[Bug] create_empty_circuit() without num_qubits behaves differently per backend

Open
#1,510 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@Howardisme is already working on this.

Since Oct 22, 2026.

  • #1561 by @Howardisme — open
  • #1575 by @Howardisme — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with create_empty_circuit() in qumat/qumat.py, then compare how the Qiskit, Cirq and Braket backends in qumat/ allocate qubits when num_qubits is missing. The issue leaves open whether to raise a ValueError or allocate on demand, so confirm the choice with maintainers before editing. Done when all three backends behave the same way and tests covering that behavior pass on each.

Written by the indexing model from the issue text.

Description

bug docs enhancement good-first-issue qumat
What

QuMat.create_empty_circuit() without num_qubits behaves differently on each backend:

qc.create_empty_circuit()
qc.apply_hadamard_gate(0)
# qiskit:        CircuitError: 'Index 0 out of range for size 0.'
# cirq / braket: ok, the qubit is allocated on demand

Actual result: code that runs on Cirq and Braket crashes on Qiskit with a low-level error, so the "write once, run on any backend" promise does not hold for this case.

Expected result: one documented behavior shared by all three backends. The quick option is a clear ValueError from QuMat.create_empty_circuit() when num_qubits is missing (or not a positive integer). Alternatively, allocate qubits on demand everywhere, but that is more work on the Qiskit side.

Where: qumat/qumat.py and the three backends in qumat/. Add tests covering the chosen behavior on all backends.

Environment
  • OS: macOS 14 / Linux
  • Python version: 3.12
  • Qumat version: 0.6.0 (PyPI) and main at 2d94f8fbd

Part of the Apache Mahout hackathon at Community over Code Glasgow 2026 (Track A, Qumat). Comment here to claim it.

Dominant language
Rust
Stars
2.3k
Forks
1k
Avg merge
2d 20h
Merged PRs (30d)
7

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/mahout

All issues in apache/mahout

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.