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

dm_simulator ported to Qiskit-terra 0.20.1 with additional features #13

Open
fasihere opened this issue Jun 8, 2022 · 0 comments
Open

Comments

@fasihere
Copy link

fasihere commented Jun 8, 2022

Information

  • Qiskit Terra version: 0.20.1

I have ported the dm_simulator to Qiskit-terra 0.20.1

The ported version can be found in this link: dmsim0.20.1

After porting, I tested out all the qiskit-textbook algorithms in the dm_simulator.

Issues identified during testing

  • Plot option does not return to default value when not stated in backend options.
  • Single measurements do not output partial probability
  • Once the backend noise is applied, it does not go back to default once the backend options are removed.(The issue was that rotation_error was a dictionary and was shallow copied from DEFAULT_OPTIONS and the DEFAULT_OPTIONS changed once we updated rotation_error. Hence it had to be deep copied.)
  • Result is a dictionary. Many qiskit algorithms expect the result to be an object similar to that in qasm_simulator, and they check for attributes which throws an error

Changes made

  • Plot and show_partition options returns to default option(False).
  • Rotation_error returns to default values
  • Single measurements now output partial probability
  • Result is changed to an object instead of dictionary, as in qasm simulator. This also improves user convenience as the usage is similar to that of qasm_simulator.
  • Made necessary changes to bell measurements to remove add_params requirement. This change is made in reference to issue #7.
     qc2 = QuantumCircuit(3,3)
     qc2.measure(1,2,basis='Bell')           #Measures bell_probabilities on the pair of qubits [1,2]
     options2 = {
         'plot': True
     }
     backend = BasicAer.get_backend('dm_simulator')
     run2 = execute(qc2,backend,**options2,shots=1)
     result2 = run2.result()
     result2.get_probability()

Features added

  • Added plot option for partial_probability
  • Added new methods to result:
    • get_densitymatrix() outputs the densitymatrix
    • get_probability() outputs the partial_probability, ensemble_probability, etc depending on the basis of measurement
    • get_expectation() outputs the expectation when the basis is ‘Expect’

I have also added the qiskit algorithms jupyter notebooks taken directly from qiskit-textbook, with changes made for the dm_simulator. These algorithms can be found in the algorithm folder inside dm_simulator_user_guide.

Observations

  • In a quantum circuit, if you measure some qubits using ensemble basis, and others using ‘X’, ’Y’, or ‘Z’ (default) basis, the partial_probabilities dictionary will contain partial probabilities of latter qubits. The get_probability() function will prioritize and output partial probabilities. Since I have also added plot option for partial probabilities, both partial probabilities and ensemble probabilities will be plotted.
  • The partial probabilities outputs the probabilities similar to the format of qasm_simulator(little endian). i.e. they output the last qubit as the most significant qubit. This is opposite to that of ensemble probabilities dictionary.
  • If we are taking an ensemble measurement in a circuit, we only need to take one such measurement. If we take multiple such ensemble measurements, multiple plots will be plotted(given plot=True).
  • For removing add_params for bell measurement, the first argument(qubit) and the second argument(cbit) are added together to form add_param. Since the function is still measure function, a classical bit should be present in the quantum circuit that is equal to the second argument. Otherwise, it throws a 'CircuitError'.

Final Note

Let me know any issues/suggestions/comments you have regarding the update. You can add the branch to the repository as you wish.

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

No branches or pull requests

1 participant