QuEraComputing / bloqade-python

QuEra's Neutral Atom SDK for Analog QPUs
https://bloqade.quera.com/
Other
56 stars 14 forks source link

Formalizing Rabi in IR. #81

Open weinbe58 opened 1 year ago

weinbe58 commented 1 year ago

Main Issue

Given the discussion about the Rabi Builder, I think from an IR and analysis perspective having a Unified Rabi IR node actually makes sense. Currently, we have two separate AST nodes for Amplitude and Phase, which makes some forms of analysis awkward.

One use-case:

When calculating the Rabi term, one needs to merge the mask for both the phase and the amplitude because only non-zero amplitudes matter for calculating the coefficient of the rabi-matrix. Currently, this has to be by storing some info about the other AST node in the compiler's state in order to do this analysis, whereas, if the rabi node was unified, this analysis would not need to use a compiler state.

Proposal

We should remove the concept of Field in place of an IR node for detuning and rabi term separately. Some input from the Hardware perspective is needed here. For example, does it even make sense to have a separate mask for the phase part of the rabi-term, given how the phase is implemented?

My guess is that generally, the amplitude of the rabi-field is easy to manipulate locally, but the phase would be more difficult, so I feel like the following makes the most sense:

Field IR module:

Remove Field all together and replace it with:

class DetuningTerms:
    terms: Dict[SpatialModulation, Waveform] = {}

class RabiDrive:
    amplitude: Waveform
    phase: Waveform

class RabiTerms
    terms: Dict[SpatialModulation, RabiDrive] = {}

If we want to have a mask for the phase then the following could also work:

Field IR module:

class RabiTerms
    amplitude: Field
    phase: Field

and Detuning just defaults to a Field object in the Pulse IR.

~In Pulse IR module:~

~Finally, we would need to update the Pulse IR:~

weinbe58 commented 1 year ago

@Wang-Shengtao I think some input about the physical implementation of the Rabi drive would be helpful for this discussion, specifically to whether it is physically possible to have local addressing of the Phase and the Amplitude independently of one another.

weinbe58 commented 1 year ago

Oh right, I forget we should probably stick with the dictionary interface for the Pulse IR. Nothing would need to change in the Pulse IR.

weinbe58 commented 1 year ago

Another Idea would be to define a special type of SpatialModulation specifically for Rabi term.

Roger-luo commented 1 year ago

We should remove the concept of Field in place of an IR node for detuning and rabi term separately. Some input from the Hardware perspective is needed here. For example, does it even make sense to have a separate mask for the phase part of the rabi-term, given how the phase is implemented?

It seems to me that this is enforcing one always aligns a phase and amplitude on the same spatial modulation, which I think makes sense given they belong to the same term in the Hamiltonian?

Oh right, I forget we should probably stick with the dictionary interface for the Pulse IR. Nothing would need to change in the Pulse IR.

what dictionary interface are you referring to here? And why this change will not affect the dictionary interface?

weinbe58 commented 1 year ago

what dictionary interface are you referring to here? And why this change will not affect the dictionary interface?

In my original proposal, I replaced the dictionary interface with concrete attributes but we shuold keep the dictionary interface and just reduce the current keys.