diff --git a/.github/workflows/test_development_versions.yml b/.github/workflows/test_development_versions.yml index 61f68ae63..821177279 100644 --- a/.github/workflows/test_development_versions.yml +++ b/.github/workflows/test_development_versions.yml @@ -32,6 +32,8 @@ jobs: python -m pip install --upgrade pip tox python -m pip install toml typer python tools/extremal-python-dependencies.py pin-dependencies \ + "qiskit @ git+https://github.com/Qiskit/qiskit.git" \ + "qiskit-nature @ git+https://github.com/qiskit-community/qiskit-nature.git" \ "qiskit-ibm-runtime @ git+https://github.com/Qiskit/qiskit-ibm-runtime.git" \ --inplace - name: Modify tox.ini for more thorough check diff --git a/circuit_knitting/forging/cholesky_decomposition.py b/circuit_knitting/forging/cholesky_decomposition.py index ed9e4eb72..d7cd4952d 100644 --- a/circuit_knitting/forging/cholesky_decomposition.py +++ b/circuit_knitting/forging/cholesky_decomposition.py @@ -30,6 +30,10 @@ to_chemist_ordering, to_physicist_ordering, ) +from qiskit_nature.second_q.operators.symmetric_two_body import ( + SymmetricTwoBodyIntegrals, + unfold, +) from .entanglement_forging_ansatz import EntanglementForgingAnsatz from .entanglement_forging_operator import EntanglementForgingOperator @@ -84,6 +88,10 @@ def cholesky_decomposition( eri = to_chemist_ordering( problem.hamiltonian.electronic_integrals.two_body.alpha["++--"] ) + if isinstance(hcore, SymmetricTwoBodyIntegrals): + hcore = unfold(hcore) + if isinstance(eri, SymmetricTwoBodyIntegrals): + eri = unfold(eri) num_alpha = problem.num_alpha if num_alpha is None: raise ValueError( diff --git a/pyproject.toml b/pyproject.toml index d5bedab89..da58306cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "qiskit-aer>=0.12.0", "qiskit>=0.44.1", "qiskit-algorithms>=0.2.1", - "qiskit-nature>=0.6.0, <0.7", + "qiskit-nature>=0.6.0", "qiskit-ibm-runtime>=0.12.2", ] diff --git a/test/forging/test_entanglement_forging_ground_state_solver.py b/test/forging/test_entanglement_forging_ground_state_solver.py index d6d036d19..ba77c0e10 100644 --- a/test/forging/test_entanglement_forging_ground_state_solver.py +++ b/test/forging/test_entanglement_forging_ground_state_solver.py @@ -29,6 +29,7 @@ from qiskit_nature.second_q.transformers import ActiveSpaceTransformer from qiskit_nature.second_q.formats import get_ao_to_mo_from_qcschema from qiskit_nature.second_q.hamiltonians import ElectronicEnergy +from qiskit_nature.second_q.operators import Tensor from circuit_knitting.forging import ( EntanglementForgingAnsatz, @@ -105,6 +106,10 @@ def test_entanglement_forging_vqe_hydrogen(self): problem = driver.to_problem(basis=ElectronicBasis.AO) qcschema = driver.to_qcschema() mo_coeff = get_ao_to_mo_from_qcschema(qcschema).coefficients.alpha["+-"] + if isinstance(mo_coeff, Tensor): + # Unwrap the Tensor in Qiskit Nature 0.7 and later + # to be compatible with qiskit-nature/pull/1248 + mo_coeff = mo_coeff.array # Specify the ansatz and bitstrings ansatz = EntanglementForgingAnsatz( diff --git a/test/forging/test_entanglement_forging_knitter.py b/test/forging/test_entanglement_forging_knitter.py index 8ad94bdbe..8d9035a17 100644 --- a/test/forging/test_entanglement_forging_knitter.py +++ b/test/forging/test_entanglement_forging_knitter.py @@ -23,6 +23,7 @@ from qiskit_nature.second_q.problems import ElectronicStructureProblem, ElectronicBasis from qiskit_nature.second_q.hamiltonians import ElectronicEnergy from qiskit_nature.second_q.formats import get_ao_to_mo_from_qcschema +from qiskit_nature.second_q.operators import Tensor from circuit_knitting.forging import ( EntanglementForgingAnsatz, @@ -99,6 +100,10 @@ def test_entanglement_forging_H2(self): # Specify the decomposition method and get the forged operator mo_coeff = get_ao_to_mo_from_qcschema(qcschema).coefficients.alpha["+-"] + if isinstance(mo_coeff, Tensor): + # Unwrap the Tensor in Qiskit Nature 0.7 and later + # to be compatible with qiskit-nature/pull/1248 + mo_coeff = mo_coeff.array hamiltonian_terms, energy_shift = cholesky_decomposition( problem, mo_coeff=mo_coeff ) @@ -175,6 +180,10 @@ def test_entanglement_forging_H2O(self): # pylint: disable=too-many-locals # Specify the decomposition method and get the forged operator mo_coeff = get_ao_to_mo_from_qcschema(qcschema).coefficients.alpha["+-"] + if isinstance(mo_coeff, Tensor): + # Unwrap the Tensor in Qiskit Nature 0.7 and later + # to be compatible with qiskit-nature/pull/1248 + mo_coeff = mo_coeff.array hamiltonian_terms, energy_shift = cholesky_decomposition( problem, mo_coeff=mo_coeff, orbitals_to_reduce=orbitals_to_reduce )