:py:mod:`pygsti.extras.ibmq.ibmqexperiment` =========================================== .. py:module:: pygsti.extras.ibmq.ibmqexperiment .. autoapi-nested-parse:: Functions for sending experiments to IBMQ devices and converting the results to pyGSTi objects Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.extras.ibmq.ibmqexperiment.IBMQExperiment .. py:class:: IBMQExperiment(edesign, pspec, remove_duplicates=True, randomized_order=True, circuits_per_batch=75, num_shots=1024, seed=None, checkpoint_path=None, disable_checkpointing=False, checkpoint_override=False) Bases: :py:obj:`pygsti.protocols.protocol._TreeNode`, :py:obj:`pygsti.protocols.HasProcessorSpec` A object that converts pyGSTi ExperimentDesigns into jobs to be submitted to IBM Q, submits these jobs to IBM Q and receives the results. .. py:attribute:: auxfile_types .. py:attribute:: edesign .. py:attribute:: remove_duplicates :value: 'True' .. py:attribute:: randomized_order :value: 'True' .. py:attribute:: circuits_per_batch :value: '75' .. py:attribute:: num_shots :value: '1024' .. py:attribute:: seed :value: 'None' .. py:attribute:: checkpoint_path :value: "''" .. py:attribute:: disable_checkpointing :value: 'False' .. py:attribute:: pygsti_circuit_batches :value: '[]' .. py:attribute:: qiskit_isa_circuit_batches :value: '[]' .. py:attribute:: qjobs :value: '[]' .. py:attribute:: job_ids :value: '[]' .. py:attribute:: submit_time_calibration_data :value: '[]' .. py:attribute:: batch_results :value: '[]' .. py:attribute:: data :value: 'None' .. py:method:: from_dir(dirname, regen_jobs=False, service=None, new_checkpoint_path=None) :classmethod: Initialize a new IBMQExperiment object from `dirname`. Parameters ---------- dirname : str The directory name. regen_jobs: bool, optional Whether to recreate the RuntimeJobs from IBMQ based on the job ides. Defaults to False. You should set this to True if you would like to call monitor() or retrieve_results(). service: QiskitRuntimeService Service used to retrieve RuntimeJobs from IBMQ based on job_ids (if regen_jobs is True). new_checkpoint_path: str, optional A string for the path to use for writing intermediate checkpoint files to disk. If None, this defaults to using the same checkpoint as the serialized IBMQExperiment object. If provided, this will be the new checkpoint path used moving forward. Note that this can be the desired {dirname} for an eventual `write({dirname})` call, i.e. the serialized IBMQExperiment checkpoint after a successful `retrieve_results()` is equivalent to the serialized IBMQExperiment after `write()`. Returns ------- IBMQExperiment .. py:method:: monitor() Queries IBM Q for the status of the jobs. .. py:method:: retrieve_results() Gets the results of the completed jobs from IBM Q, and processes them into a pyGSTi DataProtocol object (stored as the key 'data'), which can then be used in pyGSTi data analysis routines (e.g., if this was a GST experiment, it can input into a GST protocol object that will analyze the data). .. py:method:: submit(ibmq_backend, start=None, stop=None, ignore_job_limit=True, wait_time=5, max_attempts=10, ibmq_session=None) Submits the jobs to IBM Q, that implements the experiment specified by the ExperimentDesign used to create this object. Parameters ---------- ibmq_backend: qiskit.providers.ibmq.ibmqbackend.IBMQBackend or qiskit_aer.AerSimulator The IBM Q backend to submit the jobs to. Should be the backend corresponding to the processor that this experiment has been designed for. start: int, optional Batch index to start submission (inclusive). Defaults to None, which will start submission on the first unsubmitted job. Jobs can be resubmitted by manually specifying this, i.e. start=0 will start resubmitting jobs from the beginning. stop: int, optional Batch index to stop submission (exclusive). Defaults to None, which will submit as many jobs as possible given the backend's maximum job limit. ignore_job_limit: bool, optional If True, then stop is set to submit all remaining jobs. This is set as True to maintain backwards compatibility. Note that is more jobs are needed than the max limit, this will enter a wait loop until all jobs have been successfully submitted. wait_time: int Number of seconds for each waiting step. wait_steps: int Number of steps to take before retrying job submission. ibmq_session: IBMQuantumRuntimeSession IBMQuantumRuntime Session to use Returns ------- None .. py:method:: transpile(ibmq_backend, direct_to_qiskit=False, qiskit_pass_kwargs=None, qasm_convert_kwargs=None, qiskit_convert_kwargs=None, num_workers=1) Transpile pyGSTi circuits into Qiskit circuits for submission to IBMQ. Parameters ---------- ibmq_backend: IBM backend to use during Qiskit transpilation direct_to_qiskit: bool, optional Whether to use OpenQASM as an intermediary in the conversion from pyGSTi circut to Qiskit circuit. If True, `qiskit_convert_kwargs` is passed to `Circuit.convert_to_qiskit`. If False, the pyGSTi circuits are first converted to OpenQASM and then converted into Qiskit circuits. qiskit_pass_kwargs: dict, optional Only used if direct_to_qiskit is False. Additional kwargs to pass in to `generate_preset_pass_manager`. If not defined, the default is {'seed_transpiler': self.seed, 'optimization_level': 0, 'basis_gates': ibmq_backend.operation_names} Note that "optimization_level" is a required argument to the pass manager. qasm_convert_kwargs: dict, optional Only used if direct_to_qiskit is False. Additional kwargs to pass in to `Circuit.convert_to_openqasm`. If not defined, the default is {'num_qubits': self.processor_spec.num_qubits, 'standard_gates_version': 'x-sx-rz'} qiskit_convert_kwargs: dict, optional Only used if direct_to_qiskit is True. Additional kwargs to pass to `Circuit.convert_to_qiskit`. If not defined, the default is {'num_qubits': self.processor_spec.num_qubits, 'qubit_conversion': 'remove-Q', 'block_between_layers': True, 'qubits_to_measure': 'active'}. num_workers: int, optional Number of workers to use for parallel (by batch) transpilation .. py:method:: write(dirname=None) Writes to disk, storing both the pyGSTi DataProtocol object in pyGSTi's standard format and saving all of the IBM Q submission information stored in this object, written into the subdirectory 'ibmqexperiment'. Parameters ---------- dirname : str The *root* directory to write into. This directory will have an 'edesign' subdirectory, which will be created if needed and overwritten if present. If None, then the path this object was loaded from is used (if this object wasn't loaded from disk, an error is raised).