IBM Circuit function
Tingnan ang API reference
- Ang Qiskit Functions ay isang experimental na feature na available lamang sa mga gumagamit ng IBM Quantum® Premium Plan, Flex Plan, at On-Prem (sa pamamagitan ng IBM Quantum Platform API) Plan. Nasa preview release status ito at maaaring magbago.
Pangkalahatang-ideya​
Ang IBM® Circuit function ay tumatanggap ng abstract PUBs bilang mga input, at nagbabalik ng mitigated na expectation values bilang mga output. Kasama sa circuit function na ito ang isang automated at customized na pipeline para makapag-focus ang mga mananaliksik sa pag-discover ng algorithm at application.
Paglalarawan​
Pagkatapos mag-submit ng PUB, ang iyong mga abstract circuit at observable ay awtomatikong tina-transpile, pinatatakbo sa hardware, at nipo-post-process para ibalik ang mitigated na expectation values. Para magawa ito, pinagsama ang mga sumusunod na kagamitan:
- Qiskit Transpiler Service, kasama ang auto-selection ng AI-driven at heuristic na transpilation passes para i-translate ang iyong mga abstract circuit sa hardware-optimized na ISA circuits
- Error suppression at mitigation na kailangan para sa utility-scale na computation, kasama ang measurement at gate twirling, dynamical decoupling, Twirled Readout Error eXtinction (TREX), Zero-Noise Extrapolation (ZNE), at Probabilistic Error Amplification (PEA)
- Qiskit Runtime Estimator, para patakbuhin ang mga ISA PUB sa hardware at ibalik ang mitigated na expectation values
Pagsisimula​
Mag-authenticate gamit ang iyong API key at piliin ang Qiskit Function tulad ng sumusunod. (Ipinapalagay ng snippet na ito na nai-save mo na ang iyong account sa iyong lokal na environment.)
# Added by doQumentation — required packages for this notebook
!pip install -q qiskit qiskit-ibm-catalog qiskit-ibm-runtime
from qiskit_ibm_catalog import QiskitFunctionsCatalog
catalog = QiskitFunctionsCatalog(channel="ibm_quantum_platform")
function = catalog.load("ibm/circuit-function")
Mga Halimbawa​
Para makapagsimula, subukan ang basic na halimbawang ito:
from qiskit.circuit.random import random_circuit
from qiskit_ibm_runtime import QiskitRuntimeService
# You can skip this step if you have a target backend, e.g.
# backend_name = "ibm_brisbane"
# You'll need to specify the credentials when initializing QiskitRuntimeService, if they were not previously saved.
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
circuit = random_circuit(num_qubits=2, depth=2, seed=42)
observable = "Z" * circuit.num_qubits
pubs = [(circuit, observable)]
job = function.run(
# Use `backend_name=backend_name` if you didn't initialize a backend object
backend_name=backend.name,
pubs=pubs,
)
Tingnan ang status ng iyong Qiskit Function workload o kunin ang mga resulta tulad ng sumusunod:
print(job.status())
result = job.result()
QUEUED
Ang mga resulta ay nasa parehong format ng isang Estimator result:
print(f"The result of the submitted job had {len(result)} PUB\n")
print(
f"The associated PubResult of this job has the following DataBins:\n {result[0].data}\n"
)
print(f"And this DataBin has attributes: {result[0].data.keys()}")
print(
f"The expectation values measured from this PUB are: \n{result[0].data.evs}"
)
The result of the submitted job had 1 PUB
The associated PubResult of this job has the following DataBins:
DataBin(evs=np.ndarray(<shape=(), dtype=float64>), stds=np.ndarray(<shape=(), dtype=float64>), ensemble_standard_error=np.ndarray(<shape=(), dtype=float64>))
And this DataBin has attributes: dict_keys(['evs', 'stds', 'ensemble_standard_error'])
The expectation values measured from this PUB are:
1.02116704805492
Mga halimbawa ng mitigation level​
Ipinapakita ng sumusunod na halimbawa ang pagtatakda ng mitigation level:
options = {"mitigation_level": 2}
job = function.run(backend_name=backend.name, pubs=pubs, options=options)
Sa sumusunod na halimbawa, ang pagtatakda ng mitigation level sa 1 ay unang nag-a-off ng ZNE mitigation, ngunit ang pagtatakda ng zne_mitigation sa True ay nino-override ang kaugnay na setup mula sa mitigation_level.
options = {"mitigation_level": 1, "resilience": {"zne_mitigation": True}}
Halimbawa ng output​
Inilalarawan ng sumusunod na code snippet ang format ng PrimitiveResult (at kaugnay na PubResult).
print(f"The result of the submitted job had {len(result)} PUB")
print(
f"The expectation values measured from this PUB are: \n{result[0].data.evs}"
)
print(f"And the associated metadata is: \n{result[0].metadata}")
The result of the submitted job had 1 PUB
The expectation values measured from this PUB are:
1.02116704805492
And the associated metadata is:
{'shots': 4096, 'target_precision': 0.015625, 'circuit_metadata': {}, 'resilience': {}, 'num_randomizations': 32}
Kunin ang mga mensahe ng error​
Kung ang status ng iyong workload ay ERROR, gamitin ang job.result() para kunin ang mensahe ng error para makatulong sa pag-debug tulad ng sumusunod:
job = function.run(
backend_name="bad_backend_name", pubs=pubs, options=options
)
print(job.result())
Kumuha ng suporta​
Makipag-ugnayan sa IBM Quantum support, at isama ang sumusunod na impormasyon:
- Qiskit Function Job ID (
qiskit-ibm-catalog),job.job_id - Isang detalyadong paglalarawan ng isyu
- Anumang kaugnay na mensahe o code ng error
- Mga hakbang para muling mapalabas ang isyu
Mga Susunod na Hakbang​
- Subukan ang tutorial na Error mitigation gamit ang IBM Circuit function.
- Bisitahin ang API reference para sa Qiskit Function na ito.