Skip to content

Conversation

mtreinish
Copy link
Member

@mtreinish mtreinish commented May 10, 2025

Summary

This commit completes the decomposition of thw qiskit-accelerate crate into separate compilation units based on functionality. There are two new creates created in this commit, qiskit-synthesis and qiskit-quantum-info. The logical split between the crates is synthesis is the crate used to synthesize mathematical operations into quantum circuits, while the quantum-info crate is used to contain the data structures and functions used to model quantum information. In an earlier draft synthesis was just a submodule inside the quantum-info crate, but before finalizing this commit it was split out because the external dependencies of the functionality were distinct enough that keeping them seperate provide real advantages. Concretely this was primarily driven by being able to exclude pulling in faer and faer-ext when building the cext crate, since cext only depends currently on qiskit-quantum-info and qiskit-circuit.

Details and comments

This commit finishes the migration to the new internal dependency structure so that accelerate is towards the end of the tree and nothing depends on it accept for the Python interface crate. Here is the new dependency tree of qiskit-* crates of qiskit-pyext:

qiskit-pyext
├── qiskit-accelerate
    ├── qiskit-transpiler
├── qiskit-cext
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-transpiler
    ├── qiskit-synthesis
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-synthesis
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-circuit

@mtreinish mtreinish added the Changelog: None Do not include in changelog label May 10, 2025
@mtreinish mtreinish requested a review from a team as a code owner May 10, 2025 01:46
@mtreinish mtreinish added the Rust This PR or issue is related to Rust code in the repository label May 10, 2025
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @levbishop

@mtreinish mtreinish added this to the 2.1.0 milestone May 10, 2025
This commit completes the decomposition of thw qiskit-accelerate crate
into separate compilation units based on functionality. There are two
new creates created in this commit, qiskit-synthesis and
qiskit-quantum-info. The logical split between the crates is synthesis
is the crate used to synthesize mathematical operations into quantum
circuits, while the quantum-info crate is used to contain the data
structures and functions used to model quantum information. In an
earlier draft synthesis was just a submodule inside the quantum-info
crate, but before finalizing this commit it was split out because the
external dependencies of the functionality were distinct enough that
keeping them seperate provide real advantages. Concretely this was
primarily driven by being able to exclude pulling in faer and faer-ext
when building the cext crate, since cext only depends currently on
qiskit-quantum-info and qiskit-circuit.

This commit finishes the migration to the new internal dependency
structure so that accelerate is towards the end of the tree and nothing
depends on it accept for the Python interface crate.

qiskit-pyext
├── qiskit-accelerate
    ├── qiskit-transpiler
├── qiskit-cext
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-transpiler
    ├── qiskit-synthesis
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-synthesis
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-circuit
@mtreinish mtreinish force-pushed the split-synthesis-quantum-info branch from e36d991 to 6166bc0 Compare May 10, 2025 01:49
@coveralls
Copy link

coveralls commented May 10, 2025

Pull Request Test Coverage Report for Build 15170092988

Details

  • 24 of 29 (82.76%) changed or added relevant lines in 4 files are covered.
  • 9 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.01%) to 88.317%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/transpiler/src/passes/barrier_before_final_measurement.rs 0 1 0.0%
crates/quantum_info/src/sparse_pauli_op.rs 5 9 55.56%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/qasm2/src/lex.rs 3 91.98%
crates/circuit/src/symbol_expr.rs 5 75.31%
Totals Coverage Status
Change from base Build 15169979939: 0.01%
Covered Lines: 78455
Relevant Lines: 88833

💛 - Coveralls

@ShellyGarion
Copy link
Member

Thanks for re-organizing!

  • isometry.rs - should be moved to the circuit_library?
  • uc_gate.rs - should be moved to the circuit_library?

@mtreinish
Copy link
Member Author

mtreinish commented May 10, 2025

Thanks for re-organizing!

* `isometry.rs` - should be moved to the `circuit_library`?

* `uc_gate.rs` - should be moved to the `circuit_library`?

I left them where they were because it's not a full synthesis implementation. I only ported some of the numerics from the isometry code last year (which is both of the files). It was just enough to avoid buggy pieces in Apple's accelerate BLAS implementation that were causing spurious failures on arm64 macOS. I think we should be saving the synthesis crate for full synthesis algorithms, not partial things like these. If we port the full isometry code to Rust then I'd say we should move it over to qiskit-synthesis.

