Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tutorial 1D Crystal and add config #656

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.17.2
0.17.3
1 change: 1 addition & 0 deletions pulser-simulation/pulser_simulation/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def add_config(self, config: SimConfig) -> None:
param_dict["temperature"] = noise_model.temperature
if "amplitude" in diff_noise_set:
param_dict["laser_waist"] = noise_model.laser_waist
param_dict["amp_sigma"] = noise_model.amp_sigma
if "dephasing" in diff_noise_set:
param_dict["dephasing_prob"] = noise_model.dephasing_prob
param_dict["dephasing_rate"] = noise_model.dephasing_rate
Expand Down
7 changes: 4 additions & 3 deletions tests/test_simresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def results_noisy(sim):
sim.add_config(
SimConfig(noise=("SPAM", "doppler", "amplitude"), amp_sigma=1e-3)
)
assert sim.config.amp_sigma == 1e-3
return sim.run()


Expand Down Expand Up @@ -277,7 +278,7 @@ def test_expect_noisy(results_noisy):
with pytest.raises(ValueError, match="non-diagonal"):
results_noisy.expect([bad_op])
op = qutip.tensor([qutip.qeye(2), qutip.basis(2, 0).proj()])
assert np.isclose(results_noisy.expect([op])[0][-1], 0.7466666666666666)
assert np.isclose(results_noisy.expect([op])[0][-1], 0.7333333333333334)
HGSilveri marked this conversation as resolved.
Show resolved Hide resolved


def test_plot(results_noisy, results):
Expand All @@ -294,7 +295,7 @@ def test_sim_without_measurement(seq_no_meas):
)
results_no_meas = sim_no_meas.run()
assert results_no_meas.sample_final_state() == Counter(
{"00": 80, "01": 164, "10": 164, "11": 592}
{"11": 587, "10": 165, "01": 164, "00": 84}
)


