174 lines
7.6 KiB
Plaintext
174 lines
7.6 KiB
Plaintext
---
|
||
title: RXCalibrationBuilder (latest version)
|
||
description: API reference for qiskit.transpiler.passes.RXCalibrationBuilder in the latest version of qiskit
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.transpiler.passes.RXCalibrationBuilder
|
||
---
|
||
|
||
# RXCalibrationBuilder
|
||
|
||
<Class id="qiskit.transpiler.passes.RXCalibrationBuilder" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/calibration/rx_builder.py#L29-L138" signature="qiskit.transpiler.passes.RXCalibrationBuilder(*args, **kwargs)" modifiers="class">
|
||
Bases: `CalibrationBuilder`
|
||
|
||
Add single-pulse RX calibrations that are bootstrapped from the SX calibration.
|
||
|
||
<Admonition title="Note" type="note">
|
||
Requirement: NormalizeRXAngles pass (one of the optimization passes).
|
||
</Admonition>
|
||
|
||
It is recommended to place this pass in the post-optimization stage of a passmanager. A simple demo:
|
||
|
||
```python
|
||
from qiskit.providers.fake_provider import GenericBackendV2
|
||
from qiskit.transpiler import PassManager, PassManagerConfig
|
||
from qiskit.transpiler.preset_passmanagers import level_1_pass_manager
|
||
from qiskit.circuit import Parameter
|
||
from qiskit.circuit.library import QuantumVolume
|
||
from qiskit.circuit.library.standard_gates import RXGate
|
||
|
||
from qiskit.transpiler.passes import RXCalibrationBuilder
|
||
|
||
qv = QuantumVolume(4, 4, seed=1004)
|
||
|
||
# Transpiling with single pulse RX gates enabled
|
||
backend_with_single_pulse_rx = GenericBackendV2(5)
|
||
rx_inst_props = {}
|
||
for i in range(backend_with_single_pulse_rx.num_qubits):
|
||
rx_inst_props[(i,)] = None
|
||
backend_with_single_pulse_rx.target.add_instruction(RXGate(Parameter("theta")), rx_inst_props)
|
||
config_with_rx = PassManagerConfig.from_backend(backend=backend_with_single_pulse_rx)
|
||
pm_with_rx = level_1_pass_manager(pass_manager_config=config_with_rx)
|
||
rx_builder = RXCalibrationBuilder(target=backend_with_single_pulse_rx.target)
|
||
pm_with_rx.post_optimization = PassManager([rx_builder])
|
||
transpiled_circ_with_single_pulse_rx = pm_with_rx.run(qv)
|
||
transpiled_circ_with_single_pulse_rx.count_ops()
|
||
|
||
# Conventional transpilation: each RX gate is decomposed into a sequence with two SX gates
|
||
original_backend = GenericBackendV2(5)
|
||
original_config = PassManagerConfig.from_backend(backend=original_backend)
|
||
original_pm = level_1_pass_manager(pass_manager_config=original_config)
|
||
original_transpiled_circ = original_pm.run(qv)
|
||
original_transpiled_circ.count_ops()
|
||
```
|
||
|
||
**References**
|
||
|
||
* \[1]: Gokhale et al. (2020), Optimized Quantum Compilation for Near-Term Algorithms with OpenPulse. arXiv:2004.11205 \<[https://arxiv.org/abs/2004.11205](https://arxiv.org/abs/2004.11205)>
|
||
|
||
Bootstrap single-pulse RX gate calibrations from the (hardware-calibrated) SX gate calibration.
|
||
|
||
**Parameters**
|
||
|
||
* **target** ([*Target*](qiskit.transpiler.Target "qiskit.transpiler.Target")) – Should contain a SX calibration that will be
|
||
* **calibrations.** (*used for bootstrapping RX*) –
|
||
|
||
## Attributes
|
||
|
||
### is\_analysis\_pass
|
||
|
||
<Attribute id="qiskit.transpiler.passes.RXCalibrationBuilder.is_analysis_pass">
|
||
Check if the pass is an analysis pass.
|
||
|
||
If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.
|
||
</Attribute>
|
||
|
||
### is\_transformation\_pass
|
||
|
||
<Attribute id="qiskit.transpiler.passes.RXCalibrationBuilder.is_transformation_pass">
|
||
Check if the pass is a transformation pass.
|
||
|
||
If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).
|
||
</Attribute>
|
||
|
||
## Methods
|
||
|
||
### execute
|
||
|
||
<Function id="qiskit.transpiler.passes.RXCalibrationBuilder.execute" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/basepasses.py#L189-L211" signature="execute(passmanager_ir, state, callback=None)">
|
||
Execute optimization task for input Qiskit IR.
|
||
|
||
**Parameters**
|
||
|
||
* **passmanager\_ir** ([*Any*](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.13)")) – Qiskit IR to optimize.
|
||
* **state** ([*PassManagerState*](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")) – State associated with workflow execution by the pass manager itself.
|
||
* **callback** ([*Callable*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable "(in Python v3.13)") *| None*) – A callback function which is caller per execution of optimization task.
|
||
|
||
**Returns**
|
||
|
||
Optimized Qiskit IR and state of the workflow.
|
||
|
||
**Return type**
|
||
|
||
[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[*Any*](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.13)"), [qiskit.passmanager.compilation\_status.PassManagerState](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")]
|
||
</Function>
|
||
|
||
### get\_calibration
|
||
|
||
<Function id="qiskit.transpiler.passes.RXCalibrationBuilder.get_calibration" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/calibration/rx_builder.py#L112-L138" signature="get_calibration(node_op, qubits)">
|
||
Generate RX calibration for the rotation angle specified in node\_op.
|
||
|
||
**Return type**
|
||
|
||
[*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.schedule.Schedule") | [*ScheduleBlock*](qiskit.pulse.ScheduleBlock "qiskit.pulse.schedule.ScheduleBlock")
|
||
</Function>
|
||
|
||
### name
|
||
|
||
<Function id="qiskit.transpiler.passes.RXCalibrationBuilder.name" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/passmanager/base_tasks.py#L68-L70" signature="name()">
|
||
Name of the pass.
|
||
|
||
**Return type**
|
||
|
||
[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")
|
||
</Function>
|
||
|
||
### run
|
||
|
||
<Function id="qiskit.transpiler.passes.RXCalibrationBuilder.run" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/calibration/base_builder.py#L54-L79" signature="run(dag)">
|
||
Run the calibration adder pass on dag.
|
||
|
||
**Parameters**
|
||
|
||
**dag** ([*DAGCircuit*](qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.dagcircuit.DAGCircuit")) – DAG to schedule.
|
||
|
||
**Returns**
|
||
|
||
A DAG with calibrations added to it.
|
||
|
||
**Return type**
|
||
|
||
[*DAGCircuit*](qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.dagcircuit.DAGCircuit")
|
||
</Function>
|
||
|
||
### supported
|
||
|
||
<Function id="qiskit.transpiler.passes.RXCalibrationBuilder.supported" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/calibration/rx_builder.py#L96-L110" signature="supported(node_op, qubits)">
|
||
Check if the calibration for SX gate exists and it’s a single DRAG pulse.
|
||
|
||
**Return type**
|
||
|
||
[bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")
|
||
</Function>
|
||
|
||
### update\_status
|
||
|
||
<Function id="qiskit.transpiler.passes.RXCalibrationBuilder.update_status" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/basepasses.py#L213-L221" signature="update_status(state, run_state)">
|
||
Update workflow status.
|
||
|
||
**Parameters**
|
||
|
||
* **state** ([*PassManagerState*](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")) – Pass manager state to update.
|
||
* **run\_state** (*RunState*) – Completion status of current task.
|
||
|
||
**Returns**
|
||
|
||
Updated pass manager state.
|
||
|
||
**Return type**
|
||
|
||
[*PassManagerState*](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")
|
||
</Function>
|
||
</Class>
|
||
|