Skip to content
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

Oxidize synth_permutation_acg #12543

Merged
merged 33 commits into from
Jul 2, 2024
Merged

Oxidize synth_permutation_acg #12543

merged 33 commits into from
Jul 2, 2024

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Jun 11, 2024

Summary

Closes #12226. This could in future be further improved by constructing the circuit in Rust directly.

Details and comments

A small benchmark for 1000 qubit circuit on random circuits with depth 1000 gives

(main) Took 46.50923681259155s for 10000 reps on 1000 qubits
(this PR) Took 16.09170889854431s for 10000 reps on 1000 qubits

It seems that 99% of this improvement comes from constructing the circuit in Rust, not from porting doing the permutation logic.

I'm happy about any comments or possible improvements, as this is my first Rust PR 🙂

@Cryoris Cryoris added the Rust This PR or issue is related to Rust code in the repository label Jun 11, 2024
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

@coveralls
Copy link

coveralls commented Jun 11, 2024

Pull Request Test Coverage Report for Build 9463371888

Details

  • 51 of 52 (98.08%) changed or added relevant lines in 2 files are covered.
  • 27 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.03%) to 89.574%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/permutation.rs 50 51 98.04%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 9 92.11%
crates/qasm2/src/parse.rs 18 96.69%
Totals Coverage Status
Change from base Build 9455662900: -0.03%
Covered Lines: 62525
Relevant Lines: 69803

💛 - Coveralls

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

I tried taking a look as an exercise and added a few comments, I hope they can be helpful.

crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jun 17, 2024

Pull Request Test Coverage Report for Build 9549394978

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 65 of 78 (83.33%) changed or added relevant lines in 2 files are covered.
  • 18 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 89.718%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/permutation.rs 62 75 82.67%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 6 91.35%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 9500158747: -0.04%
Covered Lines: 63434
Relevant Lines: 70704

💛 - Coveralls

Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

I think that this PR also needs release notes.

@coveralls
Copy link

coveralls commented Jun 19, 2024

Pull Request Test Coverage Report for Build 9579566605

Details

  • 65 of 78 (83.33%) changed or added relevant lines in 2 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.009%) to 89.76%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/permutation.rs 62 75 82.67%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.62%
Totals Coverage Status
Change from base Build 9578841868: -0.009%
Covered Lines: 63612
Relevant Lines: 70869

💛 - Coveralls

@ShellyGarion ShellyGarion added this to the 1.2.0 milestone Jun 20, 2024
@Cryoris
Copy link
Contributor Author

Cryoris commented Jun 21, 2024

Let's merge #12605 first to have the right directory structure.

@coveralls
Copy link

coveralls commented Jun 21, 2024

Pull Request Test Coverage Report for Build 9610372304

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 61 of 74 (82.43%) changed or added relevant lines in 2 files are covered.
  • 66 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.05%) to 89.72%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/permutation.rs 58 71 81.69%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.37%
crates/qasm2/src/parse.rs 12 97.15%
qiskit/circuit/quantumcircuit.py 23 95.69%
qiskit/visualization/pulse_v2/device_info.py 28 39.71%
Totals Coverage Status
Change from base Build 9578841868: -0.05%
Covered Lines: 63597
Relevant Lines: 70884

💛 - Coveralls

Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

Generally, this code looks good. It only needs to be refactored since it conflicts with the main branch, and some further documentation is needed.

crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
crates/accelerate/src/permutation.rs Outdated Show resolved Hide resolved
ShellyGarion
ShellyGarion previously approved these changes Jul 2, 2024
Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @Cryoris !

@coveralls
Copy link

coveralls commented Jul 2, 2024

Pull Request Test Coverage Report for Build 9761267322

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 63 of 64 (98.44%) changed or added relevant lines in 4 files are covered.
  • 392 unchanged lines in 9 files lost coverage.
  • Overall coverage decreased (-0.03%) to 89.795%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/accelerate/src/synthesis/permutation/utils.rs 40 41 97.56%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
crates/qasm2/src/lex.rs 1 92.88%
crates/qasm2/src/parse.rs 12 97.15%
crates/circuit/src/circuit_data.rs 21 90.81%
crates/circuit/src/circuit_instruction.rs 31 95.09%
crates/circuit/src/dag_node.rs 32 83.67%
qiskit/dagcircuit/dagcircuit.py 56 92.15%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 58 88.35%
crates/circuit/src/operations.rs 180 78.96%
Totals Coverage Status
Change from base Build 9751520597: -0.03%
Covered Lines: 64527
Relevant Lines: 71860

💛 - Coveralls

@Cryoris Cryoris enabled auto-merge July 2, 2024 13:33
@coveralls
Copy link

coveralls commented Jul 2, 2024

Pull Request Test Coverage Report for Build 9762022533

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 70 of 70 (100.0%) changed or added relevant lines in 4 files are covered.
  • 399 unchanged lines in 8 files lost coverage.
  • Overall coverage decreased (-0.06%) to 89.77%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.11%
crates/qasm2/src/parse.rs 18 95.77%
crates/circuit/src/circuit_data.rs 21 90.81%
crates/circuit/src/circuit_instruction.rs 31 95.09%
crates/circuit/src/dag_node.rs 32 83.67%
qiskit/dagcircuit/dagcircuit.py 56 92.15%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 58 88.35%
crates/circuit/src/operations.rs 180 78.96%
Totals Coverage Status
Change from base Build 9751520597: -0.06%
Covered Lines: 64514
Relevant Lines: 71866

💛 - Coveralls

@Cryoris Cryoris added this pull request to the merge queue Jul 2, 2024
Merged via the queue into Qiskit:main with commit c674913 Jul 2, 2024
15 checks passed
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Jul 2, 2024
After the recently merged Qiskit#12543 when working with Rust 1.79 cargo fmt
makes a small formatting change that rust 1.70 wouldn't and clippy makes
flags a &Vec<_> that should be a slice &[_] instead. This commit makes
these two small chagnes so they're not an issue for people building with
the latest stable version of rust, not just our MSRV.
github-merge-queue bot pushed a commit that referenced this pull request Jul 2, 2024
After the recently merged #12543 when working with Rust 1.79 cargo fmt
makes a small formatting change that rust 1.70 wouldn't and clippy makes
flags a &Vec<_> that should be a slice &[_] instead. This commit makes
these two small chagnes so they're not an issue for people building with
the latest stable version of rust, not just our MSRV.
@Cryoris Cryoris deleted the permutation-utils branch July 10, 2024 09:50
@ElePT ElePT added the Changelog: New Feature Include in the "Added" section of the changelog label Jul 30, 2024
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
* Move utility functions _inverse_pattern and _get_ordered_swap to Rust

* fix formatting and pylint issues

* Changed input type to `PyArrayLike1<i64, AllowTypeChange>`

* Refactor `permutation.rs`, clean up imports, fix coverage error

* fix docstring for `_inverse_pattern`

Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>

* fix docstring for `_get_ordered_swap`

Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>

* remove pymodule nesting

* remove explicit `AllowTypeChange`

* Move input validation out of `_inverse_pattern` and `_get_ordered_swap`

* oxidization attempt no. 1

* working version!

maybe faster possible...

* move more into rust & fix clones

* layouting & comments

* dangling comment

* circuit construction in rust

* remove dangling code

* more lint

* add reno

* drop redundant Ok(expect())

* Implements Shelly's suggestions

* simplify code a little

---------

Co-authored-by: jpacold <jpacold@gmail.com>
Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
After the recently merged Qiskit#12543 when working with Rust 1.79 cargo fmt
makes a small formatting change that rust 1.70 wouldn't and clippy makes
flags a &Vec<_> that should be a slice &[_] instead. This commit makes
these two small chagnes so they're not an issue for people building with
the latest stable version of rust, not just our MSRV.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog Rust This PR or issue is related to Rust code in the repository synthesis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port synth_permutation_acg to Rust
8 participants