-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Simulator backends #435
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
Simulator backends #435
Conversation
Serializable Qobj + Pass cpp/projectq simulator tests
* fixing up the backend in the example * Adding the wrappers to an inport as in the examples this feel the more natural way to use them. % Your branch is up to date with 'origin/master'. * Making cleaner and removing the commeted try * fixing readme
* Remove TestQuantumProgram.test_gate_after_measure * Merge pull request Qiskit#399 from diego-plan9/fix/qp-discovery-stable Reintroduce openquantumcompiler.dag2json() * Remove extra barriers temporalily from compile() (author: @ajavadia) * Remove unnecessary headers
* no name in the registers means no name :-/ * backend=None as a skip translation * skip_translation flag * tests for skip_translation * linting * style * diff simplyfication * support in execute * style * add skip_translation to the execute functions in wrapper and _compiler * update docstrings * style * make default skip_translation False
* DAGCircuit.layers changed to yield a generator * DAGCircuit.serial_layers changed to yield a generator * Mapper has been adjust to consume generators instead of lists for layers
* Backporting changes from stable-0.4.14 to master, manually. This will remove IBM online simualtors from the tests related to configuration checking. * * Temporarily remove remote IBM simulators from tests * Added a check for making sure basis_gates config parameter doesn't conflict with gate_set * Making peace with the Linter
- Parallelisation is now handled exclusively by OpenMP - No longer parallelisation over shots on Xcode-clang build - Also adds text param support for snapshot, save, load instructions
… name in all configs.
@diego-plan9 @chriseclectic I think I'm done with this PR. |
|
||
|
||
@unittest.skipIf(_skip_class, 'C++ simulators unavailable') | ||
class TestCrossSimulation(QiskitTestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the functionality for testing the alias and deprecated mechanism included elsewhere? If not, could you please add another TestCase
on this file that exercises only that functionality it a bit (ie. without compiling or running - only making sure that querying based on an alias returns a backend as expected, that deprecated backends are converted to the current ones, etc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Just a public note following the private discussion to remember that, when merging, this PR should get squashed as the git story is not clean (in particular, it is showing some "duplicated" commits from 298d42d Circuit drawing improvement |
@diego-plan9 added more tests and confirmed that all previous PRs are intact. |
1dd8bf4
to
12afcc8
Compare
12afcc8
to
dba2a1a
Compare
Finally merging, thanks @ajavadia ! |
* port simulator files. remove a bunch of FIXME since API got better * moved compact flag from defaultqiskitprovider to wrapper * dont try to format counts when no cbit exists in qasm_simualtor_py * choose whichever statevector simualtor is available in tests * diego comments. restoring the yield PR * rzz in standard extensions * no qubit arg for simulator instructions snapshot, load, save, noise * adding new names for simulator files * aliased and deprecated dictionaries in ibmqprovider * compact flag. resolve_backend_name method in default provider. assume name in all configs. * updated dagcircuit so simulator instructions are known, and treated like barrier * changed names for ibmqx online simulators * fix snapshotting of multiple circuits in py simulator style * Fixes issue with c++11 async in simulator by removing it. - Parallelisation is now handled exclusively by OpenMP - No longer parallelisation over shots on Xcode-clang build - Also adds text param support for snapshot, save, load instructions * tests for simulator extensions and input output interfaces * dont print wait * turn off auto profiling in test_qasm_simulator_py * skip cpp tests when not built (i.e. online) * rename quantum_state to statevector in simulator output * add tests for aliased, deprecated backends
Working towards plug-and-play interchangability of simulator backends, ensuring input/outputs are the same.
Resolves #281 (Simulator Interfaces)
Resolves #314 (Simulator testing)
Resolves #324 (Sympy Simulator testing).
Description
Adds 2 new backends:
statevector_simulator_cpp
andstatevector_simulator_py
, used for simulating the wavefunction for a single shot, without noise and measurement. The result is returned in thestatevector
field of the result dictionaryAdds a new snapshot command for saving snapshots of simulator internal representations, over all qubits. For the python simulator, this is only the
quantum_state
. For the cpp simulator, this can bequantum_state
,density_matrix
,probabilities
, etc. (refer to doc). The following simulator commands are treated like barriers to prevent reordering:snapshot
,noise
,save
,load
Converts the
qasm_simulator_sympy
tostatevector_simulator_sympy
, since the point of a sympy simulator is to preserve precise amplitudes, not to do measurements and counts.Adds a mechanism for providers to report information about aliased names and deprecated names.
Aliased names are useful since there could be several implementations of functionally similar backends within a provider. So, for example, the user can just write
get_backend('local_qasm_simulator')
, and this would return an instance ofQasmSimulatorCpp()
. If that is not built, then an instance ofQasmSimualtorPy()
.Deprecated names are useful since backend names could change. For example, now all previous code that use
local_qiskit_simulator
will automatically redirect tolocal_qasm_simualtor_cpp
, with a deprecation warning.Adds an optional
compact
flag when inquiring backend names from the wrapper. For example,wrapper.local_backends()
returns:but
wrapper.local_backends(compact=False)
returns:One positive effect of the above is that all previous code that simply used
local_qasm_simulator
now run with a faster version, if available. This speeds up running the test suite.Adds a
_validate()
method to several simulators, which is called immediately before a qobj isrun()
. This can validate semantic things that a schema cannot, such as measurements being at the end of circuit.The behavior of getting the
quantum_state
by settingshots=1
in the simulators is now deprecated. You can either use thelocal_statevector_simulator
to do this automatically, or use thelocal_qasm_simulator
and place an explicitsnapshot
command. However, backwards compatibility is still preserved.This PR touches a lot of files, but most are only minor name changes.
New names are in accordance with this (also see picture below):
PROVIDERNAME_SIMPLEALIAS_simulator_LANGUAGEORPROJECT
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: