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

Unroll 3-or-moreQ pass #1614

Merged
merged 6 commits into from
Jan 24, 2019
Merged

Unroll 3-or-moreQ pass #1614

merged 6 commits into from
Jan 24, 2019

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Dec 27, 2018

The current swappers do not work with 3Q gates. Therefore, it makes sense to decompose those gates before. This pass decomposes 3q gates recursively.

@jaygambetta
Copy link
Member

jaygambetta commented Dec 27, 2018

This should not be just 3 qubit gates. We should have a pass that unrolls to 1 and 2 qubit gates. Why can't we call the unroll pass before swappers

@1ucian0
Copy link
Member Author

1ucian0 commented Dec 28, 2018

The Unroll pass decomposes the full circuit to a basis set. That might create situations where some information get lost (for example, is this cx coming from a cz? ). This pass allows other passes to say: "I don't know how to deal with 3q, unroll just those ones."

@jaygambetta
Copy link
Member

Then you can set it by the basis you want. If you are breaking up a cox you need to know what. For the mapper it will not mapper which gate basis you choose as long as it is single and two qubit.

@1ucian0
Copy link
Member Author

1ucian0 commented Dec 28, 2018

Decompose and Unroll are complementary. Unroll('U') makes sure that you will only have 'U's at the end. Decompose('swap') will guarantee that you won't have 'swap's at the end. Both are necessary. Similarly to the former, Decompose3Q will keep everything as it is, but no 3Q at the end. That's what mapper needs. As you said, as long as the circuit has single or two qubits gate, the mapper is fine with it. There is no way to express that with the unroller.

@ajavadia
Copy link
Member

It seems like what this pass should do is to unroll recursively down to a 1Q and 2Q basis. Decomposing just 3Q gates is limiting because what if the circuit has a 4Q or 5Q composite gate?
The pass can be written in a way that it decomposes until every gate is at maximum a two-body interaction. It is slightly different than the current unroller pass because no explicit basis is required.

@1ucian0
Copy link
Member Author

1ucian0 commented Dec 28, 2018

I see your point there! It will no be testable until we don't have better support for custom gates. I can modify it to consider that and be read. Do you think the name DecomposeTo2QorLess is better?

@1ucian0
Copy link
Member Author

1ucian0 commented Dec 29, 2018

After talking with @ajavadia and @jaygambetta, I see their point. The pass should be renamed to Unroll2Q since is recursive.

@1ucian0 1ucian0 changed the title Decompose 3Q pass [WIP] Decompose 3Q pass Dec 29, 2018
@1ucian0 1ucian0 self-assigned this Dec 29, 2018
@1ucian0 1ucian0 changed the title [WIP] Decompose 3Q pass Unroll 3-or-moreQ pass Jan 1, 2019
@1ucian0
Copy link
Member Author

1ucian0 commented Jan 1, 2019

I renamed the pass and I change it to consider 3-or-moreQ gates, not just 3. Ready for review.

@1ucian0 1ucian0 removed their assignment Jan 1, 2019
@ajavadia
Copy link
Member

Thanks. This looks good. I updated the pass name to match the title of this PR, as I think that makes more sense. Good to merge.

@ajavadia ajavadia merged commit 1726721 into Qiskit:master Jan 24, 2019
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Decompose3Q initial commit

* pass and test

* style and lint

* dag comparison fails in py3.5

* change name, and ge

* change pass name, some docstrings
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.

3 participants