@mtreinish mtreinish force-pushed the split-synthesis-quantum-info branch from 05fdb5c to f7dbf41 Compare May 17, 2025 11:58
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.

Thanks for re-organizing the code. I only have a few questions:

  • why rayon_ext.rs was moved to quantum_info?
  • why test.rs was moved to quantum_info? perhaps it would be good to update the file name to something more meaningful.
  • pauli_exp_val.rs and sampled_exp_val.rs - should they be moved to quantum_info?
  • optimize_1q_gates - should it be moved to qiskit_transplier?

@mtreinish mtreinish removed their assignment May 20, 2025
@mtreinish
Copy link
Member Author

Thanks for re-organizing the code. I only have a few questions:

* why `rayon_ext.rs` was moved to quantum_info?

This is an implementation of traits for the rayon data parallelism library that is used in the sparse pauli op code. It's only used there and is specific to that code. It doesn't make sense to live anywhere else.

* why `test.rs` was moved to quantum_info? perhaps it would be good to update the file name to something more meaningful.

This is specifically test code for the above rayon module. I can rename it but I'd rather do that in a follow up just to try and minimize the diff here since the more code we change in this PR makes potential future issues difficult to bisect or revert.

* `pauli_exp_val.rs` and `sampled_exp_val.rs` - should they be moved to quantum_info?

pauli_exp_val.rs falls into the same category as isometry. It's just a small function accelerating a larger set of functionality. It was only ported to rust because it was written in Cython at the time we started using rust.

sampled_exp_val.rs I didn't put in quantum info because it's a standalone function that lives in qiskit/result in python. It operates on a distribution dictionary and operator string and returns the computed expectation value. I can move it if you think that makes sense, but it doesn't really interact with the quanutm info objects directly.

* `optimize_1q_gates` - should it be moved to qiskit_transplier?

This is a similar reason to isometry. It accelerates some of the internal quaternion calculations used in the transpiler pass. It's not a standalone pass and doesn't work without python which is part of what accelerate is for.

@ShellyGarion ShellyGarion self-requested a review May 21, 2025 08:10
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.

Thanks for the explanation. I see now that the code in accelerate is not ready to be moved to other parts.
One last follow-up question:
should sampled_exp_val.rs be moved into accelerate/results?

@mtreinish
Copy link
Member Author

Potentially, the directory based split never really caught on in accelerate, so we never really have add a 1:1 mapping of the Python directory structure in the rust crates. That being said it does seem to make sense there since it's about result post-processing. I'd suggest we do that in a separate PR to minimize the diff here about the crate re-organization.

ShellyGarion
ShellyGarion previously approved these changes May 21, 2025
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.

Thanks for the explanations. I've approved your PR. Let's merge it carefully, since everyone will have to rebase their PRs afterwards :)

@mtreinish mtreinish added this pull request to the merge queue May 22, 2025
Merged via the queue into Qiskit:main with commit 22367fc May 22, 2025
24 checks passed
rahaman-quantum pushed a commit to rahaman-quantum/qiskit that referenced this pull request Jun 20, 2025
…4342)

* Split out quantum-info and synthesis crates from accelerate

This commit completes the decomposition of thw qiskit-accelerate crate
into separate compilation units based on functionality. There are two
new creates created in this commit, qiskit-synthesis and
qiskit-quantum-info. The logical split between the crates is synthesis
is the crate used to synthesize mathematical operations into quantum
circuits, while the quantum-info crate is used to contain the data
structures and functions used to model quantum information. In an
earlier draft synthesis was just a submodule inside the quantum-info
crate, but before finalizing this commit it was split out because the
external dependencies of the functionality were distinct enough that
keeping them seperate provide real advantages. Concretely this was
primarily driven by being able to exclude pulling in faer and faer-ext
when building the cext crate, since cext only depends currently on
qiskit-quantum-info and qiskit-circuit.

This commit finishes the migration to the new internal dependency
structure so that accelerate is towards the end of the tree and nothing
depends on it accept for the Python interface crate.

qiskit-pyext
├── qiskit-accelerate
    ├── qiskit-transpiler
├── qiskit-cext
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-transpiler
    ├── qiskit-synthesis
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-synthesis
    ├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-quantum-info
    ├── qiskit-circuit
├── qiskit-circuit

* Update dependency package in cbindgen config

* Remove unused requirements

* Bump cargo.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants