Skip to content
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
5 changes: 3 additions & 2 deletions demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ python -m venv qlbm-cpu-venv
source qlbm-cpu-venv/bin/activate
mkdir qlbm-output
pip install --upgrade pip
pip install qlbm jupyter ipykernel matplotlib seaborn pandas
jupyter-lab
pip install -e ..[cpu,dev,docs]
pip install jupyter ipykernel seaborn pandas
jupyter lab
```

Currently, the following directories are available:
Expand Down
30 changes: 11 additions & 19 deletions demos/benchmarks/algorithm_scalability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
"We consider two lenses of scalability. First, we analyze the high-level scaling of algorithms as a function of the underlying lattice. Second, we consider the practical scalability of the algorithms after transpilation to more restrictive gate sets. In the latter, we also analyze the performance of compilation software on specific QBM instances."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install qlbm matplotlib seaborn pandas"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -30,7 +21,8 @@
"from logging import Logger, getLogger\n",
"from typing import List\n",
"\n",
"from pytket.extensions.qulacs import QulacsBackend as TketQulacsBackend\n",
"from pytket.extensions.qiskit import AerStateBackend as TketQiskitBackend\n",
"from qiskit_aer import AerSimulator\n",
"\n",
"from qlbm.components import (\n",
" CQLBM,\n",
Expand Down Expand Up @@ -76,7 +68,7 @@
" compiler_platform: List[str],\n",
" target_platform: List[str],\n",
" optimization_levels: List[int],\n",
" backend: TketQulacsBackend | None,\n",
" backend: TketQiskitBackend | None,\n",
" num_repetitions: int = 5,\n",
") -> None:\n",
" for rep in range(num_repetitions):\n",
Expand Down Expand Up @@ -142,13 +134,13 @@
" }, # 0 Obstacles\n",
" {\n",
" \"lattice\": {\"dim\": {\"x\": 8, \"y\": 8}, \"velocities\": {\"x\": 4, \"y\": 4}},\n",
" \"geometry\": [{\"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"}],\n",
" \"geometry\": [{\"shape\": \"cuboid\", \"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"}],\n",
" }, # 1 Obstacle\n",
" {\n",
" \"lattice\": {\"dim\": {\"x\": 8, \"y\": 8}, \"velocities\": {\"x\": 4, \"y\": 4}},\n",
" \"geometry\": [\n",
" {\"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"},\n",
" {\"x\": [5, 6], \"y\": [5, 6], \"boundary\": \"specular\"},\n",
" {\"shape\": \"cuboid\", \"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"},\n",
" {\"shape\": \"cuboid\", \"x\": [5, 6], \"y\": [5, 6], \"boundary\": \"specular\"},\n",
" ],\n",
" }, # 2 Obstacles\n",
"]\n",
Expand Down Expand Up @@ -183,9 +175,9 @@
" logger,\n",
" dummy_logger,\n",
" \"QISKIT\",\n",
" \"QULACS\",\n",
" \"QISKIT\",\n",
" [0],\n",
" None,\n",
" AerSimulator(),\n",
" num_repetitions=1,\n",
")"
]
Expand All @@ -203,9 +195,9 @@
" logger,\n",
" dummy_logger,\n",
" \"TKET\",\n",
" \"QULACS\",\n",
" \"QISKIT\",\n",
" [0],\n",
" TketQulacsBackend(),\n",
" AerSimulator(),\n",
" num_repetitions=1,\n",
")\n"
]
Expand Down Expand Up @@ -443,7 +435,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
"version": "3.12.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 3 additions & 1 deletion demos/benchmarks/qiskit_qulacs_comparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Runtime Comparison\n",
"# This demo is deprecated and only works with older versions of `qlbm`.\n",
"\n",
"### Runtime Comparison\n",
"\n",
"This notebook showcases how `qlbm` enables the comparison of multiple runners for the analysis of runtime performance of QBMs.\n",
"\n",
Expand Down
17 changes: 4 additions & 13 deletions demos/benchmarks/statevector_snapshots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
"In this notebook, we showcase this feature and analyse its impact."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install qlbm matplotlib seaborn pandas"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -175,13 +166,13 @@
" },\n",
" {\n",
" \"lattice\": {\"dim\": {\"x\": 8, \"y\": 8}, \"velocities\": {\"x\": 4, \"y\": 4}},\n",
" \"geometry\": [{\"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"}],\n",
" \"geometry\": [{\"shape\": \"cuboid\", \"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"}],\n",
" },\n",
" {\n",
" \"lattice\": {\"dim\": {\"x\": 8, \"y\": 8}, \"velocities\": {\"x\": 4, \"y\": 4}},\n",
" \"geometry\": [\n",
" {\"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"},\n",
" {\"x\": [5, 6], \"y\": [5, 6], \"boundary\": \"specular\"},\n",
" {\"shape\": \"cuboid\", \"x\": [5, 6], \"y\": [1, 2], \"boundary\": \"specular\"},\n",
" {\"shape\": \"cuboid\", \"x\": [5, 6], \"y\": [5, 6], \"boundary\": \"specular\"},\n",
" ],\n",
" },\n",
"]\n",
Expand Down Expand Up @@ -440,7 +431,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
"version": "3.12.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions demos/simulation/lqlga_simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "qiskit2-venv",
"language": "python",
"name": "python3"
},
Expand All @@ -260,7 +260,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.0"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions demos/simulation/spacetime_simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "qiskit2-venv",
"language": "python",
"name": "python3"
},
Expand All @@ -144,7 +144,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.0"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion qlbm/lattice/geometry/shapes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_lqlga_reflection_data_d1q2(
def get_lqlga_reflection_data_d1q3(
self,
) -> List[LQLGAPointwiseReflectionData]:
"""Calculate space-time reflection data for :math:`D_1Q_2` :class:`.LQLGA`."""
"""Calculate space-time reflection data for :math:`D_1Q_3` :class:`.LQLGA`."""
pass


Expand Down
48 changes: 24 additions & 24 deletions test/integration/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,29 @@ def test_qiskit_target_compilation(

assert isinstance(compiled_circuit, QiskitQC)

# Qulacs is not currently supported due to qiskit 2.0
# @pytest.mark.parametrize(
# "lattice_fixture,velocity,compiler_platform",
# list(
# product(
# ["lattice_symmetric_small_2d", "lattice_asymmetric_medium_3d"],
# list(range(3)),
# ["QISKIT", "TKET"],
# )
# ),
# )
# def test_qulacs_target_compilation(
# lattice_fixture, velocity, compiler_platform, request
# ):
# lattice = request.getfixturevalue(lattice_fixture)
# num_velocities = (
# lattice.num_velocities[0] + 1
# ) # +1 because velocities are between 0 and n_vi
# velocities = get_time_series(num_velocities)[velocity]
# op = CollisionlessStreamingOperator(lattice, velocities)
# compiler = CircuitCompiler(compiler_platform, "QULACS")

@pytest.mark.parametrize(
"lattice_fixture,velocity,compiler_platform",
list(
product(
["lattice_symmetric_small_2d", "lattice_asymmetric_medium_3d"],
list(range(3)),
["QISKIT", "TKET"],
)
),
)
def test_qulacs_target_compilation(
lattice_fixture, velocity, compiler_platform, request
):
lattice = request.getfixturevalue(lattice_fixture)
num_velocities = (
lattice.num_velocities[0] + 1
) # +1 because velocities are between 0 and n_vi
velocities = get_time_series(num_velocities)[velocity]
op = CollisionlessStreamingOperator(lattice, velocities)
compiler = CircuitCompiler(compiler_platform, "QULACS")

# Qulacs backend is determined automatically
compiled_circuit = compiler.compile(op, None, 0)
# # Qulacs backend is determined automatically
# compiled_circuit = compiler.compile(op, None, 0)

assert isinstance(compiled_circuit, QulacsQC)
# assert isinstance(compiled_circuit, QulacsQC)
66 changes: 33 additions & 33 deletions test/integration/execution_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import pytest
from qiskit_aer import AerSimulator

Expand Down Expand Up @@ -83,35 +82,36 @@ def test_collisionless_qiskit_execution(
)


@pytest.mark.parametrize("statevector_sampling", [True, False])
def test_spacetime_qiskit_execution(
spacetime_circuits,
statevector_sampling,
):
cfg = SimulationConfig(
initial_conditions=spacetime_circuits["initial_conditions"],
algorithm=spacetime_circuits["algorithm"],
postprocessing=spacetime_circuits["postprocessing"],
measurement=spacetime_circuits["measurement"],
target_platform="QISKIT",
compiler_platform="QISKIT",
optimization_level=0,
execution_backend=AerSimulator(method="statevector"),
sampling_backend=AerSimulator(method="statevector")
if statevector_sampling
else None,
statevector_sampling=statevector_sampling,
)

cfg.validate()
cfg.prepare_for_simulation()

runner = QiskitRunner(cfg, spacetime_circuits["lattice"])

# Simulate the circuits using both snapshots and sampling
runner.run(
2, # Number of time steps
512, # Number of shots per time step
f"{OUTPUT_DIR}/spacetime-sampling-{int(statevector_sampling)}",
statevector_snapshots=True,
)
# Qulacs is not currently supported due to qiskit 2.0
# @pytest.mark.parametrize("statevector_sampling", [True, False])
# def test_spacetime_qiskit_execution(
# spacetime_circuits,
# statevector_sampling,
# ):
# cfg = SimulationConfig(
# initial_conditions=spacetime_circuits["initial_conditions"],
# algorithm=spacetime_circuits["algorithm"],
# postprocessing=spacetime_circuits["postprocessing"],
# measurement=spacetime_circuits["measurement"],
# target_platform="QISKIT",
# compiler_platform="QISKIT",
# optimization_level=0,
# execution_backend=AerSimulator(method="statevector"),
# sampling_backend=AerSimulator(method="statevector")
# if statevector_sampling
# else None,
# statevector_sampling=statevector_sampling,
# )

# cfg.validate()
# cfg.prepare_for_simulation()

# runner = QiskitRunner(cfg, spacetime_circuits["lattice"])

# # Simulate the circuits using both snapshots and sampling
# runner.run(
# 2, # Number of time steps
# 512, # Number of shots per time step
# f"{OUTPUT_DIR}/spacetime-sampling-{int(statevector_sampling)}",
# statevector_snapshots=True,
# )
1 change: 1 addition & 0 deletions test/resources/symmetric_2d_1_obstacle.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"geometry": [
{
"shape": "cuboid",
"x": [5, 6],
"y": [1, 2],
"boundary": "specular"
Expand Down
1 change: 1 addition & 0 deletions test/resources/symmetric_2d_1_obstacle_q4.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"geometry": [
{
"shape": "cuboid",
"x": [1, 2],
"y": [1, 2],
"boundary": "specular"
Expand Down