Skip to content

feat: trajectory simulator (4/5) (#1856)#1861

Draft
bramathon wants to merge 1 commit into
1855-experimental-exact-simulatorsfrom
1856-trajectory-simulator
Draft

feat: trajectory simulator (4/5) (#1856)#1861
bramathon wants to merge 1 commit into
1855-experimental-exact-simulatorsfrom
1856-trajectory-simulator

Conversation

@bramathon

@bramathon bramathon commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Part of the effort to land the experimental noise model and simulation module (originally PR #1848, branch nonbreaking-noise-model) as a reviewable stack. This is PR 4 of 5, stacked on #1860 — review/merge in order. Closes #1856.

This PR adds TrajectorySimulator on top of the exact-simulator core: a Monte-Carlo trajectory simulator for programs with measurements and resets. Measurements and Kraus channels are compiled into a single homogeneous, zero-padded Kraus stack driven by one reusable jitted kernel (jax.lax.scan + jax.lax.switch), so repeated sampling batches reuse a single compilation. sample() streams trajectories in batches and discards state vectors, and runs data-parallel across multiple devices via jax.pmap (one independent replica per device, no cross-device communication).

It also extends ProgramSimulator to resolve measurements as sampled QuantumInstruments (the "instrument" resolver path) and adds the trajectory compressor barriers. Tests cover the trajectory pipeline, qutrit trajectories and noise channels, compression invariants, and a Surface-17 benchmark fixture.

The dynamic-shape trajectory simulator that also builds on this base lands in the final PR.

Stack

  1. Drop Python 3.9 #1852 — Drop Python 3.9
  2. Qudit Noise model #1854 — Qudit noise model
  3. Experimental exact simulators #1855 — Experimental exact simulators
  4. Trajectory simulator #1856 — Trajectory simulator (this PR)
  5. Dynamic shape trajectory simulator #1857 — Dynamic-shape trajectory simulator

Tracked in #1863.

Add TrajectorySimulator on top of the exact-simulator core: a jitted Kraus-stack
kernel for programs with measurements and resets, batched sample() that discards
states, and data-parallel multi-device sampling via jax.pmap. Includes qutrit,
compression, and Surface-17 benchmark tests. Part of splitting PR #1848.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Branch1856-trajectory-simulator
Testbedci-runner-linux

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
test/benchmarks/test_program.py::test_copy_everything_except_instructions📈 view plot
⚠️ NO THRESHOLD
9,447.78 ms
test/benchmarks/test_program.py::test_instructions📈 view plot
⚠️ NO THRESHOLD
3,102.35 ms
test/benchmarks/test_program.py::test_iteration📈 view plot
⚠️ NO THRESHOLD
3,145.77 ms
test/benchmarks/test_state_vector.py::TestJitCompileTime::test_density_matrix_compile_depth[20L]📈 view plot
⚠️ NO THRESHOLD
649.51 ms
test/benchmarks/test_state_vector.py::TestJitCompileTime::test_density_matrix_compile_depth[40L]📈 view plot
⚠️ NO THRESHOLD
1,446.15 ms
test/benchmarks/test_state_vector.py::TestJitCompileTime::test_density_matrix_compile_depth[5L]📈 view plot
⚠️ NO THRESHOLD
311.40 ms
test/benchmarks/test_state_vector.py::TestJitCompileTime::test_state_vector_compile_depth[10L]📈 view plot
⚠️ NO THRESHOLD
208.83 ms
test/benchmarks/test_state_vector.py::TestJitCompileTime::test_state_vector_compile_depth[40L]📈 view plot
⚠️ NO THRESHOLD
199.68 ms
test/benchmarks/test_state_vector.py::TestJitCompileTime::test_state_vector_compile_depth[80L]📈 view plot
⚠️ NO THRESHOLD
204.82 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_17q_batch_size[b16]📈 view plot
⚠️ NO THRESHOLD
133,559.24 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_17q_batch_size[b64]📈 view plot
⚠️ NO THRESHOLD
115,347.66 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_17q_batch_size[b8]📈 view plot
⚠️ NO THRESHOLD
152,155.43 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_batch_size[b16]📈 view plot
⚠️ NO THRESHOLD
43,935.62 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_batch_size[b64]📈 view plot
⚠️ NO THRESHOLD
28,356.32 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_batch_size[b8]📈 view plot
⚠️ NO THRESHOLD
65,877.68 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_depth[10L]📈 view plot
⚠️ NO THRESHOLD
32,874.37 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_depth[1L]📈 view plot
⚠️ NO THRESHOLD
14,425.25 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_depth[20L]📈 view plot
⚠️ NO THRESHOLD
54,554.64 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_depth[3L]📈 view plot
⚠️ NO THRESHOLD
18,313.40 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_qubits[12q]📈 view plot
⚠️ NO THRESHOLD
11,481.30 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_qubits[15q]📈 view plot
⚠️ NO THRESHOLD
32,509.87 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_qubits[3q]📈 view plot
⚠️ NO THRESHOLD
3,493.46 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_qubits[6q]📈 view plot
⚠️ NO THRESHOLD
5,586.40 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_qubits[9q]📈 view plot
⚠️ NO THRESHOLD
7,326.07 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_subsystem_size[s0]📈 view plot
⚠️ NO THRESHOLD
91,086.65 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_scaling_subsystem_size[s1]📈 view plot
⚠️ NO THRESHOLD
32,791.45 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_surface17_depth5_cycle_noise📈 view plot
⚠️ NO THRESHOLD
78,689.72 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_surface17_depth5_cycle_noise_low_trajectory📈 view plot
⚠️ NO THRESHOLD
4,889.98 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_surface17_depth5_cycle_noise_measurements_only_micro📈 view plot
⚠️ NO THRESHOLD
2,318.33 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_surface17_depth5_cycle_noise_micro📈 view plot
⚠️ NO THRESHOLD
4,053.45 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_surface17_depth5_cycle_noise_micro_jit📈 view plot
⚠️ NO THRESHOLD
58.93 ms
test/benchmarks/test_state_vector.py::TestPerformance::test_surface17_depth5_cycle_noise_no_measurements_micro📈 view plot
⚠️ NO THRESHOLD
2,787.33 ms
🐰 View full continuous benchmarking report in Bencher

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