ระบุ Executor options
เวอร์ชันแพ็กเกจ
โค้ดในหน้านี้พัฒนาโดยใช้ requirements ต่อไปนี้ แนะนำให้ใช้เวอร์ชันเหล่านี้หรือใหม่กว่า
qiskit-ibm-runtime~=0.50.0
คุณสามารถใช้ options เพื่อปรับแต่ง Executor primitive ได้ ต่างจาก Sampler และ Estimator ตรงที่ Executor มี options น้อยมาก เนื่องจากเจตนาการออกแบบส่วนใหญ่ถูกเข้ารหัสไว้ใน samplex
-
คุณสามารถดู options ที่มีและอัปเดตค่า option ระหว่างหรือหลัง primitive initialization
-
ใช้เมธอด
update()เพื่อใช้การเปลี่ยนแปลงกับ attributeoptions -
Attribute
optionsเป็นประเภทdataclassPython คุณสามารถใช้เมธอดasdictในตัวเพื่อแปลงเป็น dictionary -
Executor สามารถประมวลผลข้อมูลที่เข้ารหัสใน samplexes ได้เท่านั้น ดู Samplomatic guides เพื่อทำความเข้าใจข้อจำกัด
ตั้งค่า Executor options
ถ้า option ถูกระบุทั้งระหว่างและหลัง primitive initialization ค่าที่ตั้งหลังจาก initialize primitive จะถูกใช้
Primitive initialization
คุณสามารถส่ง instance ของ options class หรือ dictionary เมื่อ initialize Executor ซึ่งจะทำสำเนาของ options เหล่านั้น ดังนั้น การเปลี่ยน dictionary หรือ options instance ดั้งเดิมจะไม่มีผลต่อ options ที่ primitive เป็นเจ้าของ
คลาส Options
เมื่อสร้าง instance ของ class Executor คุณสามารถส่ง instance ของ options class Options เหล่านั้นจะถูกใช้เมื่อคุณใช้ run() เพื่อทำการคำนวณ ระบุ options ในรูปแบบนี้: options.option.sub-option.sub-sub-option = choice ตัวอย่างเช่น: options.environment.log_level = INFO
ตัวอย่าง:
# Added by doQumentation — installs the packages this notebook needs if they are missing
import importlib.util
_needed = {"qiskit_ibm_runtime": "qiskit-ibm-runtime"}
_missing = [pip for module, pip in _needed.items()
if importlib.util.find_spec(module) is None]
# One at a time, so a package that fails to install does not block the others
for _pip in _missing:
%pip install -q {_pip}
if not _missing:
print("\u2713 All required packages are installed")
from qiskit_ibm_runtime import QiskitRuntimeService, Executor
from qiskit_ibm_runtime.options_models import ExecutorOptions
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
options = ExecutorOptions(
environment={"log_level": "INFO"},
execution={"init_qubits": True},
)
# or use the following instead:
options = ExecutorOptions()
options.environment.log_level = "INFO"
options.execution.init_qubits = True
executor = Executor(mode=backend, options=options)
Dictionary
คุณสามารถระบุ options เป็น dictionary เมื่อ initialize Executor
from qiskit_ibm_runtime import QiskitRuntimeService, Executor
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
# Setting options during primitive initialization
executor = Executor(
backend,
options={
"environment": {"log_level": "INFO"},
"execution": {"init_qubits": True},
},
)
Options ที่มีให้ใช้
ตารางต่อไปนี้บันทึก options จากเวอร์ชันล่าสุดของ qiskit-ibm-runtime เพื่อดู option versions เก่ากว่า โปรดไปที่ qiskit-ibm-runtime API reference และเลือกเวอร์ชันก่อนหน้า
environment
environment.job_tags
รายการ tags
ตัวเลือก: None
ค่าเริ่มต้น: None
environment.log_level
ตัวเลือก: DEBUG, INFO, WARNING, ERROR, CRITICAL
ค่าเริ่มต้น: WARNING
environment.private
ตัวเลือก: True, False
ค่าเริ่มต้น: False
environment.max_execution_time
ตัวเลือก: จำนวนวินาที (integer) ในช่วง [1, 10800]
ค่าเริ่มต้น: 10800 (3 ชั่วโมง)
execution
execution.init_qubits
ว่าจะ reset qubits กลับสู่ ground state สำหรับแต่ละ shot หรือไม่
ตัวเลือก: True, False
ค่าเริ่มต้น: True
execution.rep_delay
ความล่าช้าระหว่างการวัดและ quantum circuit ถัดไป
ตัวเลือก: ค่าในช่วงที่ให้โดย backend.rep_delay_range
ค่าเริ่มต้น: ให้โดย backend.default_rep_delay
execution.meas_type
ตัวเลือก: classified, kerneled, avg_kerneled
ค่าเริ่มต้น: classified
experimental
Experimental options เมื่อมีให้ใช้
ขั้นตอนถัดไป
- ทบทวนเอกสาร API ExecutionOptionsV2
- ทบทวนเอกสาร API EnvironmentOptions