Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SECRCalibrationBuilder does not work with Runtime #48

Open
kevinsung opened this issue Oct 17, 2022 · 0 comments
Open

SECRCalibrationBuilder does not work with Runtime #48

kevinsung opened this issue Oct 17, 2022 · 0 comments
Assignees

Comments

@kevinsung
Copy link
Collaborator

kevinsung commented Oct 17, 2022

Related: Qiskit/qiskit-ibm-runtime#571

from qiskit import QuantumCircuit, pulse
from qiskit_ibm_runtime import QiskitRuntimeService, Sampler
from qiskit.transpiler import PassManager
from qiskit.providers.fake_provider import FakeBelemV2
from qiskit_research.utils.pulse_scaling import SECRCalibrationBuilder
from qiskit_research.utils.gates import SECRGate

service = QiskitRuntimeService()
backend = service.backend("ibm_perth")
sampler = Sampler(session=backend)

inst_sched_map = backend.defaults().instruction_schedule_map
channel_map = backend.configuration().qubit_channel_mapping
pass_manager = PassManager([SECRCalibrationBuilder(inst_sched_map, channel_map)])

circuit = QuantumCircuit(2)
circuit.append(SECRGate(0.1), [0, 1])
circuit.measure_all()
transpiled = pass_manager.run(circuit)
job = sampler.run([transpiled], shots=1000)
---------------------------------------------------------------------------
QpyError                                  Traceback (most recent call last)
<ipython-input-1-205f6bf86f68> in <module>
     18 circuit.measure_all()
     19 transpiled = pass_manager.run(circuit)
---> 20 job = sampler.run([transpiled], shots=1000)

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/sampler.py in run(self, circuits, parameter_values, parameters, **kwargs)
    194             parameters = [parameters]
    195 
--> 196         return super().run(
    197             circuits=circuits,
    198             parameter_values=parameter_values,

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qiskit/primitives/base_sampler.py in run(self, circuits, parameter_values, parameters, **run_options)
    368                 )
    369 
--> 370         return self._run(circuits, parameter_values, parameter_views, **run_options)
    371 
    372     @abstractmethod

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/sampler.py in _run(self, circuits, parameter_values, parameters, **kwargs)
    235         inputs.update(Options._get_program_inputs(combined))
    236 
--> 237         return self._session.run(
    238             program_id=self._PROGRAM_ID,
    239             inputs=inputs,

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/session.py in _wrapper(self, *args, **kwargs)
     32         if not self._active:
     33             raise RuntimeError("The session is closed.")
---> 34         return func(self, *args, **kwargs)
     35 
     36     return _wrapper

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/session.py in run(self, program_id, inputs, options, result_decoder)
    137         options["backend"] = self._backend
    138 
--> 139         job = self._service.run(
    140             program_id=program_id,
    141             options=options,

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qiskit_runtime_service.py in run(self, program_id, inputs, options, callback, result_decoder, instance, session_id, job_tags, max_execution_time, start_session)
    932         result_decoder = result_decoder or ResultDecoder
    933         try:
--> 934             response = self._api_client.program_run(
    935                 program_id=program_id,
    936                 backend_name=options["backend"],

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/api/clients/runtime.py in program_run(self, program_id, backend_name, params, image, hgp, log_level, session_id, job_tags, max_execution_time, start_session)
    148             hub, group, project = from_instance_format(hgp)
    149             hgp_dict = {"hub": hub, "group": group, "project": project}
--> 150         return self._api.program_run(
    151             program_id=program_id,
    152             backend_name=backend_name,

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/api/rest/runtime.py in program_run(self, program_id, backend_name, params, image, hub, group, project, log_level, session_id, job_tags, max_execution_time, start_session)
    181             payload["group"] = group
    182             payload["project"] = project
--> 183         data = json.dumps(payload, cls=RuntimeEncoder)
    184         return self.session.post(url, data=data).json()
    185 

/usr/lib/python3.10/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
    236         check_circular=check_circular, allow_nan=allow_nan, indent=indent,
    237         separators=separators, default=default, sort_keys=sort_keys,
--> 238         **kw).encode(obj)
    239 
    240 

/usr/lib/python3.10/json/encoder.py in encode(self, o)
    197         # exceptions aren't as detailed.  The list call should be roughly
    198         # equivalent to the PySequence_Fast that ''.join() would do.
--> 199         chunks = self.iterencode(o, _one_shot=True)
    200         if not isinstance(chunks, (list, tuple)):
    201             chunks = list(chunks)

/usr/lib/python3.10/json/encoder.py in iterencode(self, o, _one_shot)
    255                 self.key_separator, self.item_separator, self.sort_keys,
    256                 self.skipkeys, _one_shot)
--> 257         return _iterencode(o, 0)
    258 
    259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/utils/json.py in default(self, obj)
    216             if isinstance(obj, BlueprintCircuit):
    217                 obj = obj.decompose()
--> 218             value = _serialize_and_encode(
    219                 data=obj,
    220                 serializer=lambda buff, data: dump(data, buff),  # type: ignore[no-untyped-call]

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/utils/json.py in _serialize_and_encode(data, serializer, compress, **kwargs)
     95     """
     96     with io.BytesIO() as buff:
---> 97         serializer(buff, data, **kwargs)
     98         buff.seek(0)
     99         serialized_data = buff.read()

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/utils/json.py in <lambda>(buff, data)
    218             value = _serialize_and_encode(
    219                 data=obj,
--> 220                 serializer=lambda buff, data: dump(data, buff),  # type: ignore[no-untyped-call]
    221             )
    222             return {"__type__": "QuantumCircuit", "__value__": value}

~/projects/qiskit-terra/qiskit/utils/deprecation.py in wrapper(*args, **kwargs)
     26             if kwargs:
     27                 _rename_kwargs(func.__name__, kwargs, kwarg_map, category)
---> 28             return func(*args, **kwargs)
     29 
     30         return wrapper

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/interface.py in dump(programs, file_obj, metadata_serializer)
    167 
    168     for program in programs:
--> 169         writer(  # type: ignore[no-untyped-call]
    170             file_obj, program, metadata_serializer=metadata_serializer
    171         )

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/binary_io/circuits.py in write_circuit(file_obj, circuit, metadata_serializer)
    847 
    848     # Write calibrations
--> 849     _write_calibrations(file_obj, circuit.calibrations, metadata_serializer)
    850 
    851 

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/binary_io/circuits.py in _write_calibrations(file_obj, calibrations, metadata_serializer)
    725             len(qubits),
    726             len(params),
--> 727             type_keys.Program.assign(schedule),
    728         )
    729         file_obj.write(defheader)

~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/type_keys.py in assign(cls, obj)
    376             return cls.SCHEDULE_BLOCK
    377 
--> 378         raise exceptions.QpyError(
    379             f"Object type '{type(obj)}' is not supported in {cls.__name__} namespace."
    380         )

QpyError: "Object type '<class 'qiskit.pulse.schedule.Schedule'>' is not supported in Program namespace."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants