QED-C: The Quantum Economic Development Consortium provides these computer programs and software for use in the fields of quantum science and engineering.
Apache License 2.0
143
stars
80
forks
source link
Bug: Max Qubit number limit Hamiltonian Simulation #430
Running the current Hamiltonian Simulation with >20Q gives:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[15], line 4
2 sys.path.insert(1, "hamiltonian-simulation/qiskit")
3 import hamiltonian_simulation_benchmark
----> 4 hamiltonian_simulation_benchmark.run(min_qubits=min_qubits, max_qubits=max_qubits, skip_qubits=skip_qubits,
5 max_circuits=max_circuits, num_shots=num_shots,
6 backend_id=backend_id, provider_backend=provider_backend,
7 hub=hub, group=group, project=project, exec_options=exec_options)
File c:\Users\2J7579897\Notebooks_general\QEDC-benchmark\QC-App-Oriented-Benchmarks\hamiltonian-simulation/qiskit\hamiltonian_simulation_benchmark.py:286, in run(min_qubits, max_qubits, max_circuits, skip_qubits, num_shots, use_XX_YY_ZZ_gates, backend_id, provider_backend, hub, group, project, exec_options, context)
284 h_x = precalculated_data['h_x'][:num_qubits] # precalculated random numbers between [-1, 1]
285 h_z = precalculated_data['h_z'][:num_qubits]
--> 286 qc = HamiltonianSimulation(num_qubits, K=k, t=t, w=w, h_x= h_x, h_z=h_z)
287 metrics.store_metric(num_qubits, circuit_id, 'create_time', time.time() - ts)
289 # collapse the sub-circuits used in this benchmark (for qiskit)
File c:\Users\2J7579897\Notebooks_general\QEDC-benchmark\QC-App-Oriented-Benchmarks\hamiltonian-simulation/qiskit\hamiltonian_simulation_benchmark.py:70, in HamiltonianSimulation(n_spins, K, t, w, h_x, h_z)
66 # loop over each trotter step, adding gates to the circuit defining the hamiltonian
67 for k in range(K):
68
69 # the Pauli spin vector product
---> 70 [qc.rx(2 * tau * w * h_x[i], qr[i]) for i in range(n_spins)]
71 [qc.rz(2 * tau * w * h_z[i], qr[i]) for i in range(n_spins)]
72 qc.barrier()
...
---> 70 [qc.rx(2 * tau * w * h_x[i], qr[i]) for i in range(n_spins)]
71 [qc.rz(2 * tau * w * h_z[i], qr[i]) for i in range(n_spins)]
72 qc.barrier()
Possible Fix:
in precalculated_data.ipynb increase hardcoded limits:
line 19: precalculated_data['h_x'] = list(2 * np.random.random(39) - 1)
line 21: precalculated_data['h_z'] = list(2 * np.random.random(29) - 1)
line 25: for n_spins in range(2,40)
or make the limits dynamic based on max_qubit_number, however, this will require a recalculation with every initialization
We only do initialization at the beginning of a run of the whole benchmark, so I don't think dynamically initializing will be a problem.
How large do you need the num_qubits to go?
Running the current Hamiltonian Simulation with >20Q gives:
Possible Fix: in
precalculated_data.ipynb
increase hardcoded limits:precalculated_data['h_x'] = list(2 * np.random.random(39) - 1)
precalculated_data['h_z'] = list(2 * np.random.random(29) - 1)
for n_spins in range(2,40)
or make the limits dynamic based on max_qubit_number, however, this will require a recalculation with every initialization