Skip to content

Implement Mixed Magnitude Approximation - #1925

Open
Acciaccatura wants to merge 11 commits into
quantumlib:mainfrom
Acciaccatura:issue1759
Open

Implement Mixed Magnitude Approximation#1925
Acciaccatura wants to merge 11 commits into
quantumlib:mainfrom
Acciaccatura:issue1759

Conversation

@Acciaccatura

@Acciaccatura Acciaccatura commented Aug 6, 2026

Copy link
Copy Markdown

hi! i tried to attempt a solution for mixed magnitude approximation (https://arxiv.org/pdf/2203.10064) for #1759 - though I am unsure how to test this implementation. it appears I need a diamond_norm_distance_to_unitary for ProbabilisticChannel implemented.

I've attempted to compute the bounds from Proposition 3.22 in the paper and have received favorable results - e.g.:

def mixed_magnitude_approx(
    ...
    # Error Calculation
    theta_under = config.arccos(abs(rx_under_rotation.to_matrix().numpy(config)[0, 0]))
    theta_over = config.arccos(abs(rx_over_rotation.to_matrix().numpy(config)[0, 0]))
    e1 = prob_channel.c1.diamond_norm_distance_to_unitary(
        rsad.rz(alpha, config)
        @ rsad.rx(theta_under * 2, config)
        @ rsad.rz(beta, config),
        config,
    ) * prob_channel.probability
    e2 = prob_channel.c2.diamond_norm_distance_to_unitary(
        rsad.rz(alpha, config)
        @ rsad.rx(theta_over * 2, config)
        @ rsad.rz(beta, config),
        config,
    ) * (1 - prob_channel.probability)
    e3 = rz_prob_approx.diamond_norm_distance_to_rz(-theta / 2, config)
    print(e1 + e2 + e3)
    ...

config = rs.with_dps(50)
us = stats.unitary_group(2).rvs(10, 0)
eps = 1e-3
for u in us:
    res = rs.mixed_magnitude_approx(u, eps, 50, config)
0.00063295290417069638736463688951349364676632387644143
0.00044495825518227126465986035869209125040344705482603
0.00068678532347280860266220444494659546893651156301564
0.00063227894577241044968894582320848073120030037333944
0.00044696254374123455166776821713373312007025357696207
0.00042205905072231409651741923166395286247539076098184
0.00037267871666233144221246383761310906871129709819125
0.0004292293819301834248569711465714788766709143123124
0.00054495476265531771051471509429865353542798466889997
0.00049815457660287823583789800426226054774201469469522

any advice? thanks for taking a look!

@Acciaccatura
Acciaccatura marked this pull request as ready for review August 20, 2026 02:59

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the mixed_magnitude_approx protocol for approximating unitaries, along with its corresponding exports. The review feedback highlights opportunities to pass the relative_norm_solver parameter down to internal calls (mixed_diagonal_protocol and diagonal_unitary_approx) to respect custom solvers, and suggests avoiding redundant .to_matrix() conversions by passing UnitaryChannel objects directly to from_unitaries.

Comment thread qualtran/rotation_synthesis/protocols/_clifford_t_synthesis.py
Comment thread qualtran/rotation_synthesis/protocols/_clifford_t_synthesis.py Outdated
Comment thread qualtran/rotation_synthesis/protocols/_clifford_t_synthesis.py
Comment thread qualtran/rotation_synthesis/protocols/_clifford_t_synthesis.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant