@@ -64,6 +64,7 @@ def __init__(
64
64
nqubits = nqubits , inputs = inputs , mps_inputs = mps_inputs , split = split
65
65
)
66
66
self .calibrations = []
67
+ self .calibration_invokes = []
67
68
68
69
self .inputs = inputs
69
70
self .mps_inputs = mps_inputs
@@ -117,7 +118,7 @@ def __init__(
117
118
self ._qir : List [Dict [str , Any ]] = []
118
119
self ._extra_qir : List [Dict [str , Any ]] = []
119
120
120
- def add_calibration (
121
+ def def_calibration (
121
122
self , name : str , parameters : List [str ], instructions : List [Dict ]
122
123
) -> None :
123
124
self .calibrations .append ({
@@ -126,6 +127,15 @@ def add_calibration(
126
127
"instructions" : instructions
127
128
})
128
129
130
+ def add_calibration (
131
+ self , name : str , parameters : List [str ], instructions : List [Dict ]
132
+ ) -> None :
133
+ self .calibration_invokes .append ({
134
+ "name" : name ,
135
+ "parameters" : parameters ,
136
+ "instructions" : instructions
137
+ })
138
+
129
139
130
140
def to_tqasm (self ) -> str :
131
141
qasm_lines = []
@@ -149,6 +159,10 @@ def to_tqasm(self) -> str:
149
159
qasm_lines .append (f" play({ inst ['frame' ]} , { wf_type } ({ args_str } ));" )
150
160
qasm_lines .append ("}" )
151
161
162
+ for cal in getattr (self , "calibration_invokes" , []):
163
+ pname = ", " .join (cal ["parameters" ])
164
+ qasm_lines .append (f"\n { cal ['name' ]} { pname } ;" )
165
+
152
166
return "\n " .join (qasm_lines )
153
167
154
168
def calibrate (self , name : str , parameters : List ["Param" ]) -> "DefcalBuilder" :
@@ -1078,8 +1092,8 @@ def play(self, frame_name: str, waveform: Any, start_time: int = None):
1078
1092
return self
1079
1093
1080
1094
def build (self ):
1081
- self .circuit .add_calibration (
1095
+ self .circuit .def_calibration (
1082
1096
name = self .name ,
1083
1097
parameters = [p .name for p in self .parameters ],
1084
1098
instructions = self .instructions ,
1085
- )
1099
+ )
0 commit comments