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

support single precision in state vector simulator #286

Merged
merged 11 commits into from
Jul 25, 2019

Conversation

hhorii
Copy link
Collaborator

@hhorii hhorii commented Jul 17, 2019

Summary

This PR adds a new parameter precision for qasm simulator.

Details and comments

QubitVector<std::complex<double>*> is changed to QubiveVector<double | float>.
By using single-precision, simulation becomes faster with reducing precision.

@hhorii hhorii force-pushed the change_qv_data_type branch from 57bdf96 to ed8552c Compare July 17, 2019 15:53
@hhorii hhorii force-pushed the change_qv_data_type branch from ed8552c to 0a55608 Compare July 19, 2019 02:01
@hhorii hhorii force-pushed the change_qv_data_type branch from 0a55608 to dc548e0 Compare July 19, 2019 02:04
@chriseclectic
Copy link
Member

@hhorii @atilag when using single precision do we have to worry about narrowing of data types when applying matrices given in double precision? The lambda loops will be things like data_[i] = mat(i, j) * data_[j] where mat(i,j) is complex<double> and data_[j] is complex<float>. Do we need to static cast the matrices to the reduced precision first?

@atilag
Copy link
Member

atilag commented Jul 24, 2019

This is valid narrowing conversion between two floating point types, it's stated in the standard as implicit so there's no need for static_cast. Having said that, I really hate implicit behaviors, it's great for programming faster but in the long term are less readable so maintainable. If there's not many conversions I'd explicitly use static_cast<float> and make clear that this is the behavior we want.
There's always a round in the last decimal digit though, so If this is mathematically correct for our use-case, then it's fine.

chriseclectic
chriseclectic previously approved these changes Jul 24, 2019
@chriseclectic
Copy link
Member

@hhorii I'm ready to merge this PR, but it needs to be rebased from master to get the build to work. The merge update failed due to some changes in recently merged PRs (I think in the UnitaryMatrix class).

atilag and others added 8 commits July 25, 2019 13:43
* add new matrix functions to utils

* add superop operation

* add canonical superop mats to utils

*allow kraus and superop qobj instructions to be conditional
…kit#291)

* Fixed general conditional checking in op execution

* Previously only gate type operations were checked for conditionals during execution. Now all op types are checked for conditional.

* add tests for conditional unitary instructions

* add test for conditional kraus instruction
* Add validation_threshold to backend options

* Add validation threshold to backends and controllers
  for checking initial unitary states are unitary, and
  initial statevectors are normalized.

* Move loading of OpenMP library to AerBackend base class
* Fixed bug in parallelization. It does not work correctly with vector push_back. Need to use assignment instead.
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.

4 participants