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

Solver continuation #87

Merged
merged 22 commits into from
Jan 6, 2025
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
4 changes: 2 additions & 2 deletions examples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def fetch_runner(qubit_count, tracing_runner=False):
precisely what's going on. It's only used for visualization though, so will be a little slower.
"""
if tracing_runner:
return RasqalRunner(TracingRuntime(qubit_count=qubit_count))
return RasqalRunner(TracingRuntime(qubit_count))
else:
return fetch_qasm_runner(qubit_count)

Expand Down Expand Up @@ -193,7 +193,7 @@ def qaoa():
to evolve them.
"""
print("Running qaoa.")
runner = fetch_runner(20)
runner = fetch_runner(30)
runner.run_ll(read_qir_file("qaoa.ll"))


Expand Down
3 changes: 2 additions & 1 deletion src/rasqal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["John Dumbell"]
name = "rasqal"
version = "0.1.7"
version = "0.2.0"
edition = "2021"
license = "BSD-3-Clause"
description = ""
Expand Down Expand Up @@ -34,6 +34,7 @@ num = "0.4.0"
bitflags = "2.4.0"
ndarray = "0.15.6"
num-complex = "0.4.6"
lazy_static = "1.5.0"

[lib]
crate-type = ["cdylib"]
Expand Down
9 changes: 4 additions & 5 deletions src/rasqal/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "rasqal"
version = "0.1.7"
version = "0.2.0"
requires-python = ">=3.10"
description = "A hybrid quantum-classical analysis/solving runtime."
license = { file = "LICENSE" }
Expand All @@ -22,10 +22,9 @@ authors = [
]

dependencies = [
"qiskit==0.45.*,<1.0.0",
"qiskit-optimization>=0.4.0",
"qiskit-ignis>=0.7.0",
"qiskit-aer>=0.13.0",
"qiskit==1.2.*",
"qiskit-optimization>=0.6.1",
"qiskit-aer>=0.15.1",
"pytket>=1.31.0"
]

Expand Down
15 changes: 6 additions & 9 deletions src/rasqal/rasqal/simulators.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Oxford Quantum Circuits Ltd
from copy import copy

from typing import Dict

from qiskit.providers.models import QasmBackendConfiguration

from qiskit import QiskitError, QuantumCircuit, transpile
from qiskit_aer import AerSimulator
from qiskit_aer.backends import AerSimulator
from qiskit_aer.backends.backendconfiguration import AerBackendConfiguration

from .runtime import RasqalRunner
from .adaptors import BuilderAdaptor, RuntimeAdaptor
Expand Down Expand Up @@ -71,14 +71,11 @@ def __init__(self, qubit_count=30):
self.qubit_count = qubit_count

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

circuit = builder.circuit
# TODO: Needs a more nuanced try/catch. Some exceptions we should catch, others we should re-throw.
try:
job = qasm_sim.run(transpile(circuit, qasm_sim), shots=builder.shot_count)
results = job.result()
Expand Down
10 changes: 8 additions & 2 deletions src/rasqal/src/analysis/projections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ impl QuantumProjection {
}
}

let took = start.elapsed();
let ms_duration = took.as_millis();
if ms_duration > 1000 {
log!(Level::Info, "Building solver took {}ms", ms_duration);
} else {
log!(Level::Info, "Building solver took {}s", took.as_secs());
}

// For the projections, for now we only accept fully quantified results. Strip all
// unknown values.
let mut solver_results = Vec::new();
Expand All @@ -294,8 +302,6 @@ impl QuantumProjection {
}
}

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

Expand Down
Loading
Loading