Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[open-systems] QCDType, CDType, QDType #1584

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

mpharrigan
Copy link
Collaborator

This pull request is the first in a series for supporting open system (classical data & measurement), roadmap item #445.

QCDType

  • The existing QDType base class for quantum data types now descends from the more general QCDType. CDType is introduced to represent classical data types.
  • CBit is added, which is a single classical bit (analogous to QBit).
  • Python type annotations are updated as needed. In particular, Register's dtype argument can be either quantum or classical.
  • This existing, runtime, Qualtran-based type checking basically works without modification. It won't let you plug a quantum wire into a classical bloq (or vice versa)

_ControlledBase

  • I've refactored the class hierarchy of Controlled. The circuit-implementation-agnostic bit is now in _ControlledBase from which Controlled (which uses a "total control" circuit) and ControlledViaAnd descend.
  • CtrlSpec supports classical data types (CDType)
  • The logic for choosing the correct default controlled meta-bloq based on control spec is factored out into a function
  • This is to support plugging in a new, forthcoming ClassicallyControlled metabloq

Drawing

  • The musical score diagrams draw classical wires in blue.

Documentation

  • The existing QDType system was not really documented (at least not with its own notebook). I went ahead and wrote docs for the data type system.
  • There is a section at the end about the QCDType class hierarchy

Naming

  • Before this PR and throughout the framework, qdtype: QDType and dtype: QDType have been used interchangeably. After this PR, idiomatically: qdtype should be the variable name used for a QDType and dtype should be reserved for variables that can be either quantum or classical (i.e. QCDType). Where the variable name isn't backwards-compatibility breaking, I've made those changes in this PR; but there are many places where dtype is used where qdtype would be more appropriate
  • Before this PR and throughout the framework, bitsize and num_qubits (as variable/method names) have been used interchangeably. This PR adds methods/properties that aim to disambiguate these quantities. bitsize or num_bits is the total number of quantum and/or classical bits. num_qubits is strictly qubits (resource counting still counts strictly qubits). num_cbits is added; which is the number of strictly classical qubits.

Non-changes (yet)

  • While CDType, CBit, and CtrlSpec(CBit()) are introduced, there's no real way to use them (with the exception of Cast, which is likely not what you really want).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant