Skip to content
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

Matrix Product State does not support all gates the statevector supports #2221

Closed
aromanro opened this issue Sep 10, 2024 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@aromanro
Copy link
Contributor

What is the expected behavior?

I expected it to support all gates (at least one and two qubit ones) that the statevector supports, probably having this wouldn't be so difficult (especially for one qubit gates, where there is an apply_matrix function for the qubit's tensor).

For two qubit gates there seems that the function apply_2_qubit_gate is able to apply a generic gate matrix, if this is true it shouldn't be so difficult to add all the two qubit gates that are supported by statevector implementation.

How I found out about this:

I tried to compare the results (and the speed, as I expect that my generic simple 'tutorial' implementation to be much slower) with my implementation of MPS with some more or less random circuits and the tests failed with something like:

class std::invalid_argument: MatrixProductState::State::invalid gate instruction 'mcrx'.

If needed, I could try to add those myself, although probably there wouldn't be any optimisation that might be possible for some gates, since I'm not familiar enough with the implementation.

@aromanro aromanro added the enhancement New feature or request label Sep 10, 2024
@doichanj
Copy link
Collaborator

I think it is not necessary to add all the gates we have on statevector simulator to others, but we can run the circuit by using transpiler

@aromanro
Copy link
Contributor Author

That is indeed a solution... my problem is that I'm using it from a c++ project and that would mean adding more complexity to it and dependency on code that might change (also I'm not sure if the transpiler is fully implemented in qiskit aer in c++... or in qiskit with some python code mixed in).

Supporting more gates in a particular simulator - and having a larger common set supported by them - seems not a bad ideea, anyway.

@aromanro
Copy link
Contributor Author

I found a workaround that's enough for me:

It appears that apply_unitary and apply_diagonal_matrix should work at least for one and two-qubit gates (the three qubit ones I need I can transpile to one and two-qubit gates circuits).

For the gates that are not supported I can provide myself the matrices to those calls.

I'm closing this as solved since this solves it for me... although still supporting a larger common set of gates would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants