Add amplitude damping noise model #544
Conversation
|
@pranav97nair Happy to get your feedback on this |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #544 +/- ##
==========================================
+ Coverage 88.85% 88.96% +0.11%
==========================================
Files 49 50 +1
Lines 7135 7216 +81
==========================================
+ Hits 6340 6420 +80
- Misses 795 796 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @CodeMaverick2 , thanks for your contribution. As you may have noticed, several other pull requests already address the same issue. Your work is in particular quite similar to #540 . Could you clarify how your contribution differs from, or improves upon, the previous works? In particular, please explain why you consider your approach to be better. |
|
Hi @pranav97nair, thanks for the review - fair question given the number of open PRs on this issue. You're right that the core implementation (Kraus channels + AmplitudeDampingNoiseModel mirroring DepolarisingNoiseModel) is structively similar across submissions, including #540. Where I think this PR adds value is mainly in test completeness and merge readiness, based on your earlier feedback on the other PRs. Compared to #540 specifically: Analytic per-step tests on the reference patterns - Following your request on #540, this PR compares simulated density matrices against hand-derived expectations for the Hadamard pattern at each isolated noise stage (prep, entanglement, measure channel, X correction), parametrized over γ ∈ {0, 0.3, 0.7, 1.0} and both measurement outcomes. The measure step also cross-checks the closed form diag((1±√(1−γ))/2). For RZ, X/Z correction and measure-confuse tests follow the same structure as the existing depolarising suite in test_noisy_density_matrix.py. API consistency with DepolarisingNoiseModel - Parameter names (prepare_error_prob, x_error_prob, etc.) and command-injection logic match the existing depolarising model exactly, so users can swap noise models without changing call sites. AmplitudeDampingNoise.gamma is used only on the Noise objects themselves, consistent with how DepolarisingNoise.prob works. CI / tooling - Ruff, mypy, pyright, and the targeted pytest suite pass locally. The one macOS 3.12 failure on the first run was a transient PyPI/network error during uv pip install scipy, not a test failure; other 3.12 jobs passed. I'm happy to re-run or address anything else that shows up. Coverage - After the Codecov note on the first commit, I added tests for input_nodes, to_kraus_channel, and the no-flip branch of confuse_result. Patch coverage is now ~99%; What I did not try to do: reinvent the physics or the noise-model architecture - the Kraus operators and model structure are standard and aligned with the issue spec. The focus here was delivering what you flagged as the harder part: tests whose correctness is explainable, in the same style as the depolarising Hadamard/RZ tests. If there are specific gaps you still see relative to #540 (e.g. a ComposeNoiseModel integration test or a direct DensityMatrix.apply_channel check), I'm happy to add them - just point me at what you'd prefer merged. Thanks again for taking the time to review. |
Summary
Implements amplitude damping noise for the density-matrix backend (closes #497): Kraus channels, noise classes,
AmplitudeDampingNoiseModel, and analytic per-step tests on Hadamard and RZ patterns.Changes
graphix/channels.py-amplitude_damping_channel()andtwo_qubit_amplitude_damping_channel()(tensor product of independent single-qubit channels)graphix/noise_models/amplitude_damping.py-AmplitudeDampingNoise,TwoQubitAmplitudeDampingNoise,AmplitudeDampingNoiseModel(mirrorsDepolarisingNoiseModelAPI:prepare_error_prob,x_error_prob, etc.)graphix/noise_models/__init__.pyandgraphix/__init__.pytest_kraus.py,test_noise_model.py,test_noisy_density_matrix.pyTest soundness
Hadamard pattern - For each noise stage in isolation (prep, entanglement, measure channel, X correction), we compare simulation to an analytic reference
_expected_hadamard(γ, step, outcome)built from:Tests are parametrized over
γ ∈ {0, 0.3, 0.7, 1.0}and both measurement outcomes. The measure-channel step also cross-checks the closed formdiag((1±√(1−γ))/2).RZ pattern - X/Z correction tests follow the depolarising suite: damping is applied only when the correction domain fires; expected state is
single_qubit_amplitude_damping_exact(rz_exact_res(α), γ)or the noiseless RZ state. Measure-confuse and zero-parameter noiseless cases are also covered.Infrastructure - Kraus operator correctness, invalid
γvalidation, noise-model transpilation on random circuits, andconfuse_resultbehaviour are tested separately.Verification