A quantum language which specifies what operators do and not what states are. Yaw reduces code complexity, is interoperable between architectures, and makes error correction first class.
Rise above qubits.
*> def grover(d, marked): ... $alg = qudit(d) ... def reflect(P): return I - 2*P ... G = reflect(proj(Z, marked)) * (-reflect(proj(X, 0))) ... r = int((pi/4)*sqrt(d)) + 1 ... return measure(Z, (G**r) « char(X, 0))()[1]
Grover search, entire, on a qudit sized to the problem rather than to the machine. The same six lines run at d = 2 and d = 500.
git clone https://github.com/torsor-io/yaw.git cd yaw pip install -r requirements.txt
Python 3.10 or later.
python3 yaw/yaw_repl.py
Native yaw syntax, as used throughout the book.
python3 yaw/y2py.py program.yaw -o program.py python3 program.py
Transpiles to Python for scripting and batch runs.
from yaw import *
Pythonic syntax replacing the native operators, for use inside an existing codebase or a notebook.
This site hosts Structure and Interpretation of Quantum Programs II: The Way of Yaw, which develops the language from scratch and uses it to build the canonical quantum algorithms. It is being written in the open; chapters go up as they are finished.
Part I: Foundations gives a deeper, self-contained account of the operator algebraic background, but it is not required reading — chapters 1–3 here build everything the language needs. A first course in quantum computing is assumed; no functional analysis is.
from one to three
ten thousand things
appendices
The algebra is the intermediate representation, not the surface syntax. A program is an element of a presented algebra, so changing hardware means changing the presentation rather than rewriting the program — and an error correcting code is a map between presentations, the same construction that moves a program between architectures.
The examples are the argument rather than a benchmark. Grover, teleportation and period finding each fit in under ten lines, in full qudit generality, with no gate decomposition and no basis fixed by hand. The chapters are there to be compared against whatever you would otherwise write.
Yes, though you address them through their Pauli algebra rather than as
qubits. qudit(2) hands you X and Z with the usual relations, and
anything expressible in the circuit model is expressible here. The gain is that
dimension stays a parameter, so the same program runs at d = 2 and d = 5.
No. Chapters 1–3 build the algebraic machinery the language needs from a standard first course in quantum computing, and assume no functional analysis. Part I gives a deeper account for anyone who wants one, but it isn't a prerequisite.
No, but it is declarative. You write down the algebra and how its pieces compose rather than a sequence of operations on a machine, and the algorithm is what that description denotes. Evaluation is inherited from Python.
Not yet. yaw currently evaluates symbolically and simulates, which is enough for the algorithms in the book. Compilation to physical backends is active research, and the qudit-to-qubit case is first in line.
Soon. Bosonic modes carry a clean algebraic description in the Weyl relations, which generalise the finite qudit algebras in exactly the generators-and-relations form yaw already uses. Getting cleanly from one to the other is the research currently in progress.
Going up as they are written, in the exercises appendix and in the tutorial
notebooks under /tutorials. Solutions marked as load-bearing for
the text are there already.