Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ca3b8d5
First version of exporting to open qasm
clausia Nov 23, 2020
9c31e79
Optional third party libraries
clausia Nov 23, 2020
06f30b3
Update README.md
kottmanj Dec 3, 2020
43c4ed2
Update README.md
kottmanj Dec 4, 2020
a795cf0
fixed qubit mapping for FermionicGateImpl
kottmanj Dec 5, 2020
e9fbd90
Merge pull request #101 from aspuru-guzik-group/pr-qubit-maps
kottmanj Dec 5, 2020
2f6e8b4
added charges and test^Co PNO-MP2 surrogate
kottmanj Dec 8, 2020
c0105eb
removed unintended content from gates.py
kottmanj Dec 8, 2020
45da429
Merge pull request #103 from aspuru-guzik-group/pr-update
kottmanj Dec 8, 2020
fea8e89
refactor Compiler
georgios-ts Dec 12, 2020
470cb1e
removed tutorials from main repo
kottmanj Dec 18, 2020
c958885
updated readme
kottmanj Dec 18, 2020
a8d0812
actually raise exceptions ...
kottmanj Dec 18, 2020
f4d3bc6
qibo/gpyopt clash
kottmanj Dec 18, 2020
f435c1c
Merge pull request #104 from aspuru-guzik-group/pr-tutorials
kottmanj Dec 18, 2020
0fcae5f
sync devel with master
kottmanj Dec 18, 2020
77d5a6c
Merge pull request #105 from aspuru-guzik-group/pr-sync-devel
kottmanj Dec 18, 2020
9d76059
Update requirements.txt
kottmanj Jan 4, 2021
145e796
Import/export OpenQASM code and import/export to pyzx package for ZX-…
clausia Jan 2, 2021
733a26b
Merge branch 'devel' into add-pyzx-and-qasm
clausia Jan 4, 2021
ac6714f
Update README.md
kottmanj Jan 4, 2021
05215e1
Merge branch 'devel' into master
kottmanj Jan 4, 2021
2cee1a4
Merge pull request #107 from aspuru-guzik-group/master
kottmanj Jan 4, 2021
85cd14d
improve comment
clausia Jan 6, 2021
058e6f6
Better equivalences for CH and Y that includes the power parameter
clausia Jan 8, 2021
45296ce
fix comments in compiler.py
clausia Jan 8, 2021
15d0841
dd matrix representation of U gate
clausia Jan 8, 2021
290ced0
More tests for gates u1,u2,u3,U
clausia Jan 8, 2021
7009185
Improve qubits property in QGateImpl
clausia Jan 11, 2021
23b8ab7
correct gates equivalent to CH
clausia Jan 12, 2021
28f069b
Tests for import/export OpenQASM code
clausia Jan 13, 2021
2392734
Pr keymap fix (#109) (#110)
kottmanj Jan 13, 2021
66626fd
Correct order for U gate equivalent circuit and improvement in tests …
clausia Jan 14, 2021
d178f26
Error (and fix) because changes in _gates_impl.py regarding _qubits a…
clausia Jan 14, 2021
0c55263
Tests for import/export OpenQASM code
clausia Jan 14, 2021
4d14b97
Remove temporal comment
clausia Jan 14, 2021
99d10b4
Avoid some warnings
clausia Jan 14, 2021
9aa17b3
Tests for convert from/to pyzx
clausia Jan 15, 2021
599777c
Test if a circuit reduced within pyzx remains the same when returned …
clausia Jan 15, 2021
ff68b80
Skip pyzx tests if pyzx package is not installed
clausia Jan 15, 2021
7b41f99
Improve tests for new compile functions (ry, y, ch)
clausia Jan 15, 2021
344c22c
Merge branch 'devel' into add-pyzx-and-qasm
clausia Jan 15, 2021
e04ef2a
Pr map warnings (#111)
kottmanj Jan 15, 2021
a8f4769
Variables are not needed when importing OpqnQASM code
clausia Jan 15, 2021
209ddf1
Merge branch 'devel' into add-pyzx-and-qasm
clausia Jan 20, 2021
eb89bac
minor fixes
georgios-ts Jan 20, 2021
ecaab9c
Merge remote-tracking branch 'upstream/devel' into compiler
georgios-ts Jan 20, 2021
dba16d8
fix syntax error
georgios-ts Jan 20, 2021
6022cbc
Merge branch 'merge-with-georgios' into compiler
clausia Jan 21, 2021
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
39 changes: 39 additions & 0 deletions .github/workflows/ci_optimizers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Tequila-Test-Optimizers

on:
push:
branches: [ master, devel ]
pull_request:
branches: [ master, devel ]

jobs:

build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install quantum backends
run: |
pip install --upgrade cirq qiskit qulacs

- name: Install and test GPyOpt interface (no qibo)
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements.txt
pip install --upgrade -r requirements_gpyopt.txt
pip install -e .

pytest tests/test_gpyopt.py --slow

28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Tequila is an Extensible Quantum Information and Learning Architecture where the
It operates on abstract data structures allowing the formulation, combination, automatic differentiation and optimization of generalized objectives.
Tequila can execute the underlying quantum expectation values on state of the art simulators as well as on real quantum devices.

[You can get an overview from this presentation](/docs/tequila.pdf)
[You can get an overview from this presentation](/docs/tequila.pdf) or from it's [video recording](https://www.youtube.com/watch?v=hUdf0P2fW2E)

[Get started with our Tutorials](/tutorials/)
[Get started with our Tutorials](https://github.com/aspuru-guzik-group/tequila-tutorials)

or checkout our [overview article](https://arxiv.org/abs/2011.03057)

Expand All @@ -22,12 +22,23 @@ Currently supported

Tequila detects backends automatically if they are installed on your systems.
All of them are available over standard pip installation like for example `pip install qulacs`.
For best performance tt is recommended to have `qulacs` installed.
For best performance it is recommended to have `qulacs` installed.

# QuantumChemistry:
Tequila supports [Psi4](https://github.com/psi4/psi4).
Currently supported
- [Psi4](https://github.com/psi4/psi4).
In a conda environment this can be installed with
`conda install psi4 -c psi4`
```bash
conda install psi4 -c psi4
```
Here is a small [tutorial](https://github.com/aspuru-guzik-group/tequila-tutorials/blob/main/Chemistry.ipynb) that illustrates the usage.

- [Madness](https://github.com/kottmanj/madness)
Currently you need to compile from a separate [fork](https://github.com/kottmanj/madness).
See the github page of this fork for installation instruction.
Note that the madness interface is currently only available on the `devel` branch of tequila (coming to master soon).
Here is a small [tutorial](https://github.com/aspuru-guzik-group/tequila-tutorials/blob/main/ChemistryMadnessInterface.ipynb) that illustrates the usage.


# Installation
We recommend installing in editable mode with
Expand Down Expand Up @@ -124,6 +135,10 @@ Quantum Computer-Aided design of Quantum Optics Hardware.
[arxiv.org/abs/2006.03075](https://arxiv.org/abs/2006.03075)
[example code](https://github.com/kottmanj/Photonic)

A. Anand, M. Degroote, A. Aspuru-Guzik.
Natural Evolutionary Strategies for Variational Quantum Computation.
[arxiv.org/abs/2012.00101](https://arxiv.org/abs/2012.00101)

Let us know, if you want your research project to be included in this list!

# Dependencies
Expand Down Expand Up @@ -185,4 +200,5 @@ They can be installed for example over visual studio.
Tequila runs on Macs OSX.
You might get in trouble with installing qulacs since it currently does not work with Apple's clang compiler.
You need to install latest GNU compile (at least gcc-7 and g++7) and set them as default before installing qulacs over pip.

## Qibo and GPyOpt
Currently you can't use Qibo and GPyOpt within the same environment
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jaxlib
#autograd # use if jaxlib gives you trouble, make sure jax is uninstalled then
setuptools
pytest
openfermion
openfermion <= 0.11*
cmake # needed by qulacs, can be removed otherwise
qulacs # default simulator, remove if the installation gives you trouble

Expand All @@ -16,3 +16,6 @@ qulacs # default simulator, remove if the installation gives you trouble
#pyquil # you need to install the forest-sdk
#qulacs-gpu
#qibo <= 0.1.1

#optional third party libraries
#pyzx
2 changes: 2 additions & 0 deletions src/tequila/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
INSTALLED_SAMPLERS, \
INSTALLED_SIMULATORS, SUPPORTED_BACKENDS, INSTALLED_BACKENDS, show_available_simulators
from tequila.wavefunction import QubitWaveFunction
from tequila.circuit.qasm import export_open_qasm, import_open_qasm, import_open_qasm_from_file
from tequila.circuit.pyzx import convert_to_pyzx, convert_from_pyzx
import tequila.quantumchemistry as chemistry # shortcut
from tequila.quantumchemistry import Molecule, MoleculeFromOpenFermion

Expand Down
67 changes: 45 additions & 22 deletions src/tequila/circuit/_gates_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tequila.objective.objective import Variable, FixedVariable, assign_variable,Objective,VectorObjective
from tequila.hamiltonian import PauliString, QubitHamiltonian, paulis
from tequila.tools import list_assignment
from numpy import pi

from dataclasses import dataclass

Expand All @@ -30,11 +31,16 @@ def control(self):

@property
def qubits(self):
return self._qubits
# Set the active qubits
if self.control:
qubits = self.target + self.control
else:
qubits = self.target
return sorted(tuple(set(qubits)))

@property
def max_qubit(self):
return self._max_qubit
return self.compute_max_qubit()

def extract_variables(self):
return []
Expand All @@ -53,13 +59,6 @@ def __init__(self, name, target: UnionList, control: UnionList = None, generator
self._target = tuple(list_assignment(target))
self._control = tuple(list_assignment(control))
self.finalize()
# Set the active qubits
if self.control:
self._qubits = self.target + self.control
else:
self._qubits = self.target
self._qubits = sorted(tuple(set(self._qubits)))
self._max_qubit = self.compute_max_qubit()
self.generator = generator

def copy(self):
Expand Down Expand Up @@ -96,6 +95,16 @@ def finalize(self):
for c in self.target:
if c in self.control:
raise Exception("control and target are the same qubit: " + self.__str__())
if hasattr(self,"generator") and self.generator:
if set(list(self.generator.qubits)) != set(list(self.target)):
raise Exception("qubits of generator and targets don't agree -- mapping error?\n gate = {}".format(self.__str__()))
if hasattr(self, "generators"):
genq = []
for generator in self.generators:
genq += generator.qubits
if set(list(genq)) != set(list(self.target)):
raise Exception("qubits of generator and targets don't agree -- mapping error?\n gate = {}".format(self.__str__()))


def __str__(self):
result = str(self.name) + "(target=" + str(self.target)
Expand Down Expand Up @@ -131,14 +140,12 @@ def __eq__(self, other):
def map_qubits(self, qubit_map: dict):
mapped = copy.deepcopy(self)
mapped._target = tuple([qubit_map[i] for i in self.target])
qubits = mapped._target
if self.control is not None:
mapped._control = tuple([qubit_map[i] for i in self.control])
qubits += mapped._control
mapped._qubits = sorted(tuple(set(qubits)))
mapped._max_qubit = mapped.compute_max_qubit()
if self.generator:
mapped.generator = self.generator.map_qubits(qubit_map)
if hasattr(self, "generator") and self.generator:
mapped.generator = self.generator.map_qubits(qubit_map=qubit_map)
if hasattr(self, "generators"):
mapped.generators = [i.map_qubits(qubit_map=qubit_map) for i in self.generators]
mapped.finalize()
return mapped

Expand Down Expand Up @@ -275,14 +282,35 @@ def __pow__(self, power, modulo=None):


class PowerGateImpl(ParametrizedGateImpl):
"""
Attributes
---------
power
numeric type (fixed exponent) or hashable type (parametrized exponent)
parameter
power multiplied by pi
to be consitent with exp(-i a/2 G) representation [a: gate.parameter, G: gate.generator]
"""

def __init__(self, name, target: list, power=None, control: list = None, generator: QubitHamiltonian = None):
super().__init__(name=name, parameter=power, target=target, control=control, generator=generator)
@property
def power(self):
return self._power

@power.setter
def power(self, other):
self._power = assign_variable(variable=other)

def __init__(self, name, target: list, power, control: list = None, generator: QubitHamiltonian = None):
super().__init__(name=name, parameter=power * pi, target=target, control=control, generator=generator)
self._power = assign_variable(variable=power)

def dagger(self):
result = copy.deepcopy(self)
result._parameter = assign_variable(-self.parameter)
result._power = assign_variable(-self.power)
return result


class GeneralizedRotationImpl(DifferentiableGateImpl):
"""
A gate which behaves like a generalized rotation
Expand Down Expand Up @@ -428,8 +456,3 @@ def dagger(self):
angles.append(-angle)
result.angles = angles
return result

def map_qubits(self, qubit_map: dict):
mapped = super().map_qubits(qubit_map=qubit_map)
mapped.generators = [generator.map_qubits(qubit_map=qubit_map) for generator in mapped.generators]
return mapped
Loading