Skip to content

feat: add amplitude damping noise model (#497)#543

Open
kish-00 wants to merge 3 commits into
TeamGraphix:masterfrom
kish-00:feat/amplitude-damping
Open

feat: add amplitude damping noise model (#497)#543
kish-00 wants to merge 3 commits into
TeamGraphix:masterfrom
kish-00:feat/amplitude-damping

Conversation

@kish-00

@kish-00 kish-00 commented Jun 15, 2026

Copy link
Copy Markdown

Description

Implements amplitude damping noise model for the density matrix backend, as requested in #497.

Changes

New file: graphix/noise_models/amplitude_damping.py

  • AmplitudeDampingNoise — single-qubit amplitude damping noise
  • TwoQubitAmplitudeDampingNoise — two-qubit amplitude damping noise
  • AmplitudeDampingNoiseModel — complete noise model with all error parameters (prepare, X/Z correction, entanglement, measurement confuse/channel)

Modified files:

  • graphix/channels.py — added amplitude_damping_channel() and two_qubit_amplitude_damping_channel()
  • graphix/noise_models/__init__.py — updated exports
  • graphix/__init__.py — updated exports

Tests:

  • tests/test_kraus.py — channel tests (single/two-qubit, gamma=0/0.5/1 edge cases)
  • tests/test_noise_model.py — noise model tests (nqubits, to_kraus_channel, defaults, input_nodes, confuse_result)
  • tests/test_noisy_density_matrix.py — end-to-end simulation tests (noiseless, state changes, confuse measurement)

Verification

  • All 57 tests passing across the 3 test files
  • Ruff linting clean
  • Follows existing DepolarisingNoiseModel architecture exactly

Related

Closes #497

(I'm participating in unitaryHACK — this is my submission for this bounty)

- Add amplitude_damping_channel() and two_qubit_amplitude_damping_channel() to channels.py
- Add AmplitudeDampingNoise, TwoQubitAmplitudeDampingNoise, AmplitudeDampingNoiseModel
- Follow existing DepolarisingNoiseModel architecture exactly
- Add channel tests in test_kraus.py, noise model tests in test_noise_model.py
- Add end-to-end simulation tests in test_noisy_density_matrix.py
- All 57 tests passing, ruff linting clean
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.87%. Comparing base (6edaaef) to head (46dc05e).

Files with missing lines Patch % Lines
graphix/noise_models/amplitude_damping.py 89.39% 7 Missing ⚠️
graphix/channels.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #543      +/-   ##
==========================================
+ Coverage   88.85%   88.87%   +0.01%     
==========================================
  Files          49       50       +1     
  Lines        7135     7216      +81     
==========================================
+ Hits         6340     6413      +73     
- Misses        795      803       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pranav97nair

Copy link
Copy Markdown

Hi @kish-00 , thanks for your contribution to Graphix !

Please take a look at the failing ruff check in CI. Also, Codecov has detected that some lines in your code are not tested. Please include these in your test suite as well.

I like the tests you've added to check some specific cases of simulating a Hadamard pattern with amplitude damping noise. However, what we would really like to see is a direct comparison between the result of a pattern simulation given a random noise probability gamma at a certain step and the expected analytical output density matrix depending on gamma. This is what we currently do for the depolarizing channel using the Hadamard and RZ patterns.

Similarly, we would like to test that the resulting state from applying amplitude damping noise at the preparation, entanglement, measurement, and correction steps matches the expected density matrix. This requires computing the state analytically at each step of the pattern. Do you think you could add this to your tests?

kish-00 added 2 commits June 16, 2026 10:09
- Add 4 Kraus-operator-based helper functions that independently
  compute expected density matrix for hpat pattern under:
  - measure_channel_prob (AD on measured node)
  - prepare_error_prob (AD on each prepared node)
  - entanglement_error_prob (tensor-product AD on entangled qubits)
  - x_error_prob (AD applied after X correction)
- Add 8 parametrized tests (x 2 outcomes) comparing simulation against
  analytical computation, covering all four noise sources
- Fix ruff RUF022: keep __all__ sorted (applied separately)
@kish-00

kish-00 commented Jun 16, 2026

Copy link
Copy Markdown
Author

Analytical comparison tests added in commits 2a6808d + 46dc05e

  • Fixed RUF022 lint (all sort) ✓
  • Added 8 Kraus-operator-based analytical comparison tests covering all 4 amplitude damping noise sources (measure_channel, prepare_error, entanglement_error, x_error) × 2 measurement outcomes
  • All 44 tests pass locally, ruff clean

CI needs approval to run (first-time fork contributor). Coverage should improve since the new tests use the density matrix backend path.

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.

Implement amplitude damping noise model

2 participants