Homepage

The Qwerty Quantum Programming Language #

Qwerty is a new basis-oriented quantum programming language. Instead of writing quantum gates, Qwerty programs are expressed with higher-level primitives (namely the basis translation) or with classical logic.

Compare one iteration of Grover’s algorithm in Qwerty versus Q#:

  • Qwerty
    @classical
    def oracle(x: bit[4]) -> bit:
        return x[0] & ~x[1] & x[2] & ~x[3]
    
    @qpu[[N]]
    def grover_iter(q):
        return (q | oracle.sign
                  | 'p'**N >> -'p'**N)
  • Q# (based on an official Q# example)
    operation GroverIter(q: Qubit[]) : Unit {
        use ancilla = Qubit();
        within {
            X(ancilla);
            H(ancilla);
            X(q[1]);
            X(q[3]);
        } apply {
            Controlled X(q, ancilla);
        }
    
        within {
            for qi in q {
                H(qi);
                X(qi);
            }
        } apply {
            Controlled Z(Most(q), Tail(q));
        }
    }

In the Qwerty code above, (1) the oracle is defined using classical logic; (2) the compiler synthesizes the phase kickback trick automatically from oracle.sign; and (3) the diffusion step is achieved with the basis translation 'p'**N >> -'p'**N instead of handwritten circuitry.

Qwerty is embedded in Python, so invoking a Qwerty program is as easy as python grover.py.

For more information, see: