qgate — Quantum Trajectory Filter¶
Hardware-agnostic quantum error suppression middleware for NISQ devices.
qgate provides a framework-agnostic Python toolkit for filtering quantum computation trajectories based on mid-circuit measurement outcomes. It implements multiple conditioning strategies (global, hierarchical k-of-N, and continuous score fusion) with dynamic threshold adaptation — including the novel Galton adaptive thresholding method.
IBM Hardware Results¶
Validated on real IBM Quantum processors with up to 7.3× fidelity improvement:
| Algorithm | Backend | Metric | Standard | TSVF | Advantage |
|---|---|---|---|---|---|
| Grover (iter=4) | IBM Fez | Success probability | 0.0830 | 0.6105 | 7.3× |
| QAOA (p=1) | IBM Torino | Approximation ratio | 0.4268 | 0.8029 | 1.88× |
| VQE (L=3) | IBM Fez | Energy gap to ground | 2.398 | 1.291 | 1.86× closer |
| QPE (t=7) | IBM Fez | Phase fidelity | 0.1569 | 0.0076 | N/A |
| Utility-Scale (133Q) | IBM Torino | Cooling delta | −4.108 | −4.188 | Δ = −0.080 |
Why QPE doesn't benefit
TSVF works for amplitude-encoded algorithms (Grover, QAOA, VQE) but not for phase-coherence-encoded algorithms (QPE). See Hardware Experiments for full analysis.
NEW: Utility-Scale Stress Test (IBM Torino, 133 Qubits)
At 16,709 ISA gate depth (\(37\times T_1\)), qgate Galton filtering achieved
a negative cooling delta (Δ = −0.080), extracting correlated signal from
~99% thermal noise across 133 physical qubits — with zero variational
optimization overhead. See Utility-Scale Stress Test.
QgateSampler — Drop-in SamplerV2 Middleware¶
New in v0.6.0 — the fastest way to get these results
One import swap. Zero circuit changes. Measurable physics improvement.
Wrap any IBM backend with QgateSampler and every call is automatically
enhanced with probe injection, Galton-filtered post-selection, and clean
result reconstruction.
from qiskit_ibm_runtime import QiskitRuntimeService
from qgate import QgateSampler
service = QiskitRuntimeService()
backend = service.backend("ibm_fez")
# Wrap the backend — that's it
sampler = QgateSampler(backend=backend)
# Use exactly like SamplerV2
job = sampler.run([(qc,)])
result = job.result()
counts = result[0].data.meas.get_counts() # higher-fidelity shots only
Validated on IBM Fez (95% Bell fidelity), IBM Torino (133Q utility-scale), and IBM Brisbane (6.6% acceptance vs 0% raw post-selection).
Full QgateSampler documentation →
Statistical Validation (NEW — Mar 2026)¶
Systematic bias study: 15 independent trials × 100,000 shots, IBM Heron-class noise model.
| Experiment | Key Finding | Significance |
|---|---|---|
| Noise Robustness | MSE reduction grows 13.6% → 20.7% as noise increases | All \(p < 10^{-23}\) |
| Qubit Scaling (8–16q) | Stable 14–17% MSE; variance collapse up to 5,360× | All \(p < 10^{-46}\) |
| Cross-Algorithm | VQE +14.8%, QAOA +48.8%, Grover +24.4% | All \(p < 10^{-17}\) |
| Train/Test Split | Frozen threshold generalises: 14.7% MSE↓ on blind test set | \(p = 0.001\) *** |
The Anti-Decoherence Property
Unlike most error mitigation techniques that degrade under heavy noise, qgate improves with noise — the filter's MSE reduction scales from 13.6% (ideal) to 20.7% at the highest noise level tested. It thrives exactly where current NISQ hardware operates.
NEW: Calibrate Once, Deploy Forever
Experiment 4 proves the Galton threshold is a stable physical constant. Enterprises can run a cheap calibration circuit to find θ, freeze it, and apply it to massive production runs — saving compute while retaining full 14.7% MSE reduction on completely unseen data (\(p = 0.001\)).
Key Features¶
- QgateSampler — Transparent SamplerV2 drop-in: wrap any backend, get filtered results. Try it →
TrajectoryFilter — Main API class that orchestrates build → execute → filter
Adapter pattern — Pluggable backends (Qiskit, Cirq, PennyLane) + algorithm-specific TSVF adapters
Score fusion — α-weighted LF/HF multi-rate fusion scoring
Dynamic thresholding — Rolling z-score gating that adapts to hardware drift
Galton adaptive thresholding — Distribution-aware gating with empirical quantile or robust z-score sub-modes
CLI —
qgate run,qgate validate,--verbose/--quiet/--error-rateStructured logging — JSONL (zero deps), CSV, Parquet output with
RunLoggercontext managerImmutable config — All Pydantic models are
frozen=TrueVectorised internals — NumPy-backed
ParityOutcomeand batch scoringstdlib logging — All modules use
logging.getLogger("qgate.*")
Quick Start¶
from qgate import TrajectoryFilter, GateConfig
from qgate.adapters import MockAdapter
config = GateConfig(n_subsystems=4, n_cycles=2, shots=1024)
adapter = MockAdapter(error_rate=0.05, seed=42)
tf = TrajectoryFilter(config, adapter)
result = tf.run()
print(f"Accepted: {result.accepted_shots}/{result.total_shots}")
What's New in v0.6.0¶
- QgateSampler middleware — Transparent SamplerV2 drop-in replacement with autonomous probe injection and Galton-filtered post-selection. One import swap, zero circuit changes. Try it →
- Algorithm TSVF adapters — Grover, QAOA, VQE, QPE adapters with Two-State Vector Formalism trajectory filtering
- Galton adaptive thresholding — Distribution-aware gating with empirical quantile and robust z-score sub-modes
- IBM hardware validation — Experiments on IBM Fez, Torino & Brisbane with up to 7.3× fidelity improvement, 95% Bell fidelity on filtered shots
- 406 tests passing across Python 3.9–3.13
- NumPy vectorisation — Batch operations for scoring and filtering
- Frozen config — All Pydantic models are immutable
See the full Changelog.
Patent Notice¶
Patent Pending
This package explores runtime trajectory filtering concepts from The underlying methods are covered by pending patent applications. See License for details.