qadence icon indicating copy to clipboard operation
qadence copied to clipboard

[Bug, DA] Limitations on `AnalogRX` due to the duration

Open CdeTerra opened this issue 1 year ago • 6 comments

Currently, it's impossible to kron AnalogRX blocks with different angles, because the duration directly depends on it:

kron(AnalogRX(torch.pi/4, qubit_support=0), kron(AnalogRX(torch.pi/2, qubit_support=1)))
# ValueError: Kron'ed blocks have to have same duration.

Same problem with values having identical absolute values but opposite signs:

kron(AnalogRX(torch.pi/4, qubit_support=0), kron(AnalogRX(-torch.pi/4, qubit_support=1)))
# ValueError: Kron'ed blocks have to have same duration.

Interestingly, a negative angle leads to a negative duration:

AnalogRX(-torch.pi/4, qubit_support=0)
# ConstantAnalogRotation(α=-0.785398163397448, t=-250.000000000000, support=(0,), Ω=3.14159265358979, δ=0, φ=0)

In _analog_rot definition, there's a comment about it, so adjust the amplitude instead of the duration:

    # FIXME: once https://gitlab.pasqal.com/pqs/qadence/-/issues/402 is fixed set default duration
    # in the function arguments to:
    # duration = Parameter(160)
    # and compute omega like this:
    # omega = alpha / duration * 1000

But the issue's link doesn't exist, so this one can serve as a replacement.

CdeTerra avatar Oct 27 '23 12:10 CdeTerra

Actually, @CdeTerra is there a reason why you have these inner kron operations ?

RolandMacDoland avatar Oct 27 '23 12:10 RolandMacDoland

Actually, @CdeTerra is there a reason why you have these inner kron operations ?

No, it's simply a mistake, the code I intended is:

kron(AnalogRX(torch.pi/4, qubit_support=0), AnalogRX(torch.pi/2, qubit_support=1))
kron(AnalogRX(torch.pi/4, qubit_support=0), AnalogRX(-torch.pi/4, qubit_support=1))

CdeTerra avatar Oct 27 '23 12:10 CdeTerra

Actually, @CdeTerra is there a reason why you have these inner kron operations ?

No, it's simply a mistake, the code I intended is:

kron(AnalogRX(torch.pi/4, qubit_support=0), AnalogRX(torch.pi/2, qubit_support=1))
kron(AnalogRX(torch.pi/4, qubit_support=0), AnalogRX(-torch.pi/4, qubit_support=1))

Right, but the error still raises ?

RolandMacDoland avatar Oct 27 '23 13:10 RolandMacDoland

Yes, it does

CdeTerra avatar Oct 27 '23 13:10 CdeTerra

@jpmoutinho Still relevant ?

RolandMacDoland avatar Feb 07 '24 21:02 RolandMacDoland

Yes, to be closed after handling #226 and #87

jpmoutinho avatar Feb 08 '24 08:02 jpmoutinho