דלג לתוכן הראשי
פרויקט זה בשלב בטא. מצאת באג? פתח issue ב-GitHub. יש שאלה או רעיון? שאל ב-Discussions — נשמח לשמוע ממך!
מה איכות התרגום בדף זה?

ארגון וחיפוש לפי תגיות משימה

גרסאות חבילות

הקוד בדף זה פותח עם הגרסאות הבאות. אנחנו ממליצים להשתמש בגרסאות אלה או בגרסאות חדשות יותר.

qiskit[all]~=2.3.1
qiskit-ibm-runtime~=0.45.1

מדריך זה מסביר איך להוסיף ולעדכן תגיות משימה ואיך לחפש לפיהן, כדי שיהיה לכם קל יותר לארגן, לעקוב ולהבין את הניסויים שלכם.

הקצאת תגיות​

ניתן להקצות תגית אחת או יותר למשימות שלך בעת הרצתן, כדי שתוכל לסנן לפי תגית מאוחר יותר. ייתכן שתרצה להשתמש בתגיות משימה כדי לסמן הגדרות מיתון שגיאות מסוימות, פרמטרים של Circuit, וכדומה.

# Added by doQumentation — installs the packages this notebook needs if they are missing
import importlib.util

_needed = {"qiskit": "qiskit", "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, Sampler
from qiskit import QuantumCircuit
from qiskit.transpiler import generate_preset_pass_manager

service = QiskitRuntimeService()
backend = service.least_busy(simulator=False, operational=True)

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

sampler = Sampler(backend)

pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(qc)

# Assign tags before executing
sampler.options.environment.job_tags = ["experiment-2025", "sampler-example"]

# Submit
job = sampler.run([isa_circuit])

print(service.job(job.job_id()).tags)
['experiment-2025', 'sampler-example']

הוספה ועדכון של תגיות​

ניתן להוסיף תגיות לאחר שליחת משימה באמצעות המתודה update_tags(). מתודה זו מחליפה את התגיות הנוכחיות, לכן אם כבר הקצית תגיות למשימה ואתה רוצה להוסיף תגיות נוספות, הקפד להקצות מחדש גם את התגיות המקוריות.

# Add a new tag while keeping the previously assigned tags
job.update_tags(["experiment-2025", "sampler-example", "127-qubit"])

# Confirm updated tags
print(job.tags)
['sampler-example', '127-qubit', 'experiment-2025']

אחזור משימות לפי תגית​

הצג רשימת משימות עם תגיות מסוימות כך:

# List jobs with a specific tag or set of tags

service.jobs(job_tags=["experiment-2025", "sampler-example"])
[<RuntimeJobV2('d76cmj5bjrds73edf2og', 'sampler')>,
<RuntimeJobV2('d6r5u84u243c73a11mug', 'sampler')>,
<RuntimeJobV2('d6hugq2thhns7392lovg', 'sampler')>,
<RuntimeJobV2('d68n7qtbujdc73d1b3vg', 'sampler')>,
<RuntimeJobV2('d674nppv6o8c73d514fg', 'sampler')>,
<RuntimeJobV2('d61mt5bc4tus73fcf3ng', 'sampler')>,
<RuntimeJobV2('d61lhfqo8gvs73f15d30', 'sampler')>,
<RuntimeJobV2('d5vftt1mvbjc73acdgpg', 'sampler')>,
<RuntimeJobV2('d5k96nv853es738djj30', 'sampler')>,
<RuntimeJobV2('d5b1s2rht8fs73a66r80', 'sampler')>]