You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "shiavm006 (via GitHub)" <gi...@apache.org> on 2025/11/08 12:28:31 UTC

[I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

shiavm006 opened a new issue, #608:
URL: https://github.com/apache/mahout/issues/608

   ### Description
   
   The Cirq backend crashes when attempting to add measurements to a circuit with zero qubits. The `execute_circuit` function in `cirq_backend.py` calls `cirq.measure(*circuit.all_qubits())` on empty circuits, which raises an error because you cannot measure an empty list of qubits.
   
   ### Steps to Reproduce
   
   1. Create a QuMat instance with Cirq backend
   2. Create an empty circuit with 0 qubits
   3. Call `execute_circuit()` directly on the backend (bypassing the main QuMat wrapper)
   
   **Example code:**
   from qumat import QuMat
   
   config = {
       "backend_name": "cirq",
       "backend_options": {"shots": 1024}
   }
   qumat = QuMat(config)
   qumat.create_empty_circuit(0)
   
   
   ### Actual Behavior
   
   Crashes with backend-specific error when attempting to call `cirq.measure(*[])` on an empty qubit list. The error message is cryptic and doesn't explain the root cause (0 qubits).
   
   


-- 
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: dev-unsubscribe@mahout.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "rawkintrevo (via GitHub)" <gi...@apache.org>.
rawkintrevo commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3513485300

   if we know it's an issue with cirq, and the error is cryptic, the band aid might just to be raise a warning that you're passing a zero qubit circuit, and this might make things crash


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3519911423

   Nice! Let’s go for it.


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "shiavm006 (via GitHub)" <gi...@apache.org>.
shiavm006 commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3508568889

   @guan404ming  any thought on this ?
   


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "shiavm006 (via GitHub)" <gi...@apache.org>.
shiavm006 commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3518220410

   @guan404ming 
    I see your point about keeping Qumat thin, but we're already handling this in the main class (lines 92-97 in qumat.py). The issue is the Cirq backend crashes if called directly because it doesn't have the same check. I think moving that logic into the backend makes it more robust without adding complexity. Thoughts?


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "shiavm006 (via GitHub)" <gi...@apache.org>.
shiavm006 commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3518223017

   @rawkintrevo 
   Agree with the band-aid approach. We could just add the same check that's in the main class to the Cirq backend's execute_circuit()


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming closed issue #608: [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits
URL: https://github.com/apache/mahout/issues/608


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "rawkintrevo (via GitHub)" <gi...@apache.org>.
rawkintrevo commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3518476574

   works for me.


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3509721462

   I'm not sure if there is better solution for this issue. Do you have any idea?
   
   IMO, I think this is not what we need to resolve here since Qumat is serve as a frontend, which is just a interface now. And this issue is kind of backend issue. Maybe you could try open PR to handle thiss issue in `cirq` repo. Please feel free to correct me if you have any idea, thanks!


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Cirq backend crashes when adding measurements to 0-qubit circuits [mahout]

Posted by "shiavm006 (via GitHub)" <gi...@apache.org>.
shiavm006 commented on issue #608:
URL: https://github.com/apache/mahout/issues/608#issuecomment-3508572306

   assign @shiavm006 


-- 
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: dev-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org