Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.26k stars 2.37k forks source link

Modeling and compiling circuits with classical instructions and data #7567

Open kdk opened 2 years ago

kdk commented 2 years ago

With the addition of classical types and the expansion of classical instructions both in the OpenQASM3 language and available on devices, terra should expand the ability of users to build, compile, and simulate QuantumCircuits containing classical instructions and classical data types. This meta-issue will serve as a place to track progress, discussions and decisions on this front.

Classical data types:

https://qiskit.github.io/openqasm/language/types.html#classical-types

Scalar types:

Questions:

Array types:

OpenQASM 3 defines two array types, global C-like arrays (backed by memory) with compile-time known size and array references (available as as function arguments) with known sizes at point of entry (if specified in the subroutine description) and compile-time known number of dimensions.

Questions:

Constants:

Duration:

https://qiskit.github.io/openqasm/language/delays.html#duration-and-stretch-types

Defined in OpenQASM3 as a numeric type plus one of ns, μs, us, ms, or s.

Questions:

Casting:

https://qiskit.github.io/openqasm/language/types.html#allowed-casts

Register aliasing/concatenation/slicing

https://qiskit.github.io/openqasm/language/types.html#register-concatenation-and-slicing

ClassicalRegisters are presently mapped in the Exporter as aliases, and support slicing and concatenation.

Classical instruction types:

https://qiskit.github.io/openqasm/language/classical.html#low-level-classical-instructions

Classical Instructions:

Parameters and ParameterExpressions

Parameters and ParameterExpressions exist in Qiskit as ways to defer assignment of QuantumCircuit instruction parameters, and overlap just enough with variables in OpenQASM 3 that a unified approach will be needed.

Questions

Input/Output types on a QuantumCircuit

https://qiskit.github.io/openqasm/language/directives.html#input-output

Subroutines

Qiskit currently supports sub-circuits as composite Instruction/Gates which map most closely to OpenQASM 3.0's hierarchically defined gates ( https://qiskit.github.io/openqasm/language/gates.html#hierarchically-defined-unitary-gates ) with the exception that Qiskit sub-circuits can include OpenQASM 2.0-like register style conditionals. OpenQASM 3.0 defines separate subroutines which are notably pass-by-value. Array's are also passed by value, but the value is a reference to the array.

jakelishman commented 2 years ago

Some additional preliminary thoughts in no particular order (mostly I'm using this issue as a notepad):

HuangJunye commented 2 years ago

Are we still planning to close this issue for 0.20?

jakelishman commented 2 years ago

I've attached it to 0.21, but really this is the containing epic as the tracking issue for "dynamic circuits" on the project board, so it's not actionable as a single item.