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

Fix #674: Measurements before swap mapping #691

Merged
merged 6 commits into from
Jul 30, 2018
Merged

Fix #674: Measurements before swap mapping #691

merged 6 commits into from
Jul 30, 2018

Conversation

nonhermitian
Copy link
Contributor

Summary

In order to satisfy the requirements of a restricted coupling map, the swap_mapper might need to swap into qubits that were measured.

Details and comments

Here we remove the measurements that have no gates after them, i.e. they are at the end of the circuit, before performing the swap mapping. Once the mapping is done, the measurements are added to the end of the circuit. A test that verifies the solution for a known problem circuit is provided.

The functionality added here also gives a clean way of solving #666, but requires adding a flag to the Qobj and having the simulator read the flag. That will done done in another PR.

@nonhermitian
Copy link
Contributor Author

This keeps failing on Travis, but works perfectly on my machine. Don't know why.

@nonhermitian
Copy link
Contributor Author

I have tested on Py35 as well, and it always works. Not sure why it fails on Travis.

@nonhermitian
Copy link
Contributor Author

I have also run this on a Ubuntu VM and it passes all tests. @diego-plan9 @atilag @delapuente do you know why this PR would be failing a test in the lint and pure python stage, but working fine when run locally?

@nonhermitian
Copy link
Contributor Author

As discovered with @diego-plan9, the problem was transpile does not compute a good initial layout, whereas compile does. Fix was to explicitly add initial layout in test.

Copy link
Member

@diego-plan9 diego-plan9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nonhermitian - neat fix! I added an entry to the changelog as it has enough importance to include it, and merging!

@diego-plan9 diego-plan9 merged commit d277521 into Qiskit:master Jul 30, 2018
@diego-plan9 diego-plan9 added this to the 0.6 milestone Jul 30, 2018
@nonhermitian nonhermitian deleted the fix_swap_mapper branch August 21, 2018 17:00
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Fix Qiskit#674

* Test for Qiskit#674

* Forgot test_mapper.py

* add initial layout to test

* Update changelog
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.

2 participants