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

add qubits-truncate optimization #164

Merged
merged 8 commits into from
Apr 26, 2019
Merged

Conversation

hhorii
Copy link
Collaborator

@hhorii hhorii commented Apr 23, 2019

Summary

This PR truncates qubits in statevector to resolve #147

Details and comments

If some qubits are not used, qasm simulator does not use them in its qubitvector with this change.

  • Implement a new circuit optimization
  • Implement test cases

chriseclectic and others added 2 commits April 23, 2019 22:49
* Adding noise transformation to the noise package

* Unified interface for dict/list/string approximating operator input

* Implementation of approximate_noise_model

* Now generates noise approximation using unitaries if possible

* Now when possible outputs error circuits instead of Kraus/Unitary

* Now represent all named operators using circuits
@hhorii hhorii changed the title [WIP] add truncate optimization add truncate optimization Apr 24, 2019
@hhorii hhorii changed the title add truncate optimization add qubits-truncate optimization Apr 24, 2019
@chriseclectic
Copy link
Member

@hhorii why did you move the optimization passes out of the controller? It makes the most sense to me there as they are roughly equivalent to transpilation passes in terra and should be able to be applied to circuits regardless of which state they will be executed on (though the state they are intended to be being executed on can obviously effect the optimizations). I think how you had it in your last PR was fine.

With this PR I would say rather than check every op type for remapping you should only specify the op types that need a special case for remapping (like snapshots, multiplexer, multimatrix). For every other instruction all you need to do is remap their qubits parameters and as long as you don't change the relative order of the lists it will be consistent.

Multiplexer and multimatrix are special cases becuase you also need to remap the op.regs fields, and snapshot is a special base where you can only remap some snapshots (the ones that use qubit arguements like probabilities and expectation values), but not others (like statevector, stabilizer). To make it a bit simpler I would say to just not allow remapping for all snapshots for this first implementation.

@hhorii
Copy link
Collaborator Author

hhorii commented Apr 25, 2019

OK. I used think that this optimization should be applied only to Statevector::State. Checking a State type in AER::CircuitOptimization is not a good way, so I moved optimization list from Controller to State. Because this my assumption is wrong, I will roll this back.

@chriseclectic
Copy link
Member

It will be useful to apply for any state type used in QasmSimulator (like extended stabilizer, stabilizer, and especially density matrix in the future). The point of it is that (except for snapshots) the QasmSimulator only uses the state type to simulate outcomes of measurements, and those measurement outcomes don't change by this remapping of qubits.

Copy link
Member

@chriseclectic chriseclectic left a comment

Choose a reason for hiding this comment

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

Looks good @hhorii, thanks for getting this done quickly!

@chriseclectic chriseclectic merged commit 68a09d4 into Qiskit:master Apr 26, 2019
dcmckayibm pushed a commit to dcmckayibm/qiskit-aer that referenced this pull request Nov 3, 2019
@ishapoval
Copy link

ishapoval commented Jan 18, 2021

@hhorii The truncation of idle qubits works as expected if I use the execute wrapper, but if I go for transpile/assemble/run chain with seemingly all other parameters being equal I get a bunch of empty results

{'data': {},
'meas_level': <MeasLevel.CLASSIFIED: 2>,
'seed_simulator': 0,
'shots': 0,
'status': 'EMPTY',
'success': False,
'time_taken': 0.0}

from the QasmSimulator with the overall status of

'ERROR: QasmSimulator: Insufficient memory for 65-qubit circuit using "statevector" method. You could try using the "matrix_product_state" or "extended_stabilizer" method instead. '

Do I have to somehow enable fusion explicitly (if truncation is part of it) in the transpile/assemble/run chain?

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.

idle qubits are not optimized away
4 participants