Skip to content

Add rust-native circuit erorrs to BasisTranslator#16318

Open
raynelfss wants to merge 1 commit into
Qiskit:mainfrom
raynelfss:update_bt_error
Open

Add rust-native circuit erorrs to BasisTranslator#16318
raynelfss wants to merge 1 commit into
Qiskit:mainfrom
raynelfss:update_bt_error

Conversation

@raynelfss
Copy link
Copy Markdown
Contributor

The basis translator currently uses the BasisTranslatorError enum to supply all of the possible errors originating in the BasisTranslator pass. We had the errorss BasisCircuitError and BasisDAGCircuitError to handle the py errors used within CircuitData and DAGCircuit. The following commit changes that behavior to use the rust-native CircuitDataError and DAGError as their bases but also performs the following changes:

  • Rename BasisCircuitError to Circuit, and BasisDAGCircuitError to DAGCircuit.
  • Add a PyGate specific error.
    • This error does not implement From<PyErr> because we don't want to implicitly pass a Python error coming from somewhere else. By manually mapping, we know exactly where it originates.

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

- The basis translator currently uses the `BasisTranslatorError` enum to supply all of the possible errors originating in the `BasisTranslator` pass. We had the errorss `BasisCircuitError` and `BasisDAGCircuitError` to handle the py errors used within `CircuitData` and `DAGCircuit`. The following commit changes that behavior to use the rust-native `CircuitDataError` and `DAGError` as their bases but also performs the following changes:
- Rename `BasisCircuitError` to `Circuit`, and `BasisDAGCircuitError` to `DAGCircuit`.
- Add a `PyGate` specific error.
    - This error does not implement `From<PyErr>` because we don't want to implicitly pass a `Python` error coming from somewhere else. By manually mapping, we know exactly where it originates.
@raynelfss raynelfss requested a review from a team as a code owner May 29, 2026 17:55
@raynelfss raynelfss added the Changelog: None Do not include in the GitHub Release changelog. label May 29, 2026
@raynelfss raynelfss requested a review from Cryoris May 29, 2026 17:55
@raynelfss raynelfss added Rust This PR or issue is related to Rust code in the repository mod: transpiler Issues and PRs related to Transpiler labels May 29, 2026
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 26653369099

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.04%) to 87.56%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: 9 uncovered changes across 3 files (25 of 34 lines covered, 73.53%).
  • 14 coverage regressions across 4 files.

Uncovered Changes

File Changed Covered %
crates/transpiler/src/passes/basis_translator/errors.rs 4 0 0.0%
crates/transpiler/src/passes/basis_translator/mod.rs 25 21 84.0%
crates/transpiler/src/passes/basis_translator/compose_transforms.rs 5 4 80.0%

Coverage Regressions

14 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
crates/circuit/src/parameter/symbol_expr.rs 10 73.93%
crates/qasm2/src/lex.rs 2 93.06%
crates/circuit/src/parameter/parameter_expression.rs 1 91.04%
crates/transpiler/src/passes/basis_translator/mod.rs 1 90.22%

Coverage Stats

Coverage Status
Relevant Lines: 123869
Covered Lines: 108460
Line Coverage: 87.56%
Coverage Strength: 966773.38 hits per line

💛 - Coveralls

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 the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler 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.

3 participants