Braket backend: circuit mutation and NumPy scalar parity bugs
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 1/100
Direzione di ricerca
The issue says both fixes are in qumat/amazon_braket_backend.py and regression tests are in testing/qumat/test_amazon_braket_backend.py. Start by reading the tests and backend changes; run the testing/qumat suite to check the circuit-copy and NumPy scalar cases. Done means the tests pass and state-vector inspection leaves the caller's circuit usable for shot-based execution.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Title: [Qumat] Fix two Braket backend parity bugs: circuit mutation and NumPy scalars
Purpose of PR
Two common patterns work on Qiskit and Cirq but fail on Amazon Braket. Reading the state vector mutated the caller's circuit, so a later shot-based run raised; and NumPy scalar angles or bound values (as produced by NumPy/PyTorch training loops) were rejected. Both are fixed in qumat/amazon_braket_backend.py.
Related Issues or PRs
Fixes a bug found during the CoC Glasgow 2026 hackathon prep (no issue filed yet — file one with the reproducer below before opening).
Reproducer (found by the backend parity sweep):
q.get_final_state_vector() # inspect the state...
q.execute_circuit() # ...then sample it: Braket raises
("StateVector or Amplitude cannot be specified when shots>0")
q.apply_rx_gate(0, "t")
q.execute_circuit({"t": np.float32(0.5)}) # Braket raises
("Cannot wrap 0.5 into literal type"; an np.float32 angle passed directly raises "FreeParameter names must be strings")
Changes Made
get_final_state_vector(): callstate_vector()oncircuit.copy()instead of the caller's circuit, as the Qiskit backend already does.- New
_as_angle(): strings becomeFreeParameter, anynumbers.Realbecomes a plainfloat; replaces three copies of theisinstance(angle, (int, float))check inapply_rx/ry/rz_gate. - New
_bound_inputs(): casts bound values tofloat; shared byexecute_circuitandget_final_state_vector. apply_u_gate: same numeric cast, angles annotatedSupportsFloat(so the repo'styhook passes); U stays non-parameterisable, as on the other backends.testing/qumat/test_amazon_braket_backend.py: mocked tests assert the copy is used and the original untouched; end-to-end local-simulator regression; NumPy scalar tests for rotation and U gates and for bindingnp.float32(pi).
Testing
testing/qumat: 604 passed (main: 589).- The new tests fail against the old code (3 for the copy fix; 14 for the NumPy fix).
- ruff, ruff format and
tyclean (no new diagnostics vs main). - Not verified: AWS SV1 (cloud); the copy and float casts are device-independent.
Merging
Conflicts with the #1507 PR on one import line in testing/qumat/test_amazon_braket_backend.py. A rebased "#1507 after A1" version exists.
🤖 Generated with Claude Code
- Lingua principale
- Rust
- Stelle
- 2.3k
- Fork
- 1k
- Merge medio
- 2g 20h
- PR unite (30g)
- 7
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/mahout
-
[Bug] Amazon Braket get_final_state_vector() changes the circuit, so execute_circuit() fails afterwardsForse già presa @Howardisme l’ha presa 48 giorni fa. Apertabug enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
apache/mahout#1538 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Reusing a parameter name on two gates fails on Qiskit only (name conflict adding parameter)Forse già presa @Imad2702 l’ha presa 50 giorni fa. Apertabug enhancement good-first-issue qumat
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/mahout#1509 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Cirq backend ignores the initialized simulator and creates its own cirq.Simulator()Forse già presa @Howardisme l’ha presa 49 giorni fa. Apertabug enhancement good-first-issue qumat
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
apache/mahout#1508 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Unknown backend_name leaks ModuleNotFoundError instead of a clear ValueErrorForse già presa @Asterisk-Hunter l’ha presa 38 giorni fa. Apertabug enhancement good-first-issue qumat
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
apache/mahout#1506 · 5 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
bug docs enhancement question
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/mahout
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 95/100
ClickHouse/clickhouse-rs#589 ·
I maintainer di solito rispondono entro 2 giorni
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pbakaus/impeccable#1887 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
bruits/satteri#400 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni