This is an automated email from the ASF dual-hosted git repository.

guanmingchiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git


The following commit(s) were added to refs/heads/main by this push:
     new dcd95e956 MAHOUT-608: handle 0-qubit circuits in cirq backend to 
prevent crash
dcd95e956 is described below

commit dcd95e956e676c938e4079578de77f6eea3e7d8b
Author: Shivam Mittal <[email protected]>
AuthorDate: Wed Nov 12 15:14:33 2025 +0530

    MAHOUT-608: handle 0-qubit circuits in cirq backend to prevent crash
---
 qumat/cirq_backend.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qumat/cirq_backend.py b/qumat/cirq_backend.py
index 075751619..735ff8f4b 100644
--- a/qumat/cirq_backend.py
+++ b/qumat/cirq_backend.py
@@ -96,6 +96,11 @@ def apply_pauli_z_gate(circuit, qubit_index):
 
 
 def execute_circuit(circuit, backend, backend_config):
+    # handle 0-qubit circuits before adding measurements
+    if not circuit.all_qubits():
+        shots = backend_config["backend_options"].get("shots", 1)
+        return [{0: shots}]
+
     # Ensure measurement is added to capture the results
     if not circuit.has_measurements():
         circuit.append(cirq.measure(*circuit.all_qubits(), key="result"))

Reply via email to