-
Notifications
You must be signed in to change notification settings - Fork 4
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
Added fix for two-qubit custom gates and Added new conversion for SU4 gates #14
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
==========================================
- Coverage 89.13% 85.84% -3.29%
==========================================
Files 2 2
Lines 92 106 +14
==========================================
+ Hits 82 91 +9
- Misses 10 15 +5 ☔ View full report in Codecov by Sentry. |
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.
Thanks for sorting this out Ahmed! A couple comments/questions:
- Can the SU(4) gate from
orquestra.qml
be handled by_custom_qulacs_gate
now that the permutation issue is fixed? If so, I think we would not need to add SU(4) as a special case to the qulacs integration. - It looks like the new test cases for permutation correctness and handling the SU(4) gate have hard coded in a bunch of numeric values, which makes it tricky to see what exactly the test is checking and whether the target wavefunction is correct. Would it be hard to come up some simpler test cases that still check the relevant behavior? Or alternatively, to include the code that generated the circuit parameters and target wavefunctions?
- Now that some of the test cases for
test_get_wavefunction_works_with_multiphase_operator
don't use the multiphase operator, this function should be renamed.
@Shiro-Raven Hey there! Just checking in to see if we're planning to keep working on this. If not, I might close the PR for now to stop the daily GitHub reminders. Let me know what you think. 😅 |
@AthenaCaesura I removed you from requested reviewers, which I think will stop the daily reminders. |
Description
During a QML experiment, it was noted that the experiment was producing bad results due to the faulty conversion of custom gates in the Qulacs simulator, since the experiment was working fine when using the
SymbolicSimulator
. The reason turned out to be that the custom gate matrix not permuted properly along with the indices as was done already in the conversion. The implemented solution, which only works for two-qubit gates, applies "virtual" SWAP gates before and after the gate. This is easily done by the swapping of the second and third rows and columns of the quantum matrix. Of course, this would never work for >3-qubit gates, and so this might need to be revisited later on. (Maybe add a warning for that as well?)In addition, support for SU4 gates (from orquestra.qml) was added because it is required by an ongoing experiment. It reuses the conversions of U3, XX, YY, and ZZ gates. An issues was testing. Since it's not efficient to include qml-core as a dev dependency, I opted for copying the original code, simplifying it, and using that for the tests.
Please verify that you have completed the following steps