-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No support for symbolic parameters for MatrixGate (U-gate) #6810
Comments
Discussed during Cirq Cynq 2024-12-11: MatrixGate is documented as behaving this way. It is not clear on the benefits would be. Also, it may have performance implications. @vili-1 would you be able to discuss some use cases that would be helped by such a change? |
The MatrixGate is defined as a 2x2 numeric unitary matrix, the qiskit equivalent gate would be In qiskit |
@vili-1 to follow up on my above comment I think the cirq gate you would want is |
Symbolic parameters, in general, can make it much easier to simplify and optimise circuits algebraically before numerical evaluations. In Quantum Machine Learning models, for example, they can optimise parameters during training. Or in Variational Quantum Algorithms, symbolic parameters for custom gates can be handy where they can represent tunable operations in hybrid quantum-classical workflows. We’re a group of academic researchers working on fuzz testing quantum simulators and building a solid model that researchers can use in the broader scientific context. |
Is your feature request related to a use case or problem? Please describe.
Cirq does not currently support symbolic parameters, such as sympy.Symbol, for the MatrixGate (U-gate). While symbolic parameters are supported in other gates like rx, ry, and rz, the same functionality is not available for custom gates using MatrixGate.
The error below is raised when attempting to simulate the circuit with a symbolic parameter:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule 'safe'.
Describe the solution you'd like
Expected that Cirq would handle symbolic parameters in the MatrixGate and allow for symbolic computation during simulation, just as it does with gates like rx, ry, and rz. Qiskit handles symbolic parameters using its Parameter() class, including for U-gates.
[optional] Describe alternatives/workarounds you've considered
[optional] Additional context (e.g. screenshots)
What is the urgency from your perspective for this issue? Is it blocking important work?
P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle
The text was updated successfully, but these errors were encountered: