Skip to content

Commit 42ba0d6

Browse files
Merge pull request #87 from oqc-community/jd/forq
Solver continuation
2 parents e72a7d0 + a5d9221 commit 42ba0d6

File tree

13 files changed

+153028
-99
lines changed

13 files changed

+153028
-99
lines changed

examples/examples.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def fetch_runner(qubit_count, tracing_runner=False):
2323
precisely what's going on. It's only used for visualization though, so will be a little slower.
2424
"""
2525
if tracing_runner:
26-
return RasqalRunner(TracingRuntime(qubit_count=qubit_count))
26+
return RasqalRunner(TracingRuntime(qubit_count))
2727
else:
2828
return fetch_qasm_runner(qubit_count)
2929

@@ -193,7 +193,7 @@ def qaoa():
193193
to evolve them.
194194
"""
195195
print("Running qaoa.")
196-
runner = fetch_runner(20)
196+
runner = fetch_runner(30)
197197
runner.run_ll(read_qir_file("qaoa.ll"))
198198

199199

src/rasqal/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
authors = ["John Dumbell"]
33
name = "rasqal"
4-
version = "0.1.7"
4+
version = "0.2.0"
55
edition = "2021"
66
license = "BSD-3-Clause"
77
description = ""
@@ -34,6 +34,7 @@ num = "0.4.0"
3434
bitflags = "2.4.0"
3535
ndarray = "0.15.6"
3636
num-complex = "0.4.6"
37+
lazy_static = "1.5.0"
3738

3839
[lib]
3940
crate-type = ["cdylib"]

src/rasqal/pyproject.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "rasqal"
3-
version = "0.1.7"
3+
version = "0.2.0"
44
requires-python = ">=3.10"
55
description = "A hybrid quantum-classical analysis/solving runtime."
66
license = { file = "LICENSE" }
@@ -22,10 +22,9 @@ authors = [
2222
]
2323

2424
dependencies = [
25-
"qiskit==0.45.*,<1.0.0",
26-
"qiskit-optimization>=0.4.0",
27-
"qiskit-ignis>=0.7.0",
28-
"qiskit-aer>=0.13.0",
25+
"qiskit==1.2.*",
26+
"qiskit-optimization>=0.6.1",
27+
"qiskit-aer>=0.15.1",
2928
"pytket>=1.31.0"
3029
]
3130

src/rasqal/rasqal/simulators.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2024 Oxford Quantum Circuits Ltd
3+
from copy import copy
34

45
from typing import Dict
56

6-
from qiskit.providers.models import QasmBackendConfiguration
7-
87
from qiskit import QiskitError, QuantumCircuit, transpile
9-
from qiskit_aer import AerSimulator
8+
from qiskit_aer.backends import AerSimulator
9+
from qiskit_aer.backends.backendconfiguration import AerBackendConfiguration
1010

1111
from .runtime import RasqalRunner
1212
from .adaptors import BuilderAdaptor, RuntimeAdaptor
@@ -71,14 +71,11 @@ def __init__(self, qubit_count=30):
7171
self.qubit_count = qubit_count
7272

7373
def execute(self, builder: QASMBuilder) -> Dict[str, int]:
74-
aer_config = QasmBackendConfiguration.from_dict(
75-
AerSimulator._DEFAULT_CONFIGURATION
76-
)
77-
aer_config.n_qubits = builder.circuit.num_qubits
78-
qasm_sim = AerSimulator(aer_config)
74+
config = copy(AerSimulator._DEFAULT_CONFIGURATION)
75+
config["n_qubits"] = self.qubit_count
76+
qasm_sim = AerSimulator(configuration=AerBackendConfiguration.from_dict(config))
7977

8078
circuit = builder.circuit
81-
# TODO: Needs a more nuanced try/catch. Some exceptions we should catch, others we should re-throw.
8279
try:
8380
job = qasm_sim.run(transpile(circuit, qasm_sim), shots=builder.shot_count)
8481
results = job.result()

src/rasqal/src/analysis/projections.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ impl QuantumProjection {
285285
}
286286
}
287287

288+
let took = start.elapsed();
289+
let ms_duration = took.as_millis();
290+
if ms_duration > 1000 {
291+
log!(Level::Info, "Building solver took {}ms", ms_duration);
292+
} else {
293+
log!(Level::Info, "Building solver took {}s", took.as_secs());
294+
}
295+
288296
// For the projections, for now we only accept fully quantified results. Strip all
289297
// unknown values.
290298
let mut solver_results = Vec::new();
@@ -294,8 +302,6 @@ impl QuantumProjection {
294302
}
295303
}
296304

297-
let took = start.elapsed();
298-
log!(Level::Info, "Solving took {}ms.", took.as_millis());
299305
AnalysisResult::from_solver_result(solver_results)
300306
}
301307

0 commit comments

Comments
 (0)