Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix applyMatrix in
lightning.gpu
(#932)
### Before submitting Please complete the following checklist when submitting a PR: - [ ] All new features must include a unit test. If you've fixed a bug or added code that should be tested, add a test to the [`tests`](../tests) directory! - [ ] All new functions and code must be clearly commented and documented. If you do make documentation changes, make sure that the docs build and render correctly by running `make docs`. - [ ] Ensure that the test suite passes, by running `make test`. - [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing the change, and including a link back to the PR. - [x] Ensure that code is properly formatted by running `make format`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Context:** [SC-74899] `lightning.gpu` stores gate data to a `unordered_map` object. The gate data can be accessed with a key (`opsName, Param`) . This design can avoid the excessive data copy between the device and host. However, the way a matrix gate is stored causes the bug since `lightning.gpu` will only add first matrix data to the cache since the keys of all matrix will be the same `({},{})` pair. Following applyMatrix calls will just result in getting data from the cache and the matrix used for operation will be always the first matrix. This bug will cause errors at least when applying TensorProd with multiple Hermitian obs. To fix it, we will not store the matrix data to the gate cache and just copy it from host to device on-the-fly. **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: ringo-but-quantum <[email protected]>
- Loading branch information