Skip to content

Commit 9a2b1c6

Browse files
Merge pull request #1155 from qiboteam/qm_kernels
Fix custom integration weights for QM
2 parents d36edc8 + c9f1eaf commit 9a2b1c6

File tree

1 file changed

+16
-15
lines changed
  • src/qibolab/_core/instruments/qm/config

1 file changed

+16
-15
lines changed

src/qibolab/_core/instruments/qm/config/pulses.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -116,32 +116,33 @@ def from_dc_pulse(cls, pulse: Pulse):
116116
)
117117

118118

119+
def _convert_integration_weights(x: list[tuple], minus: bool = False) -> list[tuple]:
120+
"""Convert integration weights array for QM."""
121+
return [(-i[0] if minus else i[0], i[1]) for i in x]
122+
123+
119124
def integration_weights(element: str, readout_len: int, kernel=None, angle: float = 0):
120125
"""Create integration weights section for QM config."""
121-
cos, sin = np.cos(angle), np.sin(angle)
122-
if kernel is None:
123126

124-
def convert(x):
125-
return [(x, readout_len)]
127+
if kernel is None:
128+
cos = [(np.cos(angle), readout_len)]
129+
sin = [(np.sin(angle), readout_len)]
126130
else:
127-
cos = kernel * cos
128-
sin = kernel * sin
129-
130-
def convert(x):
131-
return x
131+
cos = [(i, 4) for i in kernel.real[::4]]
132+
sin = [(i, 4) for i in kernel.imag[::4]]
132133

133134
return {
134135
f"cosine_weights_{element}": {
135-
"cosine": convert(cos),
136-
"sine": convert(-sin),
136+
"cosine": _convert_integration_weights(cos),
137+
"sine": _convert_integration_weights(sin, minus=True),
137138
},
138139
f"sine_weights_{element}": {
139-
"cosine": convert(sin),
140-
"sine": convert(cos),
140+
"cosine": _convert_integration_weights(sin),
141+
"sine": _convert_integration_weights(cos),
141142
},
142143
f"minus_sine_weights_{element}": {
143-
"cosine": convert(-sin),
144-
"sine": convert(-cos),
144+
"cosine": _convert_integration_weights(sin, minus=True),
145+
"sine": _convert_integration_weights(cos, minus=True),
145146
},
146147
}
147148

0 commit comments

Comments
 (0)