You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Metadata passed through jobs run with SamplerV2 on a fake backend (or AerSimulator) is in a different format to that received from SamplerV2 on real backends.
After issue #1551 and PR #1596 , circuit metadata is retained in the PrimitiveResult, but it lives in the top-level metadata attribute, and not the circuit_metadata key within this attribute as is the case with real backends.
Steps to reproduce
Run a simple circuit with metadata attached on fake backend and real backend using SamplerV2 primitive:
fromqiskit.circuitimportQuantumCircuitfromqiskit.transpiler.preset_passmanagersimportgenerate_preset_pass_managerfromqiskit_ibm_runtimeimportSamplerV2asSampler, QiskitRuntimeServicefromqiskit_ibm_runtime.fake_providerimportFakeBrisbane# Bell Circuitqc=QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
qc.metadata= {0: 1}
# Run the sampler job locally using FakeBrisbanefake_brisbane=FakeBrisbane()
pm=generate_preset_pass_manager(backend=fake_brisbane, optimization_level=0)
isa_qc=pm.run(qc)
print(f'circuit metadata: {isa_qc.metadata}')
# You can use a fixed seed to get fixed results.options= {"simulator": {"seed_simulator": 42}}
sampler=Sampler(backend=fake_manila, options=options)
result=sampler.run([isa_qc]).result()
print(f'fake result metadata: {result[0].metadata}')
# Run on real device and compare metadata passthroughservice=QiskitRuntimeService()
backend=service.get_backend("ibm_brisbane")
sampler=Sampler(backend=backend)
job=sampler.run([isa_qc])
result=job.result(timeout=300)
print(f'real result metadata: {result[0].metadata}')
circuit metadata: {0: 1}
fake result metadata: {0: 1}
real result metadata: {'circuit_metadata': {'0': 1}}
Expected behavior
Fake and real result metadata dictionaries should be the same, with the injected circuit metadata living in the circuit_metadata key.
Suggested solutions
Modify changes introduced in #1596 to place the metadata:
Describe the bug
Metadata passed through jobs run with
SamplerV2
on a fake backend (orAerSimulator
) is in a different format to that received fromSamplerV2
on real backends.After issue #1551 and PR #1596 , circuit metadata is retained in the
PrimitiveResult
, but it lives in the top-levelmetadata
attribute, and not thecircuit_metadata
key within this attribute as is the case with real backends.Steps to reproduce
Run a simple circuit with metadata attached on fake backend and real backend using
SamplerV2
primitive:Expected behavior
Fake and real result metadata dictionaries should be the same, with the injected circuit metadata living in the
circuit_metadata
key.Suggested solutions
Modify changes introduced in #1596 to place the metadata:
Additional Information
The text was updated successfully, but these errors were encountered: