mimiqcircuits.operations.magic

Magic-state preparation.

Classes

PrepareMagic

alias of PrepareStateT

PrepareStateT()

Prepare one qubit in the magic state.

class PrepareStateT[source]

Bases: krauschannel

Prepare one qubit in the magic state.

Prepares the magic state \(T\ket{+} = (\ket{0} + e^{i\pi/4}\ket{1})/\sqrt{2}\), whatever the previous state of the qubit.

A magic state is the resource consumed by a \(\pi/8\) Pauli rotation when the rotation is carried out with Pauli product measurements (see pauli_based_computation()). Fault-tolerant architectures produce these states separately, by distillation, so a dedicated operation lets them be counted and scheduled.

The operation is a Kraus channel with operators \(T\ket{+}\bra{0}\) and \(T\ket{+}\bra{1}\), and is equivalent to Reset, GateH, GateT. It cannot be inverted, raised to a power or controlled: inverse, power and control raise TypeError.

PrepareMagic is a deprecated alias of this class.

Examples

>>> from mimiqcircuits import *
>>> PrepareStateT()
PrepareStateT
>>> c = Circuit()
>>> c.push(PrepareStateT(), 0)
1-qubit circuit with 1 instruction:
└── PrepareStateT @ q[0]

The decomposition resets the qubit to \(\ket{0}\), then applies H and T:

>>> PrepareStateT().decompose()
1-qubit circuit with 3 instructions:
├── Reset @ q[0]
├── H @ q[0]
└── T @ q[0]

See also

Reset, ResetX, MeasurePauli

inverse()[source]

Kraus channels have no inverse.

Raises:

NotImplementedError – Always.

power(pwr)[source]

Kraus channels cannot be raised to a power.

Raises:

NotImplementedError – Always.

iswrapper()[source]

Whether the operation wraps another operation.

True for composite operations such as Control, Power, Inverse, Parallel or IfStatement, False otherwise.

Returns:

bool

supports_canonical_rewrite()[source]

Whether CanonicalRewrite may decompose this operation.

Operations opt in: only those the canonical rewrite knows how to handle return True.

Returns:

bool

krausoperators()[source]

Return the Kraus operators \(T\ket{+}\bra{0}\) and \(T\ket{+}\bra{1}\).

Returns:

Two Operator objects.

Return type:

list

PrepareMagic

alias of PrepareStateT