Skip to content

Use rust-native error for Sabre - #16307

Open
raynelfss wants to merge 6 commits into
Qiskit:mainfrom
raynelfss:use-sabre-error
Open

Use rust-native error for Sabre #16307
raynelfss wants to merge 6 commits into
Qiskit:mainfrom
raynelfss:use-sabre-error

Conversation

@raynelfss

Copy link
Copy Markdown
Contributor

The following commits modify Sabre passes to use rust-native errors throughout their pipelines.

  • SabreDAG: for this type we will use DAGError as the main error type since it only does DAGCircuit manipulation.
  • RoutingResult: All methods do dag manipulation and thus can use DAGError freely.
  • SabreRoutingAndLayout pass: Implements the SabreLayoutError enumeration which derives from DAGError, TargetCouplingError, and DisjointLayoutError; and implements three variants:
    • TargetNoNumQubit for when the Target doesn't define num_qubits;
    • LayoutQubitsOutOfRange when partial layouts contain out-of-range physical qubits.
    • LayoutVirtualToPhys when a layout assign a virtual qubit to a physical qubit that the disjoint QPU is unable to map back to.

These additions rely on #16305.

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 following commits modify `DisjointLayout` to use rust-native errors throughout its pipeline, specifically on its `distribute_components` method.
We implement the `DisjointLayoutError` enumeration which derives from `DAGError`; and implements two variants: `MultiQEncountered` for when the interaction graph finds a multiqubit operation; `MismatchedComponentSize`  for when the circuit and the coupling map have components of differing sizes.
@raynelfss raynelfss added this to the 2.5.0 milestone May 28, 2026
@raynelfss
raynelfss requested a review from a team as a code owner May 28, 2026 15:55
@raynelfss raynelfss added the on hold Can not fix yet label May 28, 2026
@raynelfss
raynelfss requested a review from mtreinish May 28, 2026 15:55
@raynelfss raynelfss added Changelog: None Do not include in the GitHub Release changelog. Rust This PR or issue is related to Rust code in the repository mod: transpiler Issues and PRs related to Transpiler labels May 28, 2026
@qiskit-bot

Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@raynelfss raynelfss changed the title Use sabre error Use rust-native error for Sabre May 28, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 26586767794

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.02%) to 87.677%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 9 uncovered changes across 2 files (66 of 75 lines covered, 88.0%).
  • 17 coverage regressions across 3 files.

Uncovered Changes

File Changed Covered %
crates/transpiler/src/passes/sabre/layout.rs 37 31 83.78%
crates/transpiler/src/passes/disjoint_layout.rs 26 23 88.46%
Total (5 files) 75 66 88.0%

Coverage Regressions

17 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/parse.rs 12 97.15%
crates/qasm2/src/lex.rs 4 92.03%
crates/circuit/src/parameter/parameter_expression.rs 1 91.04%

Coverage Stats

Coverage Status
Relevant Lines: 123748
Covered Lines: 108498
Line Coverage: 87.68%
Coverage Strength: 965081.94 hits per line

💛 - Coveralls

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
@raynelfss raynelfss modified the milestones: 2.5.0, 2.6.0 Jun 12, 2026
The following commits modify `Sabre` passes to use rust-native errors throughout their pipelines.
- `SabreDAG`: for this type we will use `DAGError` as the main error type since it only does `DAGCircuit` manipulation.
- `RoutingResult`: All methods do dag manipulation and thus can use `DAGError` freely.
- `SabreRoutingAndLayout` pass: Implements the `SabreLayoutError` enumeration which derives from `DAGError`, `TargetCouplingError`, and `DisjointLayoutError`; and implements three variants:
-`TargetNoNumQubit` for when the `Target` doesn't define `num_qubits`;
- `LayoutQubitsOutOfRange`  when partial layouts contain out-of-range physical qubits.
- `LayoutVirtualToPhys` when a layout assign a virtual qubit to a physical qubit that the disjoint QPU is unable to map back to.

These additions rely on Qiskit#16305.
@raynelfss raynelfss moved this from Ready to Blocked in Qiskit 2.6 Aug 5, 2026
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 on hold Can not fix yet Rust This PR or issue is related to Rust code in the repository

Projects

Status: Blocked

Development

Successfully merging this pull request may close these issues.

4 participants