Skip to content
Open
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
23 changes: 12 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@

[project]
name = "vqls_prototype"
version = "0.2.0"
version = "0.3.0"
# dynamic = [
# "version",
# ]
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9,<4"
license = {file = "LICENSE.txt"}
description = "Repository for a quantum prototype"
authors = [
{ name = "Nicolas Renaud", email = "nicolas.gm.renaud@gmail.com"},
]

dependencies = [
"certifi>=2021.5.30",
"certifi>=2025.7.9",
"importlib_metadata>=4.8.1",
"qiskit-aer>=0.10.3",
"qiskit>=0.44",
"qiskit_experiments>=0.5.3",
"qiskit_ibm_runtime>=0.9.3",
"qiskit_algorithms>=0.2.1",
"qiskit-aer>=0.0.17.1",
"qiskit>=1.0.0,<2.0.0",
"qiskit_experiments>=0.11.0",
"qiskit_ibm_runtime>=0.35",
"qiskit_algorithms>=0.4.0",
"ipykernel>=6.15.0",
"matplotlib>=3.5.3",
"pylatexenc>=2.10",
"tqdm>=4.64.1",
"networkx>=2.8.4",
"sparse>=0.14.0",
"sparse>=0.15.0",
"numba>=0.57.0", #otherwise sparse messes up python 3.11 support
"treelib"
]

Expand All @@ -40,8 +41,8 @@ dev = [
"treon>=0.1.3",
"pytest>=6.2.5",
"pytest-randomly>=1.2.0",
"mypy>=0.780",
"mypy-extensions>=0.4.3",
"mypy>=1.16.00",
"mypy-extensions>=1.0.0",
"jupyter-sphinx>=0.3.2",
"nbsphinx>=0.8.8",
"sphinx-autodoc-typehints>=1.17.0",
Expand Down
20 changes: 10 additions & 10 deletions tests/test_hadamard.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import unittest
import numpy as np

from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit.library import real_amplitudes
from qiskit_algorithms import optimizers as opt
from qiskit.primitives import Estimator, Sampler
from vqls_prototype import VQLS, VQLSLog, Hybrid_QST_VQLS


from vqls_prototype.hadamard_test.hadamard_test import BatchHadammardTest
from vqls_prototype.hadamard_test.direct_hadamard_test import BatchDirectHadammardTest
from vqls_prototype.hadamard_test.hadamard_test import BatchHadamardTest
from vqls_prototype.hadamard_test.direct_hadamard_test import BatchDirectHadamardTest


class TestHadamard(unittest.TestCase):
Expand All @@ -37,7 +37,7 @@ def setUp(self):
# define ansatz
num_qubits = 2
size = 2**num_qubits
self.ansatz = RealAmplitudes(num_qubits=num_qubits, reps=3, entanglement="full")
self.ansatz = real_amplitudes(num_qubits=num_qubits, reps=3, entanglement="full")

# define ref vqls
self.vqls = VQLS(
Expand All @@ -56,7 +56,7 @@ def setUp(self):
self.vector = np.random.rand(size)
self.vector /= np.linalg.norm(self.vector)

# compute the cricuits
# compute the circuits
hdmr_tests_norm, hdmr_tests_overlap = self.vqls.construct_circuit(
self.matrix, self.vector
)
Expand All @@ -65,10 +65,10 @@ def setUp(self):
self.parameters = np.random.rand(self.ansatz.num_parameters)

# compute the reference values of the hadamard tests
self.norm_ref = BatchHadammardTest(hdmr_tests_norm).get_values(
self.norm_ref = BatchHadamardTest(hdmr_tests_norm).get_values(
self.estimator, self.parameters
)
self.overlap_ref = BatchHadammardTest(hdmr_tests_overlap).get_values(
self.overlap_ref = BatchHadamardTest(hdmr_tests_overlap).get_values(
self.estimator, self.parameters
)

Expand Down Expand Up @@ -99,7 +99,7 @@ def test_contracted_pauli(self):
)

# compute the reference values of the hadamard tests norm
norm = BatchHadammardTest(hdmr_tests_norm).get_values(
norm = BatchHadamardTest(vqls.hdmr_tests_norm).get_values(
self.estimator, self.parameters
)
norm = vqls.matrix_circuits.post_process_contracted_norm_values(norm)
Expand All @@ -109,7 +109,7 @@ def test_contracted_pauli(self):
# assert np.allclose(norm, self.norm_ref, atol=1E-6, rtol=1E-6)

# compute the reference values of the hadamard tests overlap
overlap = BatchHadammardTest(hdmr_tests_overlap).get_values(
overlap = BatchHadamardTest(hdmr_tests_overlap).get_values(
self.estimator, self.parameters
)
assert np.allclose(overlap, self.overlap_ref)
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_optimized_pauli(self):
qst_vqls.vector_pauli_product = qst_vqls.get_vector_pauli_product()

# compute the reference values of the hadamard tests
samples = BatchDirectHadammardTest(circuits).get_values(
samples = BatchDirectHadamardTest(circuits).get_values(
self.sampler, self.parameters
)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_hybrid_qst_vqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import unittest

import numpy as np
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit.library import real_amplitudes

from qiskit_algorithms.optimizers import COBYLA
from qiskit.primitives import Estimator, Sampler
Expand Down Expand Up @@ -56,14 +56,14 @@ def test_numpy_input(self):
)

rhs = np.array([0.1] * 4)
ansatz = RealAmplitudes(num_qubits=2, reps=3, entanglement="full")
ansatz = real_amplitudes(num_qubits=2, reps=3, entanglement="full")

for estimator, sampler in zip(self.estimators, self.samplers):
for opt in self.options:
vqls = Hybrid_QST_VQLS(
estimator,
ansatz,
COBYLA(maxiter=2, disp=True),
COBYLA(maxiter=10, disp=True),
options=opt,
sampler=sampler,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_qst_vqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import unittest

import numpy as np
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit.library import real_amplitudes

from qiskit_algorithms.optimizers import COBYLA
from qiskit.primitives import Estimator, Sampler
Expand Down Expand Up @@ -56,14 +56,14 @@ def test_numpy_input(self):
)

rhs = np.array([0.1] * 4)
ansatz = RealAmplitudes(num_qubits=2, reps=3, entanglement="full")
ansatz = real_amplitudes(num_qubits=2, reps=3, entanglement="full")

for estimator, sampler in zip(self.estimators, self.samplers):
for opt in self.options:
vqls = QST_VQLS(
estimator,
ansatz,
COBYLA(maxiter=2, disp=True),
COBYLA(maxiter=10, disp=True),
options=opt,
sampler=sampler,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


from qiskit_aer import Aer
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit.library import real_amplitudes
from qiskit.primitives import Sampler

from vqls_prototype.tomography import FullQST, SimulatorQST, HTreeQST, ShadowQST
Expand All @@ -27,15 +27,15 @@ def setUp(self):

# define ansatz
num_qubits = 2
self.ansatz = RealAmplitudes(num_qubits=num_qubits, reps=3, entanglement="full")
self.ansatz = real_amplitudes(num_qubits=num_qubits, reps=3, entanglement="full")
self.parameters = 2 * np.pi * np.random.rand(self.ansatz.num_parameters)

self.ref = SimulatorQST(self.ansatz).get_relative_amplitude_sign(
self.parameters
)

def test_full_qst(self):
backend = Aer.get_backend("statevector_simulator")
backend = Aer.get_backend("aer_simulator_statevector")
_ = FullQST(self.ansatz, backend, shots=10000)
# this test fails on GH actions but not locally ...
# sol = full_qst.get_relative_amplitude_sign(self.parameters)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_vqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np

from qiskit import QuantumCircuit
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit.library import real_amplitudes
from qiskit.primitives import Estimator, Sampler

from qiskit_algorithms.optimizers import ADAM
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_numpy_input(self):
)

rhs = np.array([0.1] * 4)
ansatz = RealAmplitudes(num_qubits=2, reps=3, entanglement="full")
ansatz = real_amplitudes(num_qubits=2, reps=3, entanglement="full")

for _, (estimator, sampler) in enumerate(zip(self.estimators, self.samplers)):
for _, opt in enumerate(self.options):
Expand All @@ -87,7 +87,7 @@ def test_circuit_input_statevector(self):
"""Test the VQLS on circuits input using statevector simulator."""

num_qubits = 2
ansatz = RealAmplitudes(num_qubits=num_qubits, reps=3, entanglement="full")
ansatz = real_amplitudes(num_qubits=num_qubits, reps=3, entanglement="full")

rhs = QuantumCircuit(num_qubits)
rhs.h(0)
Expand Down
Loading