Skip to content

Commit 136561e

Browse files
authored
Some BugFixes (#311)
* UpCCGSD mix_sd fixed
1 parent 51391a3 commit 136561e

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.github/workflows/ci_pyquil.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ jobs:
2929
python -m pip install --upgrade pip
3030
pip install --upgrade pytest
3131
pip install -r requirements.txt
32-
pip install "pyquil<3.0"
32+
pip install "pyquil<3.0" # needs updates
3333
pip install -e .
34+
pip install --upgrade pip 'urllib3<2' # issues with old pyquil version otherwise
3435
docker pull rigetti/qvm:edge
3536
docker pull rigetti/quilc
3637
docker run --rm -itd -p 5555:5555 rigetti/quilc -R

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Tequila can execute the underlying quantum expectation values on state of the ar
1515

1616
# Installation
1717
Recommended Python version is 3.8-3.9.
18-
Tequila supports linux, osx and windows. However, not all optional dependencies are supported on windows.
18+
Tequila supports linux, osx and windows. However, not all optional dependencies are supported on windows.
1919

2020
## Install from PyPi
2121
**Do not** install like this: (Minecraft lovers excluded)

src/tequila/quantumchemistry/qc_base.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,8 @@ def make_upccgsd_ansatz(self,
11021102
assume_real: bool = True,
11031103
hcb_optimization: bool = None,
11041104
spin_adapt_singles: bool = True,
1105-
neglect_z=False,
1105+
neglect_z: bool = False,
1106+
mix_sd: bool = False,
11061107
*args, **kwargs):
11071108
"""
11081109
UpGCCSD Ansatz similar as described by Lee et. al.
@@ -1127,6 +1128,10 @@ def make_upccgsd_ansatz(self,
11271128
assume_real
11281129
assume a real wavefunction (that is always the case if the reference state is real)
11291130
reduces potential gradient costs from 4 to 2
1131+
mix_sd
1132+
Changes the ordering from first all doubles and then all singles excitations (DDDDD....SSSS....) to
1133+
a mixed order (DS-DS-DS-DS-...) where one DS pair acts on the same MOs. Useful to consider when systems
1134+
with high electronic correlation and system high error associated with the no Trotterized UCC.
11301135
Returns
11311136
-------
11321137
UpGCCSD ansatz
@@ -1167,7 +1172,8 @@ def make_upccgsd_ansatz(self,
11671172
raise Exception(
11681173
"name={}, Singles can't be realized without mapping back to the standard encoding leave S or HCB out of the name".format(
11691174
name))
1170-
1175+
if hcb_optimization and mix_sd:
1176+
raise TequilaException("Mixed SD can not be employed together with HCB Optimization")
11711177
# convenience
11721178
S = "S" in name.upper()
11731179
D = "D" in name.upper()
@@ -1178,7 +1184,8 @@ def make_upccgsd_ansatz(self,
11781184
if include_reference:
11791185
U = self.prepare_reference()
11801186
U += self.make_upccgsd_layer(include_singles=S, include_doubles=D, indices=indices, assume_real=assume_real,
1181-
label=(label, 0), spin_adapt_singles=spin_adapt_singles, *args, **kwargs)
1187+
label=(label, 0), mix_sd=mix_sd, spin_adapt_singles=spin_adapt_singles, *args,
1188+
**kwargs)
11821189
else:
11831190
U = QCircuit()
11841191
if include_reference:
@@ -1197,12 +1204,14 @@ def make_upccgsd_ansatz(self,
11971204

11981205
for k in range(1, order):
11991206
U += self.make_upccgsd_layer(include_singles=S, include_doubles=D, indices=indices, label=(label, k),
1200-
spin_adapt_singles=spin_adapt_singles, neglect_z=neglect_z)
1207+
spin_adapt_singles=spin_adapt_singles, neglect_z=neglect_z, mix_sd=mix_sd)
12011208

12021209
return U
12031210

1204-
def make_upccgsd_layer(self, indices, include_singles=True, include_doubles=True, assume_real=True, label=None,
1205-
spin_adapt_singles: bool = True, angle_transform=None, mix_sd=False, neglect_z=False, *args,
1211+
def make_upccgsd_layer(self, indices, include_singles: bool = True, include_doubles: bool = True,
1212+
assume_real: bool = True, label=None,
1213+
spin_adapt_singles: bool = True, angle_transform=None, mix_sd: bool = False,
1214+
neglect_z: bool = False, *args,
12061215
**kwargs):
12071216
U = QCircuit()
12081217
for idx in indices:
@@ -1220,7 +1229,7 @@ def make_upccgsd_layer(self, indices, include_singles=True, include_doubles=True
12201229
indices=((2 * idx[0], 2 * idx[1]), (2 * idx[0] + 1, 2 * idx[1] + 1)),
12211230
assume_real=assume_real, **kwargs)
12221231
if include_singles and mix_sd:
1223-
U += self.make_upccgsd_singles(indices=[idx], assume_real=assume_real, label=label,
1232+
U += self.make_upccgsd_singles(indices=[(idx,)], assume_real=assume_real, label=label,
12241233
spin_adapt_singles=spin_adapt_singles, angle_transform=angle_transform,
12251234
neglect_z=neglect_z)
12261235

0 commit comments

Comments
 (0)