From e8313c9cc4488216abb4d3c995c8081b2b2dc052 Mon Sep 17 00:00:00 2001 From: Calin Georgescu Date: Tue, 19 Aug 2025 16:28:57 +0200 Subject: [PATCH 1/6] Update STQBM and LQGLA demos --- demos/simulation/lqlga_simulation.ipynb | 4 ++-- demos/simulation/spacetime_simulation.ipynb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demos/simulation/lqlga_simulation.ipynb b/demos/simulation/lqlga_simulation.ipynb index d92178b..15ebf1d 100644 --- a/demos/simulation/lqlga_simulation.ipynb +++ b/demos/simulation/lqlga_simulation.ipynb @@ -246,7 +246,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "qiskit2-venv", "language": "python", "name": "python3" }, @@ -260,7 +260,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.10" + "version": "3.13.0" } }, "nbformat": 4, diff --git a/demos/simulation/spacetime_simulation.ipynb b/demos/simulation/spacetime_simulation.ipynb index fdf50f7..112c828 100644 --- a/demos/simulation/spacetime_simulation.ipynb +++ b/demos/simulation/spacetime_simulation.ipynb @@ -130,7 +130,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "qiskit2-venv", "language": "python", "name": "python3" }, @@ -144,7 +144,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.10" + "version": "3.13.0" } }, "nbformat": 4, From 369f5c9164942594edf4a534008d00f0fce5e56b Mon Sep 17 00:00:00 2001 From: Calin Georgescu Date: Tue, 19 Aug 2025 17:56:34 +0200 Subject: [PATCH 2/6] Update benchmark demos --- demos/benchmarks/algorithm_scalability.ipynb | 30 +++++++------------ .../benchmarks/qiskit_qulacs_comparison.ipynb | 4 ++- demos/benchmarks/statevector_snapshots.ipynb | 17 +++-------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/demos/benchmarks/algorithm_scalability.ipynb b/demos/benchmarks/algorithm_scalability.ipynb index 476a09f..587571f 100644 --- a/demos/benchmarks/algorithm_scalability.ipynb +++ b/demos/benchmarks/algorithm_scalability.ipynb @@ -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, @@ -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", @@ -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", @@ -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", @@ -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", ")" ] @@ -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" ] @@ -443,7 +435,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.5" + "version": "3.12.10" } }, "nbformat": 4, diff --git a/demos/benchmarks/qiskit_qulacs_comparison.ipynb b/demos/benchmarks/qiskit_qulacs_comparison.ipynb index 0553380..989fc3d 100644 --- a/demos/benchmarks/qiskit_qulacs_comparison.ipynb +++ b/demos/benchmarks/qiskit_qulacs_comparison.ipynb @@ -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", diff --git a/demos/benchmarks/statevector_snapshots.ipynb b/demos/benchmarks/statevector_snapshots.ipynb index 69fc8db..58baa9a 100644 --- a/demos/benchmarks/statevector_snapshots.ipynb +++ b/demos/benchmarks/statevector_snapshots.ipynb @@ -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, @@ -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", @@ -440,7 +431,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.5" + "version": "3.12.10" } }, "nbformat": 4, From 0e9c857b7409c26274e02071ca345755ebbc24c9 Mon Sep 17 00:00:00 2001 From: Calin Georgescu Date: Tue, 19 Aug 2025 17:57:09 +0200 Subject: [PATCH 3/6] Remove deprecated integration tests --- test/integration/compiler_test.py | 48 +++++++++++----------- test/integration/execution_test.py | 66 +++++++++++++++--------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/test/integration/compiler_test.py b/test/integration/compiler_test.py index 58b446f..39ef697 100644 --- a/test/integration/compiler_test.py +++ b/test/integration/compiler_test.py @@ -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) diff --git a/test/integration/execution_test.py b/test/integration/execution_test.py index 418e22d..23218c2 100644 --- a/test/integration/execution_test.py +++ b/test/integration/execution_test.py @@ -1,4 +1,3 @@ - import pytest from qiskit_aer import AerSimulator @@ -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, +# ) From fc9d2b3c0db93fb1c437f5ffd782a38f066eb87e Mon Sep 17 00:00:00 2001 From: Calin Georgescu Date: Tue, 19 Aug 2025 17:57:47 +0200 Subject: [PATCH 4/6] Update integration test data specification --- test/resources/symmetric_2d_1_obstacle.json | 1 + test/resources/symmetric_2d_1_obstacle_q4.json | 1 + 2 files changed, 2 insertions(+) diff --git a/test/resources/symmetric_2d_1_obstacle.json b/test/resources/symmetric_2d_1_obstacle.json index 0eb2a89..1106c0f 100644 --- a/test/resources/symmetric_2d_1_obstacle.json +++ b/test/resources/symmetric_2d_1_obstacle.json @@ -11,6 +11,7 @@ }, "geometry": [ { + "shape": "cuboid", "x": [5, 6], "y": [1, 2], "boundary": "specular" diff --git a/test/resources/symmetric_2d_1_obstacle_q4.json b/test/resources/symmetric_2d_1_obstacle_q4.json index 379ce54..5095d51 100644 --- a/test/resources/symmetric_2d_1_obstacle_q4.json +++ b/test/resources/symmetric_2d_1_obstacle_q4.json @@ -11,6 +11,7 @@ }, "geometry": [ { + "shape": "cuboid", "x": [1, 2], "y": [1, 2], "boundary": "specular" From 4fa94169e10e3597ed1381b297eaa64dce34dcef Mon Sep 17 00:00:00 2001 From: Calin Georgescu Date: Tue, 19 Aug 2025 18:03:15 +0200 Subject: [PATCH 5/6] Update demos documentation --- demos/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demos/README.md b/demos/README.md index b0e497a..6dd6ff5 100644 --- a/demos/README.md +++ b/demos/README.md @@ -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: From 0087713b89c4000cffd676b7fd686c9e7fee640b Mon Sep 17 00:00:00 2001 From: Calin Georgescu Date: Tue, 26 Aug 2025 13:32:10 +0200 Subject: [PATCH 6/6] Fix documentation typo --- qlbm/lattice/geometry/shapes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qlbm/lattice/geometry/shapes/base.py b/qlbm/lattice/geometry/shapes/base.py index 0dd18f9..8bac33d 100644 --- a/qlbm/lattice/geometry/shapes/base.py +++ b/qlbm/lattice/geometry/shapes/base.py @@ -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