bloqade-python icon indicating copy to clipboard operation
bloqade-python copied to clipboard

IR 2.0: ideas collection

Open Roger-luo opened this issue 2 years ago • 2 comments

opening this to track some ideas and issues we have for a refactor of the IR.

  • #665 reminds me that maybe we should make the IR a SSA IR this time
  • #661 the new IR should has its own metaclass/dataclass

Roger-luo avatar Oct 03 '23 16:10 Roger-luo

I think we should probably extend IR to include execution instructions to the different backends:

  • For hardware this is straightforward we would need a device nodes and nodes to describe sync/async execution
  • For emulator we can work off of current emulator IR just add execution instructions, e.g.:
    • Sampling at specific time points
    • Measurement of operators

weinbe58 avatar Oct 03 '23 17:10 weinbe58

I propose the following. Since we don't really plan on expanding AHS too much more, we should:

  1. remove dictionaries from the IR types and replace them with attributes, e.g. rydberg, and hyperfine are attributes of the Sequence
  2. Remove compositions on the level of the Pulse IR, this will significantly decrease the complexity of code generation for the full IR. e.g. have a Pulse node to store detuning phase and amplitude.
  3. ComplexField for the Rabi term.


class SequenceExpr
    ...

class ComplexField:
    amplitude: Field
    phase: Optional[Field]

class Pulse:
    detuning: Optional[Field]
    rabi: Optional[ComplexField]

class Sequence(SeqenceExpr):
    rydberg: Optional[Pulse]
    hyperfine: Optional[Pulse]

# keep compositions of Sequence
# ...

weinbe58 avatar Oct 15 '23 13:10 weinbe58