From 2b550232db40b66a81d04f9395a06ded5645a1a9 Mon Sep 17 00:00:00 2001 From: Caleb Johnson Date: Mon, 7 Oct 2024 15:22:51 -0500 Subject: [PATCH 1/2] Fix bugs in fermion module causing open-shell systems to have their spin-up/down determinants flipped before solving --- qiskit_addon_sqd/fermion.py | 2 -- releasenotes/notes/fermion-bug-2b2ed34f979b1321.yaml | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fermion-bug-2b2ed34f979b1321.yaml diff --git a/qiskit_addon_sqd/fermion.py b/qiskit_addon_sqd/fermion.py index 1c7f13b..f7731c5 100644 --- a/qiskit_addon_sqd/fermion.py +++ b/qiskit_addon_sqd/fermion.py @@ -96,7 +96,6 @@ def solve_fermion( else: # This will become the default code path after the deprecation period. ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix, open_shell=open_shell) - ci_strs = ci_strs[::-1] ci_strs = _check_ci_strs(ci_strs) num_up = format(ci_strs[0][0], "b").count("1") @@ -201,7 +200,6 @@ def optimize_orbitals( else: # Flip the output so the alpha CI strs are on the left with [::-1] ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix, open_shell=open_shell) - ci_strs = ci_strs[::-1] ci_strs = _check_ci_strs(ci_strs) num_up = format(ci_strs[0][0], "b").count("1") diff --git a/releasenotes/notes/fermion-bug-2b2ed34f979b1321.yaml b/releasenotes/notes/fermion-bug-2b2ed34f979b1321.yaml new file mode 100644 index 0000000..087972f --- /dev/null +++ b/releasenotes/notes/fermion-bug-2b2ed34f979b1321.yaml @@ -0,0 +1,3 @@ +fixes: + - | + Fixes a bug in :func:`qiskit_addon_sqd.fermion.solve_fermion` and :func:`qiskit_addon_sqd.fermion.optimize_orbitals` which causes the determinants for spin-up and spin-down to be incorrectly flipped before solving. From f18d5e9b2eef1d66f027d2f3d1a93d8b0c3548ef Mon Sep 17 00:00:00 2001 From: Caleb Johnson Date: Mon, 7 Oct 2024 15:28:29 -0500 Subject: [PATCH 2/2] Clean up comment --- qiskit_addon_sqd/fermion.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qiskit_addon_sqd/fermion.py b/qiskit_addon_sqd/fermion.py index f7731c5..afb4ce4 100644 --- a/qiskit_addon_sqd/fermion.py +++ b/qiskit_addon_sqd/fermion.py @@ -198,7 +198,6 @@ def optimize_orbitals( ) ci_strs = bitstring_matrix else: - # Flip the output so the alpha CI strs are on the left with [::-1] ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix, open_shell=open_shell) ci_strs = _check_ci_strs(ci_strs)