Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circuit metadata is missing from Sampler results on fake backend #1551

Closed
kielpins-qctrl opened this issue Mar 25, 2024 · 1 comment · Fixed by #1596
Closed

Circuit metadata is missing from Sampler results on fake backend #1551

kielpins-qctrl opened this issue Mar 25, 2024 · 1 comment · Fixed by #1596
Assignees
Labels
bug Something isn't working
Milestone

Comments

@kielpins-qctrl
Copy link

Describe the bug

When running a circuit via SamplerV2 on a real QPU, the PubResult corresponding to the circuit contains a metadata attribute that reproduces the original circuit metadata. However, when running that circuit on a fake backend, the metadata attribute is not present in the PubResult.

Steps to reproduce

Run the script below. The script duplicates the example script in the fake backend documentation and simply adds metadata to the circuit. The first print line correctly prints the circuit metadata, which survives transpilation. The second print line prints an empty dictionary, rather than the circuit metadata.

from qiskit.circuit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import SamplerV2 as Sampler
from qiskit_ibm_runtime.fake_provider import FakeManilaV2

# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
qc.metadata = {0: 1}

# Run the sampler job locally using FakeManilaV2
fake_manila = FakeManilaV2()
pm = generate_preset_pass_manager(backend=fake_manila, 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'circuit metadata: {result.metadata}')

Expected behavior

Retain circuit metadata in SamplerV2 when running fake backend, identically to behaviour on real QPU.

  • qiskit-ibm-runtime version: 0.22.0
  • Python version: 3.11.6
  • Operating system: macOS Sonoma 14.4
@kielpins-qctrl
Copy link
Author

The same issue occurs when using the AerSimulator migration script here. Happy to file a separate ticket if that is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants