Skip to content

RFC: refactoring measurement #158

@Roger-luo

Description

@Roger-luo

The Measure statement is not very compatible with stim or QASM2

from stim there are

  • PPMeasure(p: float, pauli_string) -> bool: measure on a Pauli string as basis by a given probability
    • measure XXYY on 4 qubits resulting a boolean value
    • p is the probablity of -> bool being flipped
    • MZZ, etc.
  • Measure(basis, position, p: float) -> bool

from QASM2 there are

  • Measure(qreg, creg)

We introduce the following statement to model all the above

# in wire
class Measure:
    basis: ir.SSAValue = info.argument(OpType)
    wires: tuple[ir.SSAValue, ...] = info.argument(Wire)
    prob: ir.SSAValue = info.argument(Union[Float, NoneType])
# in qubit
class Measure:
    basis: ir.SSAValue = info.argument(OpType)
    qubits: ir.SSAValue = info.argument(IListType[Qubit, ...])
    prob: ir.SSAValue = info.argument(Union[Float, NoneType])
parallel {
    %1 = Measure(basis, (%wire_1, %wire_2), p=None) -> bool
    %2 = Measure(basis, (%wire_3, %wire_4), p=None) -> bool
}

cc: @kaihsin @johnzl-777

Metadata

Metadata

Assignees

Labels

breakingbreaking changes or proposed changes that would break existing APIsenhancementNew feature or requestrfcRequest for Commentssquinsquin related issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions