-
Notifications
You must be signed in to change notification settings - Fork 368
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 initialise simulator instruction to statevector_state #117
Conversation
Added examples (in comments) to the functions index0 and indexes in QubitVector class, to explain what they are doing |
72c3abe
to
a9f0c87
Compare
|
@ShellyGarion great! For verifying can you add some basic unit tests for initializing subsets of qubits. Some simple tests could be something like a 3-qubit state prepared in the
You could also add tests that it works correctly for an entangled state: Eg 2-qubits prepared in |
a9f0c87
to
647956f
Compare
The initialize_component function is not producing the correct output (the norm of the vector is not 1) - I need to debug it |
@chriseclectic - In the function initialize_component - what should N be? |
647956f
to
5aa5f38
Compare
@chriseclectic - I updated the code following your comments and PR #126, and performed the checks that you suggested above, and it looks OK (see details below). In particular, we started from |+++> state:
and:
and:
I also started with the Bell state: |
@ShellyGarion can you add a proper unit file for the above tests (and the failing test from your issue comments) and we can look to debugging them. |
5aa5f38
to
f66208a
Compare
@chriseclectic - please see the updated
|
I think that the problem may be with the type of the params given - When I update the Qobj in circ4 directly using: When I update circ6 using As you can see, in the Qobj of circ4 we have: |
@ShellyGarion the code looks good to me. I think the failing tests are when you use Can you edit the Note that you can check the correct qobj is being produced by using old From local testing I didn't find any problems with different format of the input state, the following all produced the same result for me: qr = QuantumRegister(3)
circ0 = QuantumCircuit(qr)
circ0.h(qr)
circ0.reset(qr[0])
circ0.x(qr[0])
circ1 = QuantumCircuit(qr)
circ1.h(qr)
circ1.initialize([0, 1], [qr[0]])
circ2 = QuantumCircuit(qr)
circ2.h(qr)
circ2.initialize([0.0, 1.0], [qr[0]])
circ3 = QuantumCircuit(qr)
circ3.h(qr)
circ3.initialize([0j, 1.0 + 0j], [qr[0]])
circ4 = QuantumCircuit(qr)
circ4.h(qr)
circ4.initialize(np.array([0, 1], dtype=float), [qr[0]])
circ5 = QuantumCircuit(qr)
circ5.h(qr)
circ5.initialize(np.array([0, 1], dtype=complex), [qr[0]]) |
…sm_simulator classes
ac555d5
to
9e2786f
Compare
@chriseclectic - Indeed, I am now using the new API of assemble_circuits and the deterministic tests are running OK. However, I am not sure how to combine a nondeterministic test as you suggested above: I also added initialize and reset to the StatevectorSimulator and QasmSimulator python classes. |
@chriseclectic - I think that most of the test_statevector_simulator.py (namely, testing reset and other gates) is written with the old API of "execute" that will be deprecated soon. |
* added initialize_component function to qubitvector class * added examples to index0 and indexes functions (in comments) * added comments with explanations to qubitvector class * added an optimization where the qubits are sorted * added a test: initialize_statevector_deterministic * updated test_statevector simulator * added basic gates initialize and reset to statvector_simulator and qasm_simulator classes
* added initialize_component function to qubitvector class * added examples to index0 and indexes functions (in comments) * added comments with explanations to qubitvector class * added an optimization where the qubits are sorted * added a test: initialize_statevector_deterministic * updated test_statevector simulator * added basic gates initialize and reset to statvector_simulator and qasm_simulator classes
Summary
#82
Details and comments
Added some printouts for debugging - should be removed later
TODO