Tatopenn commited on
Commit
a08f090
·
verified ·
1 Parent(s): 4cdc0c8

Sync test_dashboard_core.py from v8.1.33

Browse files
Files changed (1) hide show
  1. test_dashboard_core.py +18 -0
test_dashboard_core.py CHANGED
@@ -72,6 +72,24 @@ def test_run_simulation_with_noise(noisy_res):
72
  assert 0.0 <= noisy_res["fidelity"] <= 1.0 + 1e-6
73
 
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  def test_run_simulation_heavy_circuit_15q():
76
  res = dc.run_simulation("Libreria Built-in", "Error Mitigation (Real-Stress)", "", "bitflip", 0.05, 64, 42, use_float32=True)
77
  assert res["n_qubits"] == 15
 
72
  assert 0.0 <= noisy_res["fidelity"] <= 1.0 + 1e-6
73
 
74
 
75
+ def test_run_simulation_noise_is_reproducible_from_seed():
76
+ # Regression guard: `seed` used to only reach np.random.seed() (which
77
+ # controls shot sampling), never NoiseModel.apply_to_sv's own
78
+ # randomness -- for a JAX statevector (the normal case here),
79
+ # apply_to_sv falls back to OS entropy unless `rng=`/`jax_key=` is
80
+ # passed explicitly, so two runs with the identical seed silently
81
+ # produced different noisy probability distributions. Found as a
82
+ # flaky test in test_mitigation_runner.py (same seed, different
83
+ # fidelity_per_scale on 2 of 3 runs) before being traced here.
84
+ kwargs = dict(source_mode="Libreria Built-in", circuit_name=BELL_CIRCUIT,
85
+ qasm_text="", noise_model="depolarizing", noise_p=0.2,
86
+ shots=64, seed=99, use_float32=True)
87
+ res_a = dc.run_simulation(**kwargs)
88
+ res_b = dc.run_simulation(**kwargs)
89
+ np.testing.assert_allclose(res_a["prob"], res_b["prob"])
90
+ assert res_a["fidelity"] == pytest.approx(res_b["fidelity"])
91
+
92
+
93
  def test_run_simulation_heavy_circuit_15q():
94
  res = dc.run_simulation("Libreria Built-in", "Error Mitigation (Real-Stress)", "", "bitflip", 0.05, 64, 42, use_float32=True)
95
  assert res["n_qubits"] == 15