-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MPS Synthesis #7752
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
base: main
Are you sure you want to change the base?
MPS Synthesis #7752
Conversation
- Fixed `_parser.py` formatting issues.
- Added testers for `cp`, `c3x`, `c4x`, `csx`, and `c3sqrtx` gates. - Fixed u0 gate. - Removed `r`, `ryy`, `cu2`, and `iswap` as they are not part of qelib 1.
- Fixes gate definition for `id` to address git-blame note. - Fixes gate definition for `p` to use ZPowGate. - Adds rccx and rc3x using `cirq.MatrixGate`. - Adds missing testers for cry and crz.
- Fixed failed CIs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7752 +/- ##
==========================================
- Coverage 99.38% 99.38% -0.01%
==========================================
Files 1090 1093 +3
Lines 98248 98388 +140
==========================================
+ Hits 97643 97782 +139
- Misses 605 606 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I added single qubit state prep manually, it should be removed when cirq gets state preparation added. I'll be sure to remind in the next cirq cynq. |
|
I need to check a few things with colleagues; I will have an update early next week. |
pavoljuhas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see inline comments. Otherwise LGTM, thank you for contributing this.
PS: I'd like to loop in @tanujkhattar for more comments after we converge on the initial review.
| derived from the input matrix. If a column is (approximately) zero, it | ||
| is replaced with a random vector. | ||
| """ | ||
| num_rows, num_columns = matrix.shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only caller of this function passes a square matrix.
Can we require the matrix to be square here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay if I add this for safety? I'll add it for now, and later before merge I can remove it if you don't want it.
if matrix.shape[0] != matrix.shape[1]:
raise ValueError(
"Input matrix is expected to be square. "
f"Got shape {matrix.shape} instead. "
"If this is not an error, please file an issue at "
"https://github.com/quantumlib/Cirq/issues"
)| unitary = np.zeros((num_rows, num_columns), dtype=np.complex128) | ||
| orthonormal_basis: list[NDArray[np.complex128]] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrite using scipy.linalg.org and scipy.linalg.null_space
| state = np.random.rand(2**N) + 1j * np.random.rand(2**N) | ||
| state /= np.linalg.norm(state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse cirq.testing.random_superposition instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I noticed is that cirq.testing.random_superposition is not sampling from a uniform distribution, but a normal distribution. Is it okay if I make a quick PR to change np.random.randn to np.random.rand to fix it?
Closes #7650 .