Port the Quantum Fourier Transform (QFT) all-to-all implementation to Rust - #16789
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Cryoris
left a comment
There was a problem hiding this comment.
Thanks for having a stab at this! I left some comments below.
| Vec::new() // not used in the fast path | ||
| }; | ||
|
|
||
| for j in (0..num_qubits).rev() { |
There was a problem hiding this comment.
I think this structure can be optimized, we can avoid iterating over the instruction twice and having different code paths for barrier/no barrier. This should also improve the performance a bit. There's two options that would make sense
- Write a single loop that calls
.push_standard_gateor.push_packed_operationfor barriers. This is the simpler one. - Build a single large iterator over
PackedOperations and construct the final circuit usingCircuitData::from_packed_operations-- see e.g. code in thepauli_evolution.rsmodule doing that.
I would suggest going with 1 for starters.
There was a problem hiding this comment.
Thank you for the review!
I updated the code using option 1 in
a50c6da
There was a problem hiding this comment.
thanks, I agree that the code looks better now when considering both "with barriers" and "no barrier" options :)
a50c6da to
64ed973
Compare
Cryoris
left a comment
There was a problem hiding this comment.
LGTM thanks for your contribution @simona-rc !
|
Before merging -- did you want to re-run the benchmarks after the current restructuring? |
|
I already did a re-run of the benchmarks and upddated this PR description with the results. |
… Rust (Qiskit#16789) * port qft_full to rust * Reduce duplicated code for insert_barriers=true and insert_barriers=false * Add release notes * Updated release notes * Updated to a single loop that generates the circuit directly * Updated release notes
Summary
Migrates synth_qft_full from a pure-Python implementation to Rust. The implementation includes:
Performance
Benchmarking compares the Rust implementation (current branch) against the original Python version (main branch):
Speedup ranges from ~9x at 5 qubits up to ~30x at 200 qubits. The decrease at large sizes reflects that circuit construction overhead becomes dominated by memory allocation for the instruction list rather than Python dispatch cost.
AI/LLM disclosure