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

Cirq changed initial_state kwarg to be density matrix #101

Merged
merged 7 commits into from
Apr 19, 2022

Conversation

Jaybsoni
Copy link
Contributor

@Jaybsoni Jaybsoni commented Apr 19, 2022

When calling the simulator.simulate(circuit) method for cirq.DensityMatrixSimulator() simulator (and all mixed state simulators I assume), the kwarg initial_state=None was previously passed as a state vector. Now it is required that this quantity be passed as a density matrix.

The unit tests were updated to make use of this functionality. No other changes required

@codecov
Copy link

codecov bot commented Apr 19, 2022

Codecov Report

Merging #101 (7b01707) into master (bb8c028) will increase coverage by 99.23%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           master     #101       +/-   ##
===========================================
+ Coverage    0.00%   99.23%   +99.23%     
===========================================
  Files           8        8               
  Lines         379      391       +12     
===========================================
+ Hits            0      388      +388     
+ Misses        379        3      -376     
Impacted Files Coverage Δ
pennylane_cirq/qsim_device.py 96.96% <0.00%> (+96.96%) ⬆️
pennylane_cirq/cirq_device.py 98.92% <0.00%> (+98.92%) ⬆️
pennylane_cirq/ops.py 100.00% <0.00%> (+100.00%) ⬆️
pennylane_cirq/__init__.py 100.00% <0.00%> (+100.00%) ⬆️
pennylane_cirq/_version.py 100.00% <0.00%> (+100.00%) ⬆️
pennylane_cirq/pasqal_device.py 100.00% <0.00%> (+100.00%) ⬆️
pennylane_cirq/cirq_operation.py 100.00% <0.00%> (+100.00%) ⬆️
pennylane_cirq/simulator_device.py 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb8c028...7b01707. Read the comment docs.

requirements.txt Outdated Show resolved Hide resolved
@Jaybsoni Jaybsoni changed the title Dependancy issue w PL version Cirq changed initial_state kwarg to be density matrix Apr 19, 2022
Comment on lines 190 to 194
def _convert_to_density_matrix(self, state_vec):
"""Convert ``state_vec`` into a density matrix."""
dim = 2**self.num_wires
return np.kron(state_vec, state_vec.conj()).reshape((dim, dim))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is moved, but the MixedStateSimulatorDevice inherits from the base SimulatorDevice so both classes have access to this helper function.

@Jaybsoni Jaybsoni requested a review from rmoyard April 19, 2022 18:05
Copy link
Contributor

@rmoyard rmoyard left a comment

Choose a reason for hiding this comment

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

Thank you for fixing the tests, it looks good to me! 💯

@Jaybsoni Jaybsoni merged commit 4f35cb5 into master Apr 19, 2022
@Jaybsoni Jaybsoni deleted the fix_new_release branch April 19, 2022 20:21
@antalszava
Copy link
Contributor

[sc-17246]

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.

None yet

3 participants