-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port cx_cz_lnn to rust #13867
base: main
Are you sure you want to change the base?
Port cx_cz_lnn to rust #13867
Conversation
One or more of the following people are relevant to this code:
|
cir.push(CircuitInstructions::CX(w1 as u32, w2 as u32)); | ||
} | ||
for i in 0..n { | ||
match phase_schedule[[n - 1 - i, n - 1 - i]] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now I missed the % 4
here and it wasn't caught by testing; I'll extend the tests to ensure this is caught.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this cannot have any real effect since the values in the phase schedule are always computed modulo 4 so the code is technically correct, although I'll add the % 4
since it's better to be on the safe side.
Pull Request Test Coverage Report for Build 13386025321Details
💛 - Coveralls |
Could you perhaps also compare the time improvement of the function
|
When running on random cliffords, I'm getting a nice improvement but I suspect there's more we can do.
|
Doing quick profiling of 1.2 vs 2.0: 1.2:
2.0:
It seems the bottleneck now is handling the large number of |
Summary
Ports the
synth_cx_cz_depth_line_my
method to Rust.Closes #12231
Details and comments
This is synthesis pass for constructing circuits given by two matrices, representing CX and CZ circuits. The code generating the instruction list was ported to Rust in a straightforward manner; construction of the circuit itself is done in Python.
A quick benchmarking was performed by using
random_invertible_binary_matrix(n, seed=seed)
of the CX matrix andnp.triu(np.random.randint(0, 2, (n, n)), k=1)
for the CZ matrix, and timing the application ofsynth_cx_cz_depth_line_my
on the result, showing consistent improvement for the rust version.