Skip to content

Conversation

@mpharrigan
Copy link
Collaborator

@mpharrigan mpharrigan commented Nov 11, 2025

Changes for numpy

  • data_types.py -- np.uint8 is stricter now
  • and_bloq.by -- there were np.uint8's sneaking in
  • There are new mypy complaints that I've generally ignored

Changes for Cirq

We require a more recent version of Cirq to support Numpy 2.

ControlledGate and _has_unitary_

I've monkeypatched cirq.ControlledGate. It was using cirq.has_unitary to determine whether something could be controlled. The rest of Cirq now treats "has unitary" as the ability to create a unitary matrix rather than saying whether the gate is reversible.

Simulation

There is something fundamentally incompatible between Qualtran's cirq interop functionality and recent Cirq versions. I've taken the "nuclear option", and now when you request the cirq simulation of a BloqAsCirqGate it will be done entirely in Qualtran and export a large unitary matrix to the cirq simulator; which can cause performance regressions;

In this PR, I've implemented the quick fixes to speed up Qualtran simulation of narrow, deep circuits from my comment on #1336

Some of the unit tests now cause SIGKILL on my machine. I don't know what's going on here. I've xfailed them.

Related issues

@mpharrigan mpharrigan changed the title [wip] cirq and numpy bump Support Numpy 2 via supporting Cirq 1.5+ Nov 12, 2025
@mpharrigan mpharrigan marked this pull request as ready for review November 12, 2025 20:50
@mpharrigan
Copy link
Collaborator Author

I've done local testing of the full unit test suite (not just the not slow tests) on mac and linux with Python 3.10 and newer, as well as with Cirq 1.6. The CI is still on Python 3.10 which caps us at Cirq 1.5. I'll leave bumping the CI Python version to a follow-up. So I think the nightly tests should pass; but we can't know for sure until this is merged. This is an area where the quick tests cannot catch all the errors that seem to happen only on the larger simulation tests.

@mpharrigan mpharrigan merged commit f67634f into quantumlib:main Nov 14, 2025
8 checks passed
@mpharrigan
Copy link
Collaborator Author

This broke the nightly tests, but there's no error message and I can't reproduce it

This was referenced Nov 19, 2025
@mpharrigan mpharrigan added this to the v0.7 milestone Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant