@@ -155,7 +155,20 @@ def build_random_funcs(self):
155
155
cnt = 0
156
156
while cnt < self .n_funcs :
157
157
func = np .random .choice (self .funcs )
158
- n_func_wires = op_name_dict [func ]().num_wires
158
+ # print(f"Selected function: {func}")
159
+
160
+ """
161
+ ORIGINAL: n_func_wires = op_name_dict[func]().num_wires
162
+ Changed to avoid initialization error with QubitUnitaryFast which requires
163
+ parameters during instantiation. Instead, we access num_wires directly
164
+ from the class since it's a class attribute.
165
+ """
166
+
167
+ op_class = op_name_dict [func ]
168
+ # print(f"Operator class: {op_class}")
169
+ # print(f"Number of wires: {op_class.num_wires}")
170
+ n_func_wires = op_class .num_wires
171
+
159
172
if n_func_wires > self .n_wires :
160
173
continue
161
174
cnt += 1
@@ -191,8 +204,9 @@ def forward(self, q_device: tq.QuantumDevice, x):
191
204
self .func_list , self .func_wires_list , self .func_inverse
192
205
):
193
206
n_func_wires = len (func_wires )
194
- n_func_params = op_name_dict [func ]().num_params
195
-
207
+ op_class = op_name_dict [func ]
208
+ # n_func_params = op_name_dict[func]().num_params
209
+ n_func_params = op_class .num_params
196
210
if n_func_params == 0 :
197
211
if func in ["multicnot" , "multixcnot" ]:
198
212
func_name_dict [func ](
0 commit comments