Skip to content

feat: add reproducible sampling and improve simulation and synthesis correctness - #43

Merged
jianjian01 merged 8 commits into
cq-lib:developfrom
jianjian01:develop
Sep 24, 2026
Merged

jianjian01 merged 8 commits into
cq-lib:developfrom
jianjian01:develop

Conversation

@jianjian01

Copy link
Copy Markdown
Collaborator

Add direct circuit sampling and reproducible state sampling, fix simulator correctness issues, and improve target-aware synthesis.

  • Add direct circuit sampling with statevector, density matrix, and stabilizer backends, supporting output-qubit selection and optional random seeds.
  • Support seeded sampling across all four Python state backends, with reproducible results independent of parallel scheduling.
  • Reject unsupported mid-circuit measurements and implement density-matrix reset as a deterministic channel.
  • Preserve circuit qubit mappings in state queries, including sparse and reordered qubit IDs.
  • Correct Pauli Y phases in statevector expectation and variance calculations.
  • Allow repeated get_mitigated() calls with different processing arguments without rerunning estimation.
  • Add XYX single-qubit synthesis for RX/RY bases.
  • Score two-qubit synthesis candidates after target-basis lowering and local cleanup, use conservative pruning bounds, and correct global phases in controlled-Pauli-to-RZZ decompositions.
  • Add regression coverage for simulation semantics, sampling reproducibility, observables, repeated mitigation, and synthesis selection.

Resolve measurement IDs to storage positions across simulators and keep readout noise lookup keyed by original IDs. Reject incompatible circuit mappings and commit mappings only after successful execution.

Cover sparse and reordered IDs, failure paths, state copies, and routed SWAP layouts. Verified 348 Rust state tests and 724 Python QIS tests.
Add optional keyword-only seeds to state sampling across all four Python
backends. Assign per-shot random streams before parallel execution so explicit
seeds reproduce ordered shots and projected counts independently of scheduling.
Preserve existing unseeded calls and Rust sampling signatures.

Allow ErrorMitigation.get_mitigated() to reuse collected estimates with different
processing arguments and recover from post-processing errors. Keep run() single
use and retain only the statistics required for subsequent processing.

Update type stubs and documentation, and cover seeded sampling, concurrency,
measurement projection, seed validation, and repeated mitigation in regressions.

Validation: 83 focused Python tests passed in final review; prior full suites
passed with 1830 Python tests and 3488 Rust tests (8 ignored). Clippy with warnings
denied, Ruff, formatting, and git diff checks passed.
Compute Z parity from the source amplitude index in expectation and variance calculations.

Add Rust, Python, and C regression tests for Pauli phases, Y parity, and mixed Hamiltonians.
Score source blocks, primary candidates and numerical fallbacks after one local cleanup round. Keep single-qubit scoring lowering-only to avoid recursion, and retain the source block when costs are equal.

Use conservative pruning bounds for native interactions outside CX/CY/CZ. Correct global phases in controlled-Pauli-to-RZZ decomposition rules.

  Add regression tests for cost reversal, phase preservation, fallback
  scoring, and selection consistency across pruning and cache states.
@jianjian01
jianjian01 merged commit e8917c0 into cq-lib:develop Sep 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant