Skip to content

Commit

Permalink
Merge pull request #1155 from qiboteam/qm_kernels
Browse files Browse the repository at this point in the history
Fix custom integration weights for QM
  • Loading branch information
andrea-pasquale authored Feb 26, 2025
2 parents d36edc8 + c9f1eaf commit 9a2b1c6
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/qibolab/_core/instruments/qm/config/pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,32 +116,33 @@ def from_dc_pulse(cls, pulse: Pulse):
)


def _convert_integration_weights(x: list[tuple], minus: bool = False) -> list[tuple]:
"""Convert integration weights array for QM."""
return [(-i[0] if minus else i[0], i[1]) for i in x]


def integration_weights(element: str, readout_len: int, kernel=None, angle: float = 0):
"""Create integration weights section for QM config."""
cos, sin = np.cos(angle), np.sin(angle)
if kernel is None:

def convert(x):
return [(x, readout_len)]
if kernel is None:
cos = [(np.cos(angle), readout_len)]
sin = [(np.sin(angle), readout_len)]
else:
cos = kernel * cos
sin = kernel * sin

def convert(x):
return x
cos = [(i, 4) for i in kernel.real[::4]]
sin = [(i, 4) for i in kernel.imag[::4]]

return {
f"cosine_weights_{element}": {
"cosine": convert(cos),
"sine": convert(-sin),
"cosine": _convert_integration_weights(cos),
"sine": _convert_integration_weights(sin, minus=True),
},
f"sine_weights_{element}": {
"cosine": convert(sin),
"sine": convert(cos),
"cosine": _convert_integration_weights(sin),
"sine": _convert_integration_weights(cos),
},
f"minus_sine_weights_{element}": {
"cosine": convert(-sin),
"sine": convert(-cos),
"cosine": _convert_integration_weights(sin, minus=True),
"sine": _convert_integration_weights(cos, minus=True),
},
}

Expand Down

0 comments on commit 9a2b1c6

Please sign in to comment.