mimiqcircuits.operations.losschannel¶
Loss-channel operations.
Classes
|
Record whether a qubit is present into a classical bit. |
|
One-qubit loss event: the qubit is lost with probability |
Measure a qubit if it is present, and record its presence. |
|
|
Reload a qubit: reset it to \(|0\rangle\) and mark it present. |
- class Loss(p=1.0)[source]¶
Bases:
OperationOne-qubit loss event: the qubit is lost with probability
p.Loss()isLoss(1.0), a certain loss. A lost qubit leaves the computation: gates on it are dropped, a measurement of it reads 0, andCheckreports it as missing, until aReloadbrings it back.The probability is resolved by
Circuit.sample_losses(), which turns eachLoss(p)intoLoss(1.0)or removes it.Circuit.resolve_losses()then gives a runnable, loss-free circuit; aLossModeldecides what happens to gates acting on both lost and present qubits.Loss cannot be inverted, raised to a power or controlled:
inverse(),power()andcontrol()raiseTypeError.- Parameters:
p – Loss probability, real and in \([0, 1]\) (default
1.0). May be symbolic; it must be numeric before sampling.- Raises:
ValueError – If a numeric
pis not real or is outside \([0, 1]\).
Examples
>>> from mimiqcircuits import * >>> # qubit 0 is lost with probability 0.1 >>> c = Circuit() >>> c.push(Loss(0.1), 0) 1-qubit circuit with 1 instruction: └── Loss(0.1) @ q[0] >>> # qubit 1 is lost for sure >>> c.push(Loss(), 1) 2-qubit circuit with 2 instructions: ├── Loss(0.1) @ q[0] └── Loss(1.0) @ q[1]
See also
Reload,Check,MeasureCheck,sample_losses(),resolve_losses()- evaluate(d={})[source]¶
Return a copy with symbols in
psubstituted by values.- Parameters:
d (dict) – Map from symbols to the values to substitute.
- Returns:
A new operation;
pbecomes a number when it is fully numeric.- Return type:
- Raises:
ValueError – If the substituted
pis not real or is outside \([0, 1]\).
- class Reload[source]¶
Bases:
OperationReload a qubit: reset it to \(|0\rangle\) and mark it present.
A reload always resets the qubit, whether or not it was lost. After
lower_losses()it becomes aResetfollowed by aReloadedmarker.Reload is not reversible:
inverse(),power()andcontrol()raiseTypeError.Examples
>>> from mimiqcircuits import * >>> # bring qubit 0 back in |0>, lost or not >>> c = Circuit() >>> c.push(Reload(), 0) 1-qubit circuit with 1 instruction: └── Reload @ q[0]
See also
Loss,Reset
- class Check[source]¶
Bases:
OperationRecord whether a qubit is present into a classical bit.
The bit is set to 1 if the qubit is present and to 0 if it is lost. Like
Measurerecords a qubit’s value,Checkrecords its presence; it does not touch the quantum state. It targets one qubit and one bit.Check cannot be inverted, raised to a power or controlled: those methods raise
TypeError.Examples
>>> from mimiqcircuits import * >>> # write the presence of qubit 0 into bit 0 >>> c = Circuit() >>> c.push(Check(), 0, 0) 1-qubit, 1-bit circuit with 1 instruction: └── Check @ q[0], c[0]
See also
- class MeasureCheck[source]¶
Bases:
OperationMeasure a qubit if it is present, and record its presence.
It targets one qubit and two bits. The first bit gets the Z-basis measurement result (0 if the qubit is lost), the second the presence (1 present, 0 lost). The state collapses only when the qubit is present.
MeasureCheck cannot be inverted, raised to a power or controlled: those methods raise
TypeError.Examples
>>> from mimiqcircuits import * >>> # outcome of qubit 0 into bit 0, its presence into bit 1 >>> c = Circuit() >>> c.push(MeasureCheck(), 0, 0, 1) 1-qubit, 2-bit circuit with 1 instruction: └── MeasureCheck @ q[0], c[0:1]