Expand Down Expand Up @@ -326,7 +327,7 @@ def test_sample_final_state_three_level(seq_no_meas, pi_pulse):
def test_sample_final_state_noisy(seq_no_meas, results_noisy):
np.random.seed(123)
assert results_noisy.sample_final_state(N_samples=1234) == Counter(
{"11": 772, "10": 190, "01": 161, "00": 111}
{"11": 725, "10": 265, "01": 192, "00": 52}
)
res_3level = QutipEmulator.from_sequence(
seq_no_meas, config=SimConfig(noise=("SPAM", "doppler"), runs=10)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,14 +799,19 @@ def test_add_config(matrices):
assert sim.config.temperature == 20000.0e-6
sim.set_config(SimConfig(noise="doppler", laser_waist=175.0))
sim.add_config(
SimConfig(noise=("SPAM", "amplitude", "dephasing"), laser_waist=172.0)
SimConfig(
noise=("SPAM", "amplitude", "dephasing"),
laser_waist=172.0,
amp_sigma=1e-2,
)
)
assert (
"amplitude" in sim.config.noise
and "dephasing" in sim.config.noise
and "SPAM" in sim.config.noise
)
assert sim.config.laser_waist == 172.0
assert sim.config.amp_sigma == 1e-2
sim.set_config(SimConfig(noise="SPAM", eta=0.5))
sim.add_config(SimConfig(noise="depolarizing"))
assert "depolarizing" in sim.config.noise
Expand Down
128 changes: 64 additions & 64 deletions tutorials/quantum_simulation/Building 1D Rydberg Crystals.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@
"name": "stdout",
HGSilveri marked this conversation as resolved.
Show resolved Hide resolved
HGSilveri marked this conversation as resolved.
Show resolved Hide resolved
"output_type": "stream",
"text": [
"10.0%. Run time: 0.00s. Est. time left: 00:00:00:00\n",
"20.0%. Run time: 0.01s. Est. time left: 00:00:00:00\n",
"30.0%. Run time: 0.01s. Est. time left: 00:00:00:00\n",
"40.0%. Run time: 0.01s. Est. time left: 00:00:00:00\n",
"50.0%. Run time: 0.02s. Est. time left: 00:00:00:00\n",
"60.0%. Run time: 0.02s. Est. time left: 00:00:00:00\n",
"70.0%. Run time: 0.02s. Est. time left: 00:00:00:00\n",
"80.0%. Run time: 0.03s. Est. time left: 00:00:00:00\n",
"90.0%. Run time: 0.03s. Est. time left: 00:00:00:00\n",
"Total run time: 0.03s\n"
"10.0%. Run time: 0.01s. Est. time left: 00:00:00:00\n",
"20.0%. Run time: 0.02s. Est. time left: 00:00:00:00\n",
"30.0%. Run time: 0.02s. Est. time left: 00:00:00:00\n",
"40.0%. Run time: 0.03s. Est. time left: 00:00:00:00\n",
"50.0%. Run time: 0.04s. Est. time left: 00:00:00:00\n",
"60.0%. Run time: 0.05s. Est. time left: 00:00:00:00\n",
"70.0%. Run time: 0.07s. Est. time left: 00:00:00:00\n",
"80.0%. Run time: 0.07s. Est. time left: 00:00:00:00\n",
"90.0%. Run time: 0.08s. Est. time left: 00:00:00:00\n",
"Total run time: 0.08s\n"
]
},
{
Expand All @@ -165,16 +165,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10.0%. Run time: 0.01s. Est. time left: 00:00:00:00\n",
"20.0%. Run time: 0.03s. Est. time left: 00:00:00:00\n",
"30.0%. Run time: 0.04s. Est. time left: 00:00:00:00\n",
"40.0%. Run time: 0.06s. Est. time left: 00:00:00:00\n",
"50.0%. Run time: 0.09s. Est. time left: 00:00:00:00\n",
"60.0%. Run time: 0.10s. Est. time left: 00:00:00:00\n",
"70.0%. Run time: 0.12s. Est. time left: 00:00:00:00\n",
"80.0%. Run time: 0.14s. Est. time left: 00:00:00:00\n",
"90.0%. Run time: 0.16s. Est. time left: 00:00:00:00\n",
"Total run time: 0.18s\n"
"10.0%. Run time: 0.02s. Est. time left: 00:00:00:00\n",
"20.0%. Run time: 0.05s. Est. time left: 00:00:00:00\n",
"30.0%. Run time: 0.07s. Est. time left: 00:00:00:00\n",
"40.0%. Run time: 0.13s. Est. time left: 00:00:00:00\n",
"50.0%. Run time: 0.17s. Est. time left: 00:00:00:00\n",
"60.0%. Run time: 0.22s. Est. time left: 00:00:00:00\n",
"70.0%. Run time: 0.27s. Est. time left: 00:00:00:00\n",
"80.0%. Run time: 0.34s. Est. time left: 00:00:00:00\n",
"90.0%. Run time: 0.39s. Est. time left: 00:00:00:00\n",
"Total run time: 0.45s\n"
]
},
{
Expand All @@ -191,16 +191,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10.0%. Run time: 0.52s. Est. time left: 00:00:00:04\n",
"20.0%. Run time: 0.98s. Est. time left: 00:00:00:03\n",
"30.0%. Run time: 1.42s. Est. time left: 00:00:00:03\n",
"40.0%. Run time: 1.89s. Est. time left: 00:00:00:02\n",
"50.0%. Run time: 2.37s. Est. time left: 00:00:00:02\n",
"60.0%. Run time: 2.83s. Est. time left: 00:00:00:01\n",
"70.0%. Run time: 3.31s. Est. time left: 00:00:00:01\n",
"80.0%. Run time: 3.77s. Est. time left: 00:00:00:00\n",
"90.0%. Run time: 4.25s. Est. time left: 00:00:00:00\n",
"Total run time: 4.68s\n"
"10.0%. Run time: 1.02s. Est. time left: 00:00:00:09\n",
"20.0%. Run time: 1.92s. Est. time left: 00:00:00:07\n",
"30.0%. Run time: 2.74s. Est. time left: 00:00:00:06\n",
"40.0%. Run time: 3.70s. Est. time left: 00:00:00:05\n",
"50.0%. Run time: 4.74s. Est. time left: 00:00:00:04\n",
"60.0%. Run time: 5.74s. Est. time left: 00:00:00:03\n",
"70.0%. Run time: 7.16s. Est. time left: 00:00:00:03\n",
"80.0%. Run time: 8.58s. Est. time left: 00:00:00:02\n",
"90.0%. Run time: 10.25s. Est. time left: 00:00:00:01\n",
"Total run time: 12.29s\n"
]
}
],
Expand Down Expand Up @@ -448,16 +448,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10.0%. Run time: 0.21s. Est. time left: 00:00:00:01\n",
"20.0%. Run time: 0.45s. Est. time left: 00:00:00:01\n",
"30.0%. Run time: 0.71s. Est. time left: 00:00:00:01\n",
"40.0%. Run time: 0.95s. Est. time left: 00:00:00:01\n",
"50.0%. Run time: 1.15s. Est. time left: 00:00:00:01\n",
"60.0%. Run time: 1.34s. Est. time left: 00:00:00:00\n",
"70.0%. Run time: 1.53s. Est. time left: 00:00:00:00\n",
"80.0%. Run time: 1.75s. Est. time left: 00:00:00:00\n",
"90.0%. Run time: 2.00s. Est. time left: 00:00:00:00\n",
"Total run time: 2.28s\n"
"10.0%. Run time: 0.76s. Est. time left: 00:00:00:06\n",
"20.0%. Run time: 1.61s. Est. time left: 00:00:00:06\n",
"30.0%. Run time: 2.55s. Est. time left: 00:00:00:05\n",
"40.0%. Run time: 3.27s. Est. time left: 00:00:00:04\n",
"50.0%. Run time: 3.86s. Est. time left: 00:00:00:03\n",
"60.0%. Run time: 4.40s. Est. time left: 00:00:00:02\n",
"70.0%. Run time: 4.99s. Est. time left: 00:00:00:02\n",
"80.0%. Run time: 5.60s. Est. time left: 00:00:00:01\n",
"90.0%. Run time: 6.35s. Est. time left: 00:00:00:00\n",
"Total run time: 7.21s\n"
]
}
],
Expand Down Expand Up @@ -530,9 +530,9 @@
" N = len(reg.qubits)\n",
" time_window = []\n",
" x = []\n",
" detunings = simul.samples[\"Global\"][\"ground-rydberg\"][\"det\"][\n",
" [int(1000 * t) for t in simul.evaluation_times[:-1]]\n",
" ]\n",
" detunings = simul.samples_obj.to_nested_dict()[\"Global\"][\"ground-rydberg\"][\n",
" \"det\"\n",
" ][[int(1000 * t) for t in simul.evaluation_times[:-1]]]\n",
"\n",
" for t, d in enumerate(detunings):\n",
" if start <= d <= end:\n",
Expand Down Expand Up @@ -617,16 +617,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10.0%. Run time: 0.71s. Est. time left: 00:00:00:06\n",
"20.0%. Run time: 1.53s. Est. time left: 00:00:00:06\n",
"30.0%. Run time: 2.41s. Est. time left: 00:00:00:05\n",
"40.0%. Run time: 3.26s. Est. time left: 00:00:00:04\n",
"50.0%. Run time: 4.11s. Est. time left: 00:00:00:04\n",
"60.0%. Run time: 4.99s. Est. time left: 00:00:00:03\n",
"70.0%. Run time: 5.83s. Est. time left: 00:00:00:02\n",
"80.0%. Run time: 6.68s. Est. time left: 00:00:00:01\n",
"90.0%. Run time: 7.53s. Est. time left: 00:00:00:00\n",
"Total run time: 8.35s\n"
"10.0%. Run time: 2.20s. Est. time left: 00:00:00:19\n",
"20.0%. Run time: 4.31s. Est. time left: 00:00:00:17\n",
"30.0%. Run time: 6.38s. Est. time left: 00:00:00:14\n",
"40.0%. Run time: 8.46s. Est. time left: 00:00:00:12\n",
"50.0%. Run time: 10.56s. Est. time left: 00:00:00:10\n",
"60.0%. Run time: 12.80s. Est. time left: 00:00:00:08\n",
"70.0%. Run time: 14.89s. Est. time left: 00:00:00:06\n",
"80.0%. Run time: 16.99s. Est. time left: 00:00:00:04\n",
"90.0%. Run time: 19.08s. Est. time left: 00:00:00:02\n",
"Total run time: 21.14s\n"
]
},
{
Expand Down Expand Up @@ -677,7 +677,7 @@
"\n",
"simul = QutipEmulator.from_sequence(seq, sampling_rate=0.1)\n",
"\n",
"occup_list = [occupation(reg, j) for j in range(simul._size)]\n",
"occup_list = [occupation(reg, j) for j in range(len(reg.qubits))]\n",
"\n",
"res = simul.run(progress_bar=True, method=\"bdf\")\n",
"\n",
Expand Down Expand Up @@ -730,16 +730,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10.0%. Run time: 1.56s. Est. time left: 00:00:00:14\n",
"20.0%. Run time: 3.02s. Est. time left: 00:00:00:12\n",
"30.0%. Run time: 4.71s. Est. time left: 00:00:00:10\n",
"40.0%. Run time: 6.75s. Est. time left: 00:00:00:10\n",
"50.0%. Run time: 8.92s. Est. time left: 00:00:00:08\n",
"60.0%. Run time: 10.56s. Est. time left: 00:00:00:07\n",
"70.0%. Run time: 12.01s. Est. time left: 00:00:00:05\n",
"80.0%. Run time: 13.47s. Est. time left: 00:00:00:03\n",
"90.0%. Run time: 14.71s. Est. time left: 00:00:00:01\n",
"Total run time: 15.92s\n"
"10.0%. Run time: 4.70s. Est. time left: 00:00:00:42\n",
"20.0%. Run time: 10.75s. Est. time left: 00:00:00:42\n",
"30.0%. Run time: 16.96s. Est. time left: 00:00:00:39\n",
"40.0%. Run time: 24.73s. Est. time left: 00:00:00:37\n",
"50.0%. Run time: 32.96s. Est. time left: 00:00:00:32\n",
"60.0%. Run time: 39.45s. Est. time left: 00:00:00:26\n",
"70.0%. Run time: 44.43s. Est. time left: 00:00:00:19\n",
"80.0%. Run time: 49.02s. Est. time left: 00:00:00:12\n",
"90.0%. Run time: 53.25s. Est. time left: 00:00:00:05\n",
"Total run time: 58.02s\n"
]
},
{
Expand Down
Loading