Skip to content

Fix undefined 'backend' in IBMQ getting-started example - #2251

Merged
cqc-alec merged 2 commits into
Quantinuum:mainfrom
neonlight0123:fix/getting-started-ibmq-run-device
Oct 1, 2026
Merged

cqc-alec merged 2 commits into
Quantinuum:mainfrom
neonlight0123:fix/getting-started-ibmq-run-device

Conversation

@neonlight0123

Copy link
Copy Markdown
Contributor

Fix undefined backend in the IBMQ getting-started example

In pytket/docs/getting_started.md, the IBMQ example declares a nairobi_device but then calls backend.run_circuit(...) — a variable that is not defined in that code block:

nairobi_device = IBMQBackend('ibm_nairobi')

# Compile Circuit to use supported gates of IBMQ Nairobi
compiled_circ = nairobi_device.get_compiled_circuit(circ)
result = backend.run_circuit(compiled_circ, n_shots=100)   # `backend` is undefined here

Running the guide top-to-bottom makes it NameError, or worse, silently runs the IBMQ-compiled circuit on the AerBackend that leaks from the earlier Aer example. The intended execution target is nairobi_device:

result = nairobi_device.run_circuit(compiled_circ, n_shots=100)

Verification:

  • Confirmed on current main (2d03cce) that backend is undefined in this code block and nairobi_device is the only backend in scope.
  • Confirmed the installed pytket.extensions.qiskit.IBMQBackend exposes both get_compiled_circuit and run_circuit, so the fix is valid API usage.
  • No other backend misuse appears elsewhere in getting_started.md (the Aer example above legitimately defines backend = AerBackend()).

Doc-only change; no code, no version bump required.

The IBMQ example declares 'nairobi_device' but then calls
'backend.run_circuit(...)', which is not defined in that code block (it
happens to resolve only by leaking the AerBackend from the earlier Aer
example). Run the compiled circuit on 'nairobi_device' instead.
@cqc-alec
cqc-alec self-requested a review October 1, 2026 15:12
@cqc-alec
cqc-alec merged commit af8b859 into Quantinuum:main Oct 1, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants