Skip to content

✨ Add support for classical registers #1726

@denialhaag

Description

@denialhaag

Description

Currently, QC and QCO do not have native support for classical registers. Their builders do have methods to allocate classical registers, but these only return collections of Bit structures that store some metadata. We should adapt these methods to allocate an MLIR object that can store and retrieve measurement results.

Open questions

  • Should classical registers be represented as tensor or memref types? For reference, jeff uses tensor types. How are classical registers represented in openqasm/qe-compiler?
  • Should the same representation be used in QC and QCO? Using the same representation would significantly simplify internal conversions.

Acceptance criteria

  • QCProgramBuilder::allocClassicalBitRegister() and QCOProgramBuilder::allocClassicalBitRegister() create some sort of MLIR object. It likely makes sense to mimic the behavior of the allocQubitRegister() methods and return a custom structure containing the loaded entries.
  • The register_name, register_size, and register_index attributes are removed from qc::MeasureOp and qco::MeasureOp.
  • The conversion of qc::MeasureOps to QIR is improved. The original register information is retained during conversion to the Adaptive Profile. During conversion to the Base Profile, all bits are converted to statically allocated ones. Implement the output recording as suggested in ✨ Add QC to QIR Adaptive Profile Conversion #1710 (comment).
  • translateQuantumComputationToQC() can translate measurements inside qc::IfElseOperations (see ✨ Translate qc::IfElseOperation to QC #1717 (review) for context).

Metadata

Metadata

Assignees

No one assigned

    Labels

    MLIRAnything related to MLIRfeatureNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions