myQLM / myqlm-issues

4 stars 1 forks source link

Lambda functions in gate times and gate noise are not accepted, qpu constructor raises an error on the number of arguments. #27

Closed hvermaQ closed 6 months ago

hvermaQ commented 12 months ago

Exception: QLMServiceException(message='check_qpu_constructor: failed with TypeError: code() takes at most 16 arguments (21 given)', service_name='QLMHelpers')

To reproduce, see the following MWE:

from qat.lang.AQASM import Program, H, CNOT, RX, RY, RZ #Gates from qlmaas.qpus import NoisyQProc import numpy as np from qat.hardware import GatesSpecification, HardwareModel, DefaultGatesSpecification, DefaultHardwareModel from qlmaas.noisy import compute_fidelity

gdur1 = 50 # gate duration

alp = np.pi #rotation angle considered for the gate

simple program follows below

prog = Program() reg = prog.qalloc(1) prog.apply(RX(alp), reg[0]) circ = prog.to_circ()

gate specs and noise model follows

g_times = {"RX" : lambda ang: gdur1*ang} gates_spec = DefaultGatesSpecification(gate_times=g_times)

hardware model instantiated

h_model = DefaultHardwareModel(gate_times=g_times, gate_noise= None, idle_noise=None)

qpu with the noisy proc and above hardware model

qpu_predef = NoisyQProc(hardware_model = h_model, sim_method = 'stochastic')

calculate the fidelity

res3 = compute_fidelity(circ,qpu_predef) tes3 = res3.join() print(tes3)

Expected behavior There should be no error while using lambda functions in prescribing the gate times.

Info - OS: Windows11 qat-comm==1.4.4 qat-core==1.8.2 qat-devices==0.2.2 qat-hardware==1.3.2 qat-lang==3.0.2 qat-quops==1.3.1 qat-variational==1.4.2 qlmaas==1.9.1 myqlm==1.9.4 myqlm-clinalg==0.1.2 myqlm-contrib==1.9.1 myqlm-fermion==1.1.0 myqlm-simulators==1.9.2

JayEviden commented 6 months ago

I am closing this issue, please reopen, if there is still a problem.