Skip to content

Commit

Permalink
Limit AER simulator to only use 1 thread
Browse files Browse the repository at this point in the history
  • Loading branch information
bachase committed Feb 21, 2025
1 parent 5118cc0 commit f1e0b5a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions benchmarks/scripts/expval_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def simulate_density_matrix(circuit: qiskit.QuantumCircuit) -> np.ndarray:
circuit, SINGLE_QUBIT_ERROR_RATE, TWO_QUBIT_ERROR_RATE
)
simulator = AerSimulator(
method="density_matrix", noise_model=depolarizing_noise
method="density_matrix",
noise_model=depolarizing_noise,
max_parallel_threads=1,
)
return simulator.run(circuit).result().data()["density_matrix"]

Expand Down Expand Up @@ -161,7 +163,10 @@ def fetch_pre_post_compiled_circuits(

def get_heavy_bitstrings(circuit: qiskit.QuantumCircuit) -> Set[str]:
""" "Determine the heavy bitstrings of the circuit."""
simulator = AerSimulator(method="statevector")
simulator = AerSimulator(
method="statevector",
max_parallel_threads=1,
)
result = simulator.run(circuit, shots=1024).result()
counts = list(result.get_counts().items())
median = np.median([c for (_, c) in counts])
Expand All @@ -187,13 +192,15 @@ def estimate_heavy_output_prob(
if noisy:
simulator = AerSimulator(
method="statevector",
max_parallel_threads=1,
noise_model=create_depolarizing_noise_model(
circuit, SINGLE_QUBIT_ERROR_RATE, TWO_QUBIT_ERROR_RATE
),
)
else:
simulator = AerSimulator(
method="statevector",
max_parallel_threads=1,
)
result = simulator.run(circuit).result()

Expand Down

0 comments on commit f1e0b5a

Please sign in to comment.