Skip to content

fix(em): rebuild virtual distillation as Hadamard test; release 2.0.0-beta.2 / 0.1.0-beta.2 - #51

Merged
jianjian01 merged 6 commits into
cq-lib:release/2.0from
jianjian01:release/2.0
Sep 29, 2026
Merged

jianjian01 merged 6 commits into
cq-lib:release/2.0from
jianjian01:release/2.0

Conversation

@jianjian01

Copy link
Copy Markdown
Collaborator

Summary

Fixes and release preparation for 2.0.0-beta.2 (Python) / 0.1.0-beta.2 (Rust/C).

Changes

  • fix(em): rebuild virtual distillation as a Hadamard-test circuit — the old copy-swap circuit used uncontrolled SWAPs, which are a no-op on the product state, so the mitigated estimate degenerated to <H>^copies (e.g. VD of <Z> on |1⟩ returned +1 instead of -1). Replaced with the Hadamard-test circuit of Huggins et al. (PRX 11, 041036, App. C), with exact density-matrix tests and updated C/Python bindings and docs. BREAKING CHANGE: estimators now receive an observable (ancilla X) on the denominator call instead of None; circuit width grows by one qubit.
  • fix(device): reject zero-qubit device factory construction — Device::line, ring, star, grid, from_edges, etc. previously accepted zero qubits and returned an empty device; all factories now return DeviceError::EmptyDevice.
  • fix(core/cqlib): remove unsupported crates.io category — drop the invalid science::physics category slug from both manifests.
  • docs(tianyan): fix wait/wait_raw parameter names to timeout and poll_interval.
  • chore(release): bump versions to 0.1.0-beta.2 / 2.0.0-beta2.

Test plan

  • cargo test --workspace --locked passes
  • pytest suite passes against the development installation
  • New tests cover the VD fix and device validation

The copy-swap circuit inserted uncontrolled SWAPs between copies. Since
S rho^⊗M S† = rho^⊗M, a bare permutation is a no-op on the product
state, so neither Tr(O rho^M) nor Tr(rho^M) was ever measured and the
mitigated estimate degenerated to <H>^copies (e.g. VD of <Z> on |1>
returned +1 instead of -1).

Replace it with the Hadamard-test circuit of Huggins et al. (PRX 11,
041036, App. C): copies preparations, one ancillary qubit prepared in
|+>, and a ladder of ancilla-controlled SWAPs between adjacent copies
realizing the derangement. The numerator observable is the original
Hamiltonian on the first copy tensored with X on the ancilla; the
denominator observable is X on the ancilla alone.

BREAKING CHANGE: estimators now receive a Hamiltonian on the
denominator call too (a single X on the ancilla) instead of None;
distinguish numerator and denominator by observable content. The
copy-swap circuit width grows from copies * base_width to
copies * base_width + 1.

Add exact density-matrix tests: |1> recovers <Z> = -1, pure states
Ry(theta) are invariant for copies 2 and 3, and depolarizing noise
matches the analytic Tr(Z rho^2)/Tr(rho^2). Update C/Python bindings
and the CN/EN docs to the new contract.
Device::line, bidirectional_line, ring, star, grid, from_edges, and
line_from_qubits previously accepted zero qubits and returned an empty
device. Add DeviceError::EmptyDevice and validate the two construction
entry points (line_from_qubits and from_u32_edges) so all factories
reject empty input.
@jianjian01
jianjian01 merged commit 2be7214 into cq-lib:release/2.0 Sep 29, 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