อินพุตและเอาต์พุตของ Primitives
Package versions
The code on this page was developed using the following requirements. We recommend using these versions or newer.
qiskit[all]~=2.4.0
หน้านี้ให้ภาพรวมของอินพุตและเอาต์พุตของ Qiskit primitives ด้วย primitives เหล่านี้ คุณสามารถใช้โครงสร้างข้อมูลที่เรียกว่า Primitive Unified Bloc (PUB) เพื่อกำหนด vectorized workloads ได้อย่างมีประสิทธิภาพ PUBs เหล่านี้คือหน่วยพื้นฐานสำหรับการประมวลผล workload และใช้เป็นอินพุตของเมธอด run() สำหรับ Sampler และ Estimator primitives ซึ่งประมวลผล workload ที่กำหนดเป็น job จากนั้น หลังจาก job เสร็จสิ้น ผลลัพธ์จะถูกส่งคืนในรูปแบบที่ขึ้นอยู่กับ PUBs ที่ใช้และ options ที่ระบุ
ภาพรวมของ PUBs
เมื่อเรียกใช้เมธอด run() ของ primitive argument หลักที่ต้องใช้คือ list ของ tuple หนึ่งตัวหรือมากกว่า — หนึ่ง tuple ต่อหนึ่ง circuit ที่รัน แต่ละ tuple นี้ถือเป็น PUB และ elements ที่จำเป็นของแต่ละ tuple ในรายการขึ้นอยู่กับ primitive ที่ใช้ ข้อมูลที่ระบุใน tuples เหล่านี้ยังสามารถจัดเรียงในรูปแบบต่างๆ เพื่อให้มีความยืดหยุ่นใน workload ผ่านการ broadcasting — ซึ่งมีกฎที่อธิบายไว้ในส่วนถัดไป
Estimator PUB
สำหรับ Estimator primitive รูปแบบของ PUB ควรมีค่าไม่เกินสี่ค่า:
QuantumCircuitเดียว ซึ่งอาจมีParameterobjects หนึ่งตัวหรือมากกว่า- รายการของ observables หนึ่งตัวหรือมากกว่า ซึ่งระบุ expectation values ที่ต้องการประมาณ จัดเรียงเป็น array (เช่น observable เดียวแทนด้วย 0-d array, รายการของ observables เป็น 1-d array และอื่นๆ) ข้อมูลสามารถอยู่ในรูปแบบ
ObservablesArrayLikeใดก็ได้ เช่นPauli,SparsePauliOp,PauliListหรือstrหมายเหตุถ้ามี observables สองตัวที่ commute กันอยู่ใน PUBs ต่างกันแต่มี circuit เดียวกัน จะไม่ถูกประมาณด้วยการวัดเดียวกัน แต่ละ PUB แทน basis สำหรับการวัดที่แตกต่างกัน ดังนั้นจึงต้องมีการวัดแยกกันสำหรับแต่ละ PUB เพื่อให้แน่ใจว่า commuting observables ถูกประมาณด้วยการวัดเดียวกัน ต้องจัดกลุ่มไว้ใน PUB เดียวกัน
- ชุดของค่า parameter เพื่อ bind กับ circuit สามารถระบุเป็น array-like object เดียวที่ index สุดท้ายอยู่บน
Parameterobjects ของ circuit หรือละไว้ (หรือเทียบเท่ากับการตั้งค่าเป็นNone) ถ้า circuit ไม่มีParameterobjects - (ไม่บังคับ) ความแม่นยำเป้าหมายสำหรับ expectation values ที่ต้องการประมาณ
Sampler PUB
สำหรับ Sampler primitive รูปแบบของ PUB tuple มีค่าไม่เกินสามค่า:
QuantumCircuitเดียว ซึ่งอาจมีParameterobjects หนึ่งตัวหรือมากกว่า หมายเหตุ: Circuit เหล่านี้ต้องมีคำสั่งการวัดสำหรับแต่ละ qubit ที่ต้องการ sample ด้วย- ชุดของค่า parameter เพื่อ bind กับ circuit (จำเป็นเฉพาะเมื่อมี
Parameterobjects ที่ต้อง bind ตอน runtime) - (ไม่บังคับ) จำนวน shots สำหรับวัด circuit
โค้ดต่อไปนี้แสดงตัวอย่างชุดของ vectorized inputs ให้กับ Estimator primitive
# Added by doQumentation — required packages for this notebook
!pip install -q numpy qiskit
from qiskit.circuit import (
Parameter,
QuantumCircuit,
ClassicalRegister,
QuantumRegister,
)
from qiskit.transpiler import generate_preset_pass_manager
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives.containers import BitArray
from qiskit.primitives import StatevectorEstimator
import numpy as np
# Define a circuit with two parameters.
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.ry(Parameter("a"), 0)
circuit.rz(Parameter("b"), 0)
circuit.cx(0, 1)
circuit.h(0)
# Transpile the circuit without providing a backend
pm = generate_preset_pass_manager(optimization_level=1)
transpiled_circuit = pm.run(circuit)
layout = transpiled_circuit.layout
# Now define a sweep over parameter values, the last axis of dimension 2 is
# for the two parameters "a" and "b"
params = np.vstack(
[
np.linspace(-np.pi, np.pi, 10),
np.linspace(-4 * np.pi, 4 * np.pi, 10),
]
).T
# Define three observables. The inner length-1 lists cause this array of
# observables to have shape (3, 1), rather than shape (3,) if they were
# omitted.
observables = [
[SparsePauliOp(["XX", "IY"], [0.5, 0.5])],
[SparsePauliOp("XX")],
[SparsePauliOp("IY")],
]
# Apply the same layout as the transpiled circuit.
observables = [
[observable.apply_layout(layout) for observable in observable_set]
for observable_set in observables
]
# Estimate the expectation value for all 300 combinations of observables
# and parameter values, where the pub result will have shape (3, 100).
#
# This shape is due to our array of parameter bindings having shape
# (100, 2), combined with our array of observables having shape (3, 1).
estimator = StatevectorEstimator()
estimator_pub = (transpiled_circuit, observables, params)
# Run the transpiled circuit
# using the set of parameters and observables.
job = estimator.run([estimator_pub])
result = job.result()
A1 (1d array): 1
A2 (2d array): 3 x 5
Result (2d array): 3 x 5
A1 (3d array): 11 x 2 x 7
A2 (3d array): 11 x 1 x 7
Result (3d array): 11 x 2 x 7
A1 (1d array): 5
A2 (1d array): 3
A1 (2d array): 2 x 1
# The following would work if the middle dimension were 2,
# instead of 5.
A2 (3d array): 6 x 5 x 4
กฎการ Broadcasting
PUBs รวม elements จาก arrays หลายตัว (observables และค่า parameter) โดยทำตามกฎการ broadcasting เดียวกับ NumPy ส่วนนี้สรุปกฎเหล่านั้นโดยย่อ สำหรับคำอธิบายโดยละเอียด ดูเอกสาร NumPy broadcasting rules
กฎ:
- Input arrays ไม่จำเป็นต้องมีจำนวน dimensions เท่ากัน
- Array ผลลัพธ์จะมีจำนวน dimensions เท่ากับ input array ที่มี dimension ใหญ่ที่สุด
- ขนาดของแต่ละ dimension คือขนาดที่ใหญ่ที่สุดของ dimension ที่ตรงกัน
- Dimensions ที่หายไปถือว่ามีขนาดหนึ่ง
- การเปรียบเทียบ shape เริ่มจาก dimension ขวาสุดและดำเนินต่อไปทางซ้าย
- Dimensions สองตัวเข้ากันได้ถ้าขนาดเท่ากันหรือถ้าตัวหนึ่งเป็น 1
ตัวอย่างคู่ของ arrays ที่ broadcast ได้:
# Broadcast single observable
parameter_values = np.random.uniform(size=(5,)) # shape (5,)
observables = SparsePauliOp("ZZZ") # shape ()
# >> pub result has shape (5,)
# Zip
parameter_values = np.random.uniform(size=(5,)) # shape (5,)
observables = [
SparsePauliOp(pauli) for pauli in ["III", "XXX", "YYY", "ZZZ", "XYZ"]
] # shape (5,)
# >> pub result has shape (5,)
# Outer/Product
parameter_values = np.random.uniform(size=(1, 6)) # shape (1, 6)
observables = [
[SparsePauliOp(pauli)] for pauli in ["III", "XXX", "YYY", "ZZZ"]
] # shape (4, 1)
# >> pub result has shape (4, 6)
# Standard nd generalization
parameter_values = np.random.uniform(size=(3, 6)) # shape (3, 6)
observables = [
[
[SparsePauliOp(["XII"])],
[SparsePauliOp(["IXI"])],
[SparsePauliOp(["IIX"])],
],
[
[SparsePauliOp(["ZII"])],
[SparsePauliOp(["IZI"])],
[SparsePauliOp(["IIZ"])],
],
] # shape (2, 3, 1)
# >> pub result has shape (2, 3, 6)
ตัวอย่างคู่ของ arrays ที่ broadcast ไม่ได้:
Estimator คืน expectation value estimate หนึ่งค่าสำหรับแต่ละ element ของ shape ที่ broadcast แล้ว
นี่คือตัวอย่างของ patterns ทั่วไปที่แสดงในรูปของ array broadcasting พร้อมกับการแสดงภาพแบบ visual ในรูปถัดไป:
ชุดค่า parameter แทนด้วย n x m arrays และ observable arrays แทนด้วย single-column arrays หนึ่งตัวหรือมากกว่า สำหรับแต่ละตัวอย่างในโค้ดก่อนหน้า ชุดค่า parameter ถูกรวมกับ observable array เพื่อสร้าง expectation value estimates ที่ได้
-
ตัวอย่างที่ 1: (broadcast single observable) มีชุดค่า parameter เป็น array 5x1 และ observables array แบบ 1x1 item เดียวใน observables array ถูกรวมกับแต่ละ item ในชุดค่า parameter เพื่อสร้าง array 5x1 เดียวที่แต่ละ item เป็นการรวมกันของ item ต้นฉบับในชุดค่า parameter กับ item ใน observables array
-
ตัวอย่างที่ 2: (zip) มีชุดค่า parameter 5x1 และ observables array 5x1 ผลลัพธ์คือ array 5x1 ที่แต่ละ item เป็นการรวมกันของ item ที่ n ในชุดค่า parameter กับ item ที่ n ในชุด observables array
-
ตัวอย่างที่ 3: (outer/product) มีชุดค่า parameter 1x6 และ observables array 4x1 การรวมกันของพวกมันให้ผล array 4x6 ที่สร้างโดยการรวมแต่ละ item ในชุดค่า parameter กับ ทุก item ใน observables array ดังนั้นแต่ละค่า parameter จึงกลายเป็นคอลัมน์ทั้งคอลัมน์ในผลลัพธ์
-
ตัวอย่างที่ 4: (Standard nd generalization) มีชุดค่า parameter array 3x6 และ observables array สองตัวแบบ 3x1 พวกมันรวมกันเพื่อสร้าง output arrays 3x6 สองตัวในลักษณะเดียวกับตัวอย่างก่อนหน้า
แต่ละ SparsePauliOp นับเป็น element เดียวในบริบทนี้ โดยไม่คำนึงถึงจำนวน Paulis ที่มีอยู่ใน SparsePauliOp ดังนั้น สำหรับจุดประสงค์ของกฎ broadcasting เหล่านี้ elements ต่อไปนี้ทั้งหมดมี shape เดียวกัน:
a = SparsePauliOp("Z") # shape ()
b = SparsePauliOp("IIIIZXYIZ") # shape ()
c = SparsePauliOp.from_list(["XX", "XY", "IZ"]) # shape ()
รายการของ operators ต่อไปนี้ แม้จะเทียบเท่ากันในแง่ของข้อมูลที่มีอยู่ มี shape ต่างกัน:
list1 = SparsePauliOp.from_list(["XX", "XY", "IZ"])
# list1 has shape ()
list2 = [SparsePauliOp("XX"), SparsePauliOp("XY"), SparsePauliOp("IZ")]
# list2 has shape (3, )
ภาพรวมของ primitive outputs
เมื่อส่ง PUBs หนึ่งตัวหรือมากกว่าไปยัง QPU เพื่อประมวลผลและ job เสร็จสิ้นสำเร็จ ข้อมูลจะถูกส่งคืนในรูปแบบ PrimitiveResult container object PrimitiveResult มี iterable list ของ PubResult objects ที่มีผลลัพธ์การประมวลผลสำหรับแต่ละ PUB ตัวอย่างเช่น job ที่ส่งพร้อม 20 PUBs จะคืน PrimitiveResult object ที่มีรายการ 20 PubResult หนึ่งตัวตรงกับแต่ละ PUB
แต่ละ PubResult objects เหล่านี้มีทั้ง data และ metadata attribute แบบ optional data attribute คือ DataBin แบบกำหนดเองที่มี expectation value estimates ในกรณีของ Estimator หรือ samples ของ circuit output ในกรณีของ Sampler
data attribute อาจมีข้อมูลเฉพาะ implementation อื่นๆ ด้วย เช่น ค่าเบี่ยงเบนมาตรฐาน metadata attribute อาจมีข้อมูลเฉพาะ implementation เพิ่มเติมเกี่ยวกับการประมวลผลของ PUB ที่เกี่ยวข้อง
นี่คือโครงร่างภาพของโครงสร้างข้อมูล PrimitiveResult:
- Estimator output
- Sampler output
└── PrimitiveResult
├── PubResult[0]
│ ├── metadata
│ └── data ## In the form of a DataBin object,
| | ## which includes data such as the following:
│ ├── evs
│ │ └── List of estimated expectation values in the shape
| | specified by the first pub
│ └── stds
│ └── List of calculated standard deviations in the
| same shape as above
├── PubResult[1]
| ├── metadata
| └── data ## In the form of a DataBin object,
| | ## which includes data such as the following:
| ├── evs
| │ └── List of estimated expectation values in the shape
| | specified by the second pub
| └── stds
| └── List of calculated standard deviations in the
| same shape as above
├── ...
├── ...
└── ...
The above is an example of data that might be returned. The actual data returned depends on the implementation.
└── PrimitiveResult
├── PubResult[0]
│ ├── metadata
│ └── data ## In the form of a DataBin object
│ ├── NAME_OF_CLASSICAL_REGISTER
│ │ └── BitArray of count data for first PUB (default is 'meas')
| |
│ └── NAME_OF_ANOTHER_CLASSICAL_REGISTER
│ └── BitArray of count data (exists only if more than one
| ClassicalRegister was specified in the circuit)
├── PubResult[1]
| ├── metadata
| └── data ## In the form of a DataBin object
| └── NAME_OF_CLASSICAL_REGISTER
| └── BitArray of count data for second PUB
├── ...
├── ...
└── ...
Estimator output
ตามที่กล่าวไว้ก่อนหน้า ข้อมูลที่ส่งคืนใน PubResult สำหรับ Estimator primitive ขึ้นอยู่กับ implementation ตัวอย่างเช่น อาจมี array ของ expectation values (PubResult.data.evs) และค่าเบี่ยงเบนมาตรฐานที่เกี่ยวข้อง (PubResult.data.stds)
โค้ดด้านล่างอธิบายรูปแบบ PrimitiveResult (และ PubResult ที่เกี่ยวข้อง) สำหรับ job ที่สร้างด้านบน
print(
f"The result of the submitted job had {len(result)} PUB and "
f"has a value:\n {result}\n"
)
print(
f"The associated PubResult of this job has the following data bins:"
f"\n {result[0].data}\n"
)
print(f"And this DataBin has attributes: {result[0].data.keys()}")
print(
"Recall that this shape is due to our array of parameter binding sets "
"having shape (100, 2) -- where 2 is the number of parameters in the circuit -- "
"combined with our array of observables having shape (3, 1)."
)
print(
f"The expectation values measured from this PUB are: \n{result[0].data.evs}"
)
The result of the submitted job had 1 PUB and has a value:
PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(3, 10), dtype=float64>), stds=np.ndarray(<shape=(3, 10), dtype=float64>), shape=(3, 10)), metadata={'target_precision': 0.0, 'circuit_metadata': {}})], metadata={'version': 2})
The associated PubResult of this job has the following data bins:
DataBin(evs=np.ndarray(<shape=(3, 10), dtype=float64>), stds=np.ndarray(<shape=(3, 10), dtype=float64>), shape=(3, 10))
And this DataBin has attributes: dict_keys(['evs', 'stds'])
Recall that this shape is due to our array of parameter binding sets having shape (100, 2) -- where 2 is the
number of parameters in the circuit -- combined with our array of observables having shape (3, 1).
The expectation values measured from this PUB are:
[[ 3.06161700e-16 4.52395120e-01 4.36594428e-01 2.16506351e-01
6.33718361e-01 -6.33718361e-01 -2.16506351e-01 -4.36594428e-01
-4.52395120e-01 -3.06161700e-16]
[ 1.22464680e-16 6.42787610e-01 9.84807753e-01 8.66025404e-01
3.42020143e-01 -3.42020143e-01 -8.66025404e-01 -9.84807753e-01
-6.42787610e-01 -1.22464680e-16]
[ 4.89858720e-16 2.62002630e-01 -1.11618897e-01 -4.33012702e-01
9.25416578e-01 -9.25416578e-01 4.33012702e-01 1.11618897e-01
-2.62002630e-01 -4.89858720e-16]]
Sampler output
เมื่อ Sampler job เสร็จสิ้นสำเร็จ PrimitiveResult object ที่ส่งคืนมีรายการของ SamplerPubResult หนึ่งตัวต่อ PUB data bins ของ SamplerPubResult objects เหล่านี้เป็น dict-like objects ที่มี BitArray หนึ่งตัวต่อ ClassicalRegister ใน circuit
คลาส BitArray เป็น container สำหรับข้อมูล shot แบบเรียงลำดับ โดยละเอียดคือจัดเก็บ bitstrings ที่ sample มาเป็น bytes ภายใน array สองมิติ แกนซ้ายสุดของ array นี้วิ่งผ่าน ordered shots ส่วนแกนขวาสุดวิ่งผ่าน bytes
เป็นตัวอย่างแรก มาดู ten-qubit circuit ต่อไปนี้:
from qiskit.primitives import StatevectorSampler
# generate a ten-qubit GHZ circuit
circuit = QuantumCircuit(10)
circuit.h(0)
circuit.cx(range(0, 9), range(1, 10))
# append measurements with the `measure_all` method
circuit.measure_all()
# transpile the circuit
transpiled_circuit = pm.run(circuit)
sampler = StatevectorSampler()
# run the Sampler job and retrieve the results
job = sampler.run([transpiled_circuit])
result = job.result()
# the data bin contains one BitArray
data = result[0].data
print(f"Databin: {data}\n")
# to access the BitArray, use the key "meas", which is the default name of
# the classical register when this is added by the `measure_all` method
array = data.meas
print(f"BitArray: {array}\n")
print(f"The shape of register `meas` is {data.meas.array.shape}.\n")
print(f"The bytes in register `alpha`, shot by shot:\n{data.meas.array}\n")
Databin: DataBin(meas=BitArray(<shape=(), num_shots=1024, num_bits=10>))
BitArray: BitArray(<shape=(), num_shots=1024, num_bits=10>)
The shape of register `meas` is (1024, 2).
The bytes in register `alpha`, shot by shot:
[[ 0 0]
[ 3 255]
[ 0 0]
...
[ 3 255]
[ 3 255]
[ 3 255]]
บางครั้งการแปลงจากรูปแบบ bytes ใน BitArray เป็น bitstrings อาจสะดวกกว่า เมธอด get_count คืน dictionary ที่ mapping bitstrings ไปยังจำนวนครั้งที่เกิดขึ้น
# optionally convert the native BitArray format to a dictionary format
counts = data.meas.get_counts()
print(f"Counts: {counts}")
Counts: {'0000000000': 492, '1111111111': 532}
เมื่อ circuit มีมากกว่าหนึ่ง classical register ผลลัพธ์จะถูกจัดเก็บใน BitArray objects ต่างกัน ตัวอย่างต่อไปนี้ปรับ snippet ก่อนหน้าโดยแบ่ง classical register เป็นสอง registers ที่แตกต่างกัน:
# generate a ten-qubit GHZ circuit with two classical registers
circuit = QuantumCircuit(
qreg := QuantumRegister(10),
alpha := ClassicalRegister(1, "alpha"),
beta := ClassicalRegister(9, "beta"),
)
circuit.h(0)
circuit.cx(range(0, 9), range(1, 10))
# append measurements with the `measure_all` method
circuit.measure([0], alpha)
circuit.measure(range(1, 10), beta)
# transpile the circuit
transpiled_circuit = pm.run(circuit)
# run the Sampler job and retrieve the results
job = sampler.run([transpiled_circuit])
result = job.result()
# the data bin contains two BitArrays, one per register, and can be accessed
# as attributes using the registers' names
data = result[0].data
print(f"BitArray for register 'alpha': {data.alpha}")
print(f"BitArray for register 'beta': {data.beta}")
BitArray for register 'alpha': BitArray(<shape=(), num_shots=1024, num_bits=1>)
BitArray for register 'beta': BitArray(<shape=(), num_shots=1024, num_bits=9>)
print(f"The shape of register `alpha` is {data.alpha.array.shape}.")
print(f"The bytes in register `alpha`, shot by shot:\n{data.alpha.array}\n")
print(f"The shape of register `beta` is {data.beta.array.shape}.")
print(f"The bytes in register `beta`, shot by shot:\n{data.beta.array}\n")
# post-select the bitstrings of `beta` based on having sampled "1" in `alpha`
mask = data.alpha.array == "0b1"
ps_beta = data.beta[mask[:, 0]]
print(f"The shape of `beta` after post-selection is {ps_beta.array.shape}.")
print(f"The bytes in `beta` after post-selection:\n{ps_beta.array}")
# get a slice of `beta` to retrieve the first three bits
beta_sl_bits = data.beta.slice_bits([0, 1, 2])
print(
f"The shape of `beta` after bit-wise slicing is {beta_sl_bits.array.shape}."
)
print(f"The bytes in `beta` after bit-wise slicing:\n{beta_sl_bits.array}\n")
# get a slice of `beta` to retrieve the bytes of the first five shots
beta_sl_shots = data.beta.slice_shots([0, 1, 2, 3, 4])
print(
f"The shape of `beta` after shot-wise slicing is {beta_sl_shots.array.shape}."
)
print(
f"The bytes in `beta` after shot-wise slicing:\n{beta_sl_shots.array}\n"
)
# calculate the expectation value of diagonal operators on `beta`
ops = [SparsePauliOp("ZZZZZZZZZ"), SparsePauliOp("IIIIIIIIZ")]
exp_vals = data.beta.expectation_values(ops)
for o, e in zip(ops, exp_vals):
print(f"Exp. val. for observable `{o}` is: {e}")
# concatenate the bitstrings in `alpha` and `beta` to "merge" the results
# of the two registers
merged_results = BitArray.concatenate_bits([data.alpha, data.beta])
print(f"\nThe shape of the merged results is {merged_results.array.shape}.")
print(f"The bytes of the merged results:\n{merged_results.array}\n")
การใช้ประโยชน์จาก BitArray objects เพื่อการ post-processing ที่มีประสิทธิภาพ
เนื่องจาก arrays โดยทั่วไปให้ประสิทธิภาพที่ดีกว่าเมื่อเทียบกับ dictionaries จึงแนะนำให้ทำ post-processing ใดๆ บน BitArray objects โดยตรงแทนที่จะทำบน dictionaries ของ counts คลาส BitArray มีเมธอดหลายอย่างสำหรับทำ post-processing operations ทั่วไป:
The shape of register `alpha` is (1024, 1).
The bytes in register `alpha`, shot by shot:
[[1]
[1]
[1]
...
[0]
[0]
[1]]
The shape of register `beta` is (1024, 2).
The bytes in register `beta`, shot by shot:
[[ 1 255]
[ 1 255]
[ 1 255]
...
[ 0 0]
[ 0 0]
[ 1 255]]
The shape of `beta` after post-selection is (0, 2).
The bytes in `beta` after post-selection:
[]
The shape of `beta` after bit-wise slicing is (1024, 1).
The bytes in `beta` after bit-wise slicing:
[[7]
[7]
[7]
...
[0]
[0]
[7]]
The shape of `beta` after shot-wise slicing is (5, 2).
The bytes in `beta` after shot-wise slicing:
[[ 1 255]
[ 1 255]
[ 1 255]
[ 1 255]
[ 1 255]]
Exp. val. for observable `SparsePauliOp(['ZZZZZZZZZ'],
coeffs=[1.+0.j])` is: -0.017578125
Exp. val. for observable `SparsePauliOp(['IIIIIIIIZ'],
coeffs=[1.+0.j])` is: -0.017578125
The shape of the merged results is (1024, 2).
The bytes of the merged results:
[[ 3 255]
[ 3 255]
[ 3 255]
...
[ 0 0]
[ 0 0]
[ 3 255]]
ข้อมูล metadata ของผลลัพธ์
นอกจากผลลัพธ์การประมวลผล PrimitiveResult และ PubResult objects ยังมี metadata attribute แบบ optional เกี่ยวกับ job ที่ส่งไป metadata ที่ส่งคืน (ถ้ามี) ขึ้นอยู่กับ implementation
# Print out the results metadata
print("The metadata of the PrimitiveResult is:")
for key, val in result.metadata.items():
print(f"'{key}' : {val},")
print("\nThe metadata of the PubResult result is:")
for key, val in result[0].metadata.items():
print(f"'{key}' : {val},")
The metadata of the PrimitiveResult is:
'version' : 2,
The metadata of the PubResult result is:
'shots' : 1024,
'circuit_metadata' : {},
ขั้นตอนถัดไป
- ดู API ของ Qiskit primitives
- ดู API ของ Qiskit Aer primitives
- เรียนรู้เพิ่มเติมเกี่ยวกับ Qiskit Runtime primitives
- ดู API ของ Qiskit Runtime Estimator
- ดู API ของ Qiskit Runtime Sampler