*> yaw

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.

Install

Install the repo

git clone https://github.com/torsor-io/yaw.git
cd yaw
pip install -r requirements.txt

Python 3.10 or later.

Run the REPL

python3 yaw/yaw_repl.py

Native yaw syntax, as used throughout the book.

Compile a .yaw file

python3 yaw/y2py.py program.yaw -o program.py
python3 program.py

Transpiles to Python for scripting and batch runs.

Import as a package

from yaw import *

Pythonic syntax replacing the native operators, for use inside an existing codebase or a notebook.

The book

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

  1. 1Algebraslive
  2. 2Operators and stateslive
  3. 3Laws of compositionlive

ten thousand things

  1. 4Sendlive
  2. 5Searchlive
  3. 6Samplelive
  4. 7Simulatedrafting
  5. 8Salvagedrafting
  6. 9Subgroupsplanned
  7. 10Shadowsplanned
  8. 11Sparsityplanned
  9. 12Signalsplanned

appendices

  1. AExerciseslive
  2. BCircuit diagramsdrafting
  3. CRepresentation efficiencydrafting
  4. DCompiling Pauli algebrasdrafting

Questions

Isn't this a library with nicer syntax?

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.

Does it really reduce code complexity?

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.

Can I work with qubits?

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.

Do I need to know operator algebras?

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.

Is the language functional?

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.

Does it run on hardware?

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.

Can I work with photonic quantum computers?

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.

Where are the exercise solutions?

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.

Citing

D. Wakeham, Structure and Interpretation of Quantum Programs II:
The Way of Yaw
. Torsor Labs, 2026. https://yawlang.dev

D. Wakeham, Structure and Interpretation of Quantum Programs I:
Foundations
. arXiv:2509.04527.