Skip to content

Conversation

ajavadia
Copy link
Member

@ajavadia ajavadia commented Apr 22, 2018

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 and statevector_simulator_py, used for simulating the wavefunction for a single shot, without noise and measurement. The result is returned in the quantum_state field of the result dictionary

  • Adds 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 be quantum_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 to statevector_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 of QasmSimulatorCpp(). If that is not built, then an instance of QasmSimualtorPy().
    Deprecated names are useful since backend names could change. For example, now all previous code that use local_qiskit_simulator will automatically redirect to local_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:

['local_qasm_simulator',
 'local_clifford_simulator',
 'local_unitary_simulator',
 'local_statevector_simulator']

but wrapper.local_backends(compact=False) returns:

['local_qasm_simulator_cpp',
 'local_qasm_simulator_py',
 'local_qasm_simulator_projectq',
 'local_statevector_simulator_cpp',
 'local_statevector_simulator_py',
 'local_statevector_simulator_sympy',
 'local_unitary_simulator_sympy',
 'local_unitary_simulator_py',
 'local_clifford_simulator_cpp']
  • 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 is run(). 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 setting shots=1 in the simulators is now deprecated. You can either use the local_statevector_simulator to do this automatically, or use the local_qasm_simulator and place an explicit snapshot 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

image

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ajavadia ajavadia changed the title Simualtor Interfaces Simulator Interfaces Apr 22, 2018
@ajavadia ajavadia mentioned this pull request Apr 23, 2018
77 tasks
@ajavadia ajavadia force-pushed the interfaces-simulators-python branch from 4b4e77c to ea1bc41 Compare April 23, 2018 16:52
@ajavadia ajavadia requested a review from diego-plan9 April 23, 2018 17:29
ajavadia and others added 26 commits April 28, 2018 00:39
- 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
@ajavadia
Copy link
Member Author

Opened a new PR with clean history (#435 )

@ajavadia ajavadia closed this Apr 29, 2018
@ajavadia ajavadia deleted the interfaces-simulators-python branch July 21, 2018 00:09
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.

Sympy backends need more testing The simulators need more testing Simulator Interfaces
6 participants