Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quilt Extensions #1257

Merged
merged 141 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
81dc23d
add quilt primitives
ecpeterson Jul 9, 2019
eaa4d69
parse either Qubit or FormalArgument from formalQubit
Jan 6, 2020
989900c
formatting improvements
Jan 8, 2020
ed99835
add get_qubits on Quilt instructions
Jan 9, 2020
07b9e9c
fix printing of complex iq values etc
Jan 13, 2020
db623be
add SHIFT-FREQUENCY
Jan 14, 2020
88249dc
change ShiftFrequency 'offset' to 'freq'
Jan 15, 2020
ee870d4
add parsing for AffineKernelFamilies
Jan 15, 2020
5be3878
change AffineKernelFamily.kernels -> AffineKernelFamily.waveforms
Jan 15, 2020
0489351
parenthesize and space filter waveforms
Jan 15, 2020
7ff92d4
add protoquilt validation
Jan 20, 2020
a90db9d
bugfix: add DELAY and FENCE to valid quilt ops
Jan 21, 2020
98eee84
fix typo
Jan 21, 2020
a8ae817
add missing instr types in Program.get_qubits
Jan 22, 2020
21dac5b
add FenceAll instruction
Jan 24, 2020
64104e2
allow a single slash in a waveform name
Jan 28, 2020
8bbf3d2
remove AffineKernelExpressions
Feb 3, 2020
caba9cb
add frame hardware object
Feb 4, 2020
1481c75
remove sample rate from waveform definitions
Mar 31, 2020
5e267c3
remove last vestiges of AffineKernelFamily
Mar 31, 2020
7bbf762
Update Quilt AST (#1209)
Apr 30, 2020
16a8699
add CENTER-FREQUENCY frame attribute
May 12, 2020
c0cf5e4
update parser
May 12, 2020
48c216e
fix typo
May 13, 2020
9c075b9
add defcal matching and expansion
Jun 1, 2020
ea3b9a6
escape hatch in calibration matching for non gate/measure instrs
Jun 3, 2020
9f99bc2
add get_calibration
Jun 3, 2020
42e246f
quilt hacks
Apr 30, 2020
4990560
add rewrite_arithmetic hooks for frame mutations
May 12, 2020
e5a2be5
update arithmetic rewriting to convert radians to revs
May 13, 2020
925959f
bugfix: convert radians to revs in parametric phase ops
May 14, 2020
f84bbdb
raw-capture fixup
May 15, 2020
6e49b90
fixup handling of ro sources
May 22, 2020
3ace540
allow for compilation of quil programs with calibrations
Jun 23, 2020
31f5940
update tests
Jun 23, 2020
471652e
add test for quil_to_native_quil compilation w/ calibrations
Jun 23, 2020
1e34e4d
ignore quilt calibrations in QVM calls
Jun 23, 2020
e914a8f
copy calibrations on Program + and +=
Jun 23, 2020
e77766d
elide quilt calibrations during benchmark calls
Jun 23, 2020
dd4bbb6
add quilt tutorials
Jul 13, 2020
649e53a
add quilt info to Program docs
Jul 13, 2020
b9c0894
update Quilt docs
Jul 14, 2020
7ee78b0
update formatting
Jul 14, 2020
3408e7a
style fixes
Jul 15, 2020
f07523a
add _collect_classical_memory... back to compiler.py
Jul 27, 2020
8f05a74
fix calibration update in benchmarker
Jul 27, 2020
44404b4
add DECLARE to gates.py
Jul 27, 2020
057799b
add scipy to requirements.txt
Jul 29, 2020
9eacce2
don't fail on sphinx warnings (temporary hack)
Aug 2, 2020
4a81a80
bugfix: don't typecheck against union
Aug 2, 2020
7ade0b4
add Quilt proposal
Aug 6, 2020
638400b
fix format
notmgsk Sep 21, 2020
352b537
Fix: Fall back to client-side memory references if ro_sources respons…
notmgsk Oct 7, 2020
ca9efa0
Correct type hint for DelayQubits and DelayFrames
notmgsk Oct 9, 2020
36df174
Hint RawCapture as float
notmgsk Oct 13, 2020
213d1f3
remove redundant requirement
Oct 14, 2020
2aa7073
treat sphinx warnings as errors
Oct 14, 2020
8907b4a
change formalQubit to qubitOrFormal in grammar
Oct 14, 2020
7e8a3a8
rename _qubitVariable to _formalQubit
Oct 14, 2020
9e93b93
update types
Oct 15, 2020
702aeb7
update formatting
Oct 15, 2020
da2f06e
calibrations are not valid protoquil
Oct 20, 2020
74650f1
Fix type hint in parser
notmgsk Oct 20, 2020
51a5ddc
Fix return type for DECLARE
notmgsk Oct 20, 2020
89aea3a
Don't type check DELAY
notmgsk Oct 20, 2020
6d30d6f
Don't reassign variable, avoiding type issue
notmgsk Oct 20, 2020
60daa2f
use iterable list() rather than tuple () in itertools.chain
notmgsk Oct 20, 2020
0b89bb5
Provide a return None for Program.match_calibrations
notmgsk Oct 20, 2020
4d5cd7f
Provide return None for Program.get_calibration
notmgsk Oct 20, 2020
ac51d9a
Cast a return in _what_type_of_qubit_does_it_use to quell mypy's prot…
notmgsk Oct 20, 2020
892dd89
Give FormalArgument a index() method/property
notmgsk Oct 20, 2020
69758fc
Allow FormalArgument as a frame target
notmgsk Oct 20, 2020
e4f5f9e
Type default function
notmgsk Oct 20, 2020
76b9ce1
Should FormalArgument be deemed a QubitDesignator?
notmgsk Oct 20, 2020
20367a1
Allow FormalArgument in _extract_qubit_index
notmgsk Oct 20, 2020
0e35947
Allow FormalArgument in Measurement
notmgsk Oct 20, 2020
2cd04ac
Allow FormalArgument in ResetQubit
notmgsk Oct 20, 2020
8a47740
any -> Any
notmgsk Oct 20, 2020
44e08f3
Allow redefinitions in mypy
notmgsk Oct 20, 2020
5cb0589
Fix import
notmgsk Oct 20, 2020
9212a23
Don't typecheck (yet) rewrite_arithmetic
notmgsk Oct 20, 2020
39159d8
Type hint a dict
notmgsk Oct 20, 2020
a6bfd02
Type hint a variable
notmgsk Oct 20, 2020
32d4507
Add hint for alloc
notmgsk Oct 20, 2020
db3ab7d
Add hint for variable
notmgsk Oct 20, 2020
d54adbc
Add hint for variable
notmgsk Oct 20, 2020
6aab84c
Remove unused type ignore
notmgsk Oct 20, 2020
0312b5c
Use getattr with default None
notmgsk Oct 20, 2020
a52c0ed
Fix type hint for _collect_classical_memory_write_locations
notmgsk Oct 20, 2020
0183ed4
Remove unnecessary hint
notmgsk Oct 20, 2020
d8305b6
Check for available qpu compiler in get_quilt_calibrations
notmgsk Oct 20, 2020
1882963
import
notmgsk Oct 20, 2020
06e4098
Avoid type checking for quiltcalibrations.py
notmgsk Oct 21, 2020
577af22
Imports for types
notmgsk Oct 21, 2020
ea48cea
Type hint _waveform_classes
notmgsk Oct 21, 2020
2beff11
Don't type check waveform() because it's icky
notmgsk Oct 21, 2020
e6c2e31
Type hint waveform()
notmgsk Oct 21, 2020
ea62195
Don't type check _wf_from_dict
notmgsk Oct 21, 2020
ae3e2bd
use getattr for dataclass fields, provide default
notmgsk Oct 21, 2020
42fb902
use getattr for dataclass fields, provide default
notmgsk Oct 21, 2020
24cd0d8
Move TemplateWaveform._update_envelope out to a helper function
notmgsk Oct 21, 2020
aac2bf3
Fix comment
notmgsk Oct 21, 2020
c904db1
Raise sensible error in measure_all when program includes FormalArgument
notmgsk Oct 21, 2020
84d995a
update antlr requirement
Oct 22, 2020
717871a
Add get_quilt_calibrations to QVMCompile
notmgsk Oct 26, 2020
7202fc5
Use translation service as the default qpu compiler endpoint
notmgsk Oct 22, 2020
3b3c12a
Prevent UserMessageError from showing error message if exception is c…
notmgsk Oct 23, 2020
eb3fcbc
Force kwargs in Program.out()
notmgsk Oct 26, 2020
cc80442
Include waveforms and frames when appending programs
notmgsk Oct 26, 2020
dacec41
Test quilt features preserved during program append
notmgsk Oct 26, 2020
a11faaf
Format, style, types
notmgsk Oct 26, 2020
3f576a6
Remove unnecessary test
notmgsk Oct 26, 2020
48bc233
Access property to trigger error
notmgsk Oct 26, 2020
6dcae04
format
notmgsk Oct 26, 2020
4f2529d
style
notmgsk Oct 26, 2020
3006abd
Unpack qubit index when matching calibrations
notmgsk Oct 29, 2020
4b6776c
Add info to some error strings
notmgsk Nov 1, 2020
d4a6ccc
Fix typo
notmgsk Nov 1, 2020
4ae7186
Revert "Unpack qubit index when matching calibrations"
notmgsk Nov 2, 2020
f2b72f6
format
notmgsk Nov 2, 2020
20eef82
missing import
notmgsk Nov 10, 2020
3551f96
Quilt demo quil submodule (#1269)
notmgsk Nov 12, 2020
7bb7e27
don't capture pytest output
notmgsk Nov 12, 2020
b8dc5aa
remove debug
notmgsk Nov 20, 2020
898d840
refactor validate_protoquil_or_quilt into validate_protoquil
notmgsk Nov 20, 2020
ee210c9
Recursively expand defcals (#1270)
notmgsk Nov 19, 2020
a3943a6
Expand calibrations on client side (#1271)
notmgsk Nov 19, 2020
94a8f12
Update quil submodule commit
notmgsk Nov 20, 2020
c18e77e
Remove quilt proposal (see the quil repo for the canonical version)
notmgsk Nov 20, 2020
0b1829d
Add quilt.rst and some information on where to find quilt spec
notmgsk Nov 20, 2020
0e86047
Fix: bug in calibration expansion loop prevention
kalzoo Nov 21, 2020
2a71124
Allow cyclic calibration to hit max recursion depth
notmgsk Nov 24, 2020
48b2874
Program.calibrate catches most cyclic calibration errors
notmgsk Nov 25, 2020
4d502e1
remove TODO
notmgsk Nov 25, 2020
e8f941d
CalibrationRecursionError -> CalibrationError
notmgsk Nov 25, 2020
e183d15
Pin bugbear==20.1.4
notmgsk Nov 30, 2020
eb57c4d
allow test_coverage to fail
notmgsk Nov 30, 2020
b4b8499
Port parser to Lark (#1278)
notmgsk Dec 1, 2020
ca68699
update changelog
notmgsk Dec 7, 2020
05a2406
chglg
notmgsk Dec 9, 2020
5b1d4e0
Remove client-side calibration
notmgsk Dec 9, 2020
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
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test-coverage:
extends: .python
script:
- make coverage
allow_failure: true

####################################################################################################
# MASTER-ONLY JOBS
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "quillang"]
path = docs/quil
url = https://github.com/rigetti/quil.git
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changelog
### Improvements and Changes

- Unpacking bitstrings is significantly faster (@mhodson-rigetti, @notmgsk, #1276).
- Parsing is now performed using Lark rather than ANTLR (@notmgsk, #1278).

### Bugfixes

Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ verify that everything looks right!

### Working with the Parser

Working with the ANTLR parser involves some extra steps, so make sure to read the
[Parser README](pyquil/_parser/README.md) if you plan on making changes to it. Note
that you only need to install ANTLR if you want to change the grammar; simply running
the parser involves no additional steps beyond installing pyQuil as usual.
The parser is implemented with Lark. See the [parser README](pyquil/_parser/README.md).

### Using the Docker Image

Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ check-format:

.PHONY: check-types
check-types:
mypy .
mypy pyquil

.PHONY: check-style
check-style:
flake8
flake8 pyquil

.PHONY: clean
clean:
Expand Down Expand Up @@ -80,3 +80,11 @@ upload:
.PHONY: version
version:
@git describe --tags | sed 's/v//' | sed 's/\(.*\)-.*/\1/'| sed 's/-/./'

docs/quil/grammars/Quil.g4:
git submodule init
git submodule update

.PHONY: generate-parser
generate-parser: docs/quil/grammars/Quil.g4
cd docs/quil/grammars && antlr -Dlanguage=Python3 -o ../../../pyquil/_parser/gen3 Quil.g4
1 change: 1 addition & 0 deletions docs/quil
Submodule quil added at 7f3b2f
47 changes: 45 additions & 2 deletions docs/source/apidocs/gates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,37 @@ in the computational (Z) basis.
MEASURE


Quilt instructions
------------------

Quilt extends the above "native" operations with several more.

.. autosummary::
:toctree: autogen
:template: autosumm.rst

PULSE
SET_FREQUENCY
SHIFT_FREQUENCY
SET_PHASE
SHIFT_PHASE
SWAP_PHASE
SET_SCALE
CAPTURE
RAW_CAPTURE
DELAY
FENCE



All gates and instructions
--------------------------

In general, you will write a quantum program using the full suite of Quil gates and instructions
and use :ref:`the Quil compiler <compiler>` to compile programs into the target instruction
set (ISA). The full list of quantum gates and classical Quil instructions is enumerated here.
set (ISA).

Furthermore, Quilt instructions may be executed natively, although are not fully supported by the Quil compiler or QVM.

.. rubric:: Single-qubit gates
.. autosummary::
Expand Down Expand Up @@ -77,7 +102,24 @@ set (ISA). The full list of quantum gates and classical Quil instructions is enu
PSWAP


.. rubric:: Classical instructions
.. rubric:: Quilt instructions
.. autosummary::
:toctree: autogen
:template: autosumm.rst

PULSE
SET_FREQUENCY
SHIFT_FREQUENCY
SET_PHASE
SHIFT_PHASE
SWAP_PHASE
SET_SCALE
CAPTURE
RAW_CAPTURE
DELAY
FENCE

.. rubric:: Other classical instructions
.. autosummary::
:toctree: autogen
:template: autosumm.rst
Expand Down Expand Up @@ -112,5 +154,6 @@ set (ISA). The full list of quantum gates and classical Quil instructions is enu
.. autosummary::

QUANTUM_GATES
QUILT_INSTRUCTIONS
STANDARD_INSTRUCTIONS

12 changes: 12 additions & 0 deletions docs/source/apidocs/program.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Program

~Program.instructions
~Program.defined_gates
~Program.calibrations
~Program.waveforms
~Program.frames
~Program.out
~Program.get_qubits
~Program.is_protoquil
Expand Down Expand Up @@ -47,6 +50,15 @@ Program
~Program.while_do
~Program.if_then

.. rubric:: Quilt Routines
.. autosummary::
:toctree: autogen
:template: autosumm.rst

~Program.get_calibration
~Program.match_calibrations
~Program.calibrate

.. rubric:: Utility Methods
.. autosummary::
:toctree: autogen
Expand Down
25 changes: 25 additions & 0 deletions docs/source/apidocs/waveforms.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Quilt Waveforms
===============

.. currentmodule:: pyquil.quiltwaveforms

All Quilt waveforms have corresponding PyQuil syntax objects. For example, a waveform written in Quilt syntax as ``flat(iq: 1.0, duration: 1e-5)`` corresponds to a :py:class:`~pyquil.quiltwaveforms.FlatWaveform` object.

.. autosummary::
:toctree: autogen
:template: autosumm.rst


FlatWaveform
GaussianWaveform
DragGaussianWaveform
HrmGaussianWaveform
ErfSquareWaveform
BoxcarAveragerKernel



Custom Waveforms
----------------

Custom waveform definitions, introduced in Quilt with ``DEFWAVEFORM``, have a corresponding :py:class:`~pyquil.quilbase.DefWaveform` object. These are referenced in PyQuil with :py:class:`~pyquil.quilatom.WaveformReference`.
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
"nbsphinx",
"recommonmark"
]

autosummary_generate = True
Expand All @@ -59,7 +60,7 @@
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
source_suffix = [".rst", ".md"]

# The encoding of source files.
#
Expand Down
11 changes: 11 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,23 @@ Contents
changes
intro

.. toctree::
:maxdepth: 3
:caption: Quil-T

quilt
quilt_getting_started
quilt_waveforms
quilt_parametric
quilt_raw_capture

.. toctree::
:maxdepth: 1
:caption: API Reference

apidocs/program
apidocs/gates
apidocs/waveforms
apidocs/pauli
apidocs/quantum_computer
apidocs/compilers
Expand Down
34 changes: 34 additions & 0 deletions docs/source/quilt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.. _quilt:

Quil-T
======

Quil-T is an extension to Quil which introduces pulse-level control to
quantum programs. With Quil-T one can describe a program at a level
lower than is typically permitted in circuit-type programs, with
explicit control over the RF waveforms played by the QPU's control
hardware. In particular this imbues programs with a notion of *time*,
hence the `T` suffix.

The Quil compiler `quilc` was developed to support most users in their
pursuit for producing an optimal program from a high-level
language. In contrast Quil-T was developed to enable the low-level and
precise control desired by power-users. For example, for many users
the implementation details of a Hadamard gate are not particularly
important, and indeed the behind-the-scenes realisation of a Hadamard
gate are likely to change over time as gate implementations are
recalibrated to provide the best results. If you instead you are
interested in those details, and in particular you want to control
those details, then pulse-level control with Quil-T is the way to
go. With Quil-T you can define precisely what you mean by `H 0`, you
can perform experiments to characterize the underlying hardware such
as determining `T1`. The hardware is almost at your fingertips.

.. note::

Quil-T is not yet finalized and subject to change. The following
link should be updated upon the release of Quil-T.

For examples, see the adjacent notebooks. For more information, see
the Quil-T proposal at the `Quil project homepage
<https://github.com/rigetti/quil/tree/bugfix/quilt-rfc-improvements/rfcs/analog>`_.
Loading