You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by "Howardisme (via GitHub)" <gi...@apache.org> on 2026/10/17 17:40:07 UTC

[PR] [QUMAT] Fix Cirq backend ignores the initialized simulator and creates its own cirq.Simulator() [mahout]

Howardisme opened a new pull request, #1535:
URL: https://github.com/apache/mahout/pull/1535

   ### Related Issues
   
   Closes #1508 
   
   ### Changes
   
   - [x] Bug fix
   - [ ] New feature
   - [ ] Refactoring
   - [ ] Documentation
   - [x] Test
   - [ ] CI/CD pipeline
   - [ ] Other
   
   ### Why
   
   `cirq_backend.initialize_backend()` returns a simulator, but `execute_circuit()` and `get_final_state_vector()` ignored the `backend` argument and created a new `cirq.Simulator()` every time. Any simulator configuration (like seed...) was silently lost, and other Cirq simulators such as `DensityMatrixSimulator` could not be plugged in.
   
   ### How
   
   - letting `execute_circuit()` and `get_final_state_vector()` directly use the simulator passed in as `backend` (returned by `initialize_backend()`), instead of creating a new `cirq.Simulator()` on each call.
   - Added `testing/qumat/test_cirq_backend.py`. Since the bug is in the Cirq backend functions themselves, the tests call these functions directly with `MagicMock(wraps=cirq.Simulator())` and assert that the passed-in simulator is the one that runs, covering both the plain and parameterized paths. A seeded test also checks that two simulators with the same seed give same results.
   (All 5 new tests fail on `main` and pass with this change.)
   
   ## Checklist
   
   - [x] Added or updated unit tests for all changes
   - [ ] Added or updated documentation for all changes
   


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

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