shiavm006 opened a new pull request, #615:
URL: https://github.com/apache/mahout/pull/615
### Purpose
Fixes crash in Cirq backend when executing 0-qubit circuits with
measurements.
### Related Issues
issue related #608
### Changes Made
- Added guard in `execute_circuit()` to handle empty circuits before adding
measurements
- Returns Cirq-formatted result `[{0: shots}]` for 0-qubit case
- Prevents crash when `cirq.measure()` is called on empty qubit list
### Technical Details
The issue occurred at line 106 where
`circuit.append(cirq.measure(*circuit.all_qubits(), key="result"))` crashes on
empty circuits because `circuit.all_qubits()` returns an empty list.
This fix aligns with existing behavior in the main `QuMat` class (lines
92-97 in `qumat.py`) which already handles 0-qubit circuits. Moving this logic
to the backend makes it self-contained and robust.
### Breaking Changes
None. This is a bug fix that maintains existing behavior.
### Checklist
- [x] Code follows project style guidelines
- [x] Changes are minimal and focused on the issue
- [x] Implementation aligns with maintainer feedback
- [x] No breaking changes introduced
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]