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

Library of commutation relations over standard gates #7101

Closed
kdk opened this issue Oct 5, 2021 · 3 comments
Closed

Library of commutation relations over standard gates #7101

kdk opened this issue Oct 5, 2021 · 3 comments
Assignees
Labels
type: enhancement It's working, but needs polishing

Comments

@kdk
Copy link
Member

kdk commented Oct 5, 2021

What is the expected enhancement?

From @jakelishman 's comment in #6982 (comment) :

There is more work that could be done here as well, which I think would give us more performance in more natural workflows that don't just involve dumping in a tonne of unitary matrices. The next obvious step would be to build a lookup table of gate types that are known to commute with each other, in order to skip the entire process of comparing the two matrix multiplications for common cases; we can always fall back to this method. I haven't done this right now, because it's bigger task, and doesn't need doing in one go.

@kdk kdk added the type: enhancement It's working, but needs polishing label Oct 5, 2021
@jakelishman
Copy link
Member

To add to this: sensibly, the "lookup table" is probably something like a dictionary of (gate_type_1, gate_type_2) -> callable, where the callables take the actual gate instances and the qubits they operate on. Then they can return True, False, or None depending on whether they know they definitely commute, definitely don't commute, or they're not sure, by fast methods, such as inspecting the parameters. If we get None back, or there's no callable for the given types, we can just fall back to the current multiplication methods.

The callables won't play super nicely with the current caching method, but if they're fast enough, we may well not care that much. This form of type-based lookup also doesn't work "right" with inheritance, but if someone's inheriting from XGate, it's probably not our fault if things don't work right after.

@clausia
Copy link
Contributor

clausia commented Oct 6, 2021

I'm interested in doing this enhancement

@jakelishman
Copy link
Member

Done by #11192.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement It's working, but needs polishing
Projects
Status: Done
Development

No branches or pull requests

3 participants