-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix compiler pushing /measurement/ pulses to later time #1096
base: 0.1
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 0.1 #1096 +/- ##
==========================================
+ Coverage 69.88% 69.95% +0.06%
==========================================
Files 64 64
Lines 6880 6879 -1
==========================================
+ Hits 4808 4812 +4
+ Misses 2072 2067 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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 @hay-k.
At this stage, I believe moments
are not used by the compiler anymore, therefore we could probably even drop the nested loop and use for gate in circuit.queue
directly. However, this will change the order in which gates are processed and I am not sure if this will affect the final result. In any case, for me it is fine as it is too.
# make sure they are in different moments before proceeding | ||
assert not any( | ||
[ | ||
len([gate for gate in m if isinstance(gate, gates.M)]) == 2 |
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.
len([gate for gate in m if isinstance(gate, gates.M)]) == 2 | |
len([gate for gate in m if isinstance(gate, gates.M)]) > 1 |
Silly remark, it's just slightly more readable for myself (it translates more literally the comment above)
] | ||
) | ||
|
||
circ._wire_names = [q0, q1] |
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.
Do you really need to force .wire_names
?
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.
Without this the wire names were strings and they caused problems when getting the qubit from platform. I saw a similar thing is done in the backend (here), so did it here as well. Is there any better way around this?
circ._wire_names = [q0, q1] | ||
sequence, _ = compiler.compile(circ, dummy) | ||
|
||
MEASUREMENT_DURATION = 2000 |
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.
Maybe you could read this value from dummy
, just to be relatively sure in case anyone will change it later on.
After some testing I found a case that this new compilation logic fails to compile correctly. Converting the PR to draft for now, until I get it fixed. |
@hay-k this is what I was mentioning before: we have dedicated handling to make sure things are also synced per-qubit, even when the qubit is involved in an interaction but there is no pulse on any of its associated channels qibolab/src/qibolab/_core/compilers/compiler.py Lines 147 to 159 in ed8b3cc
|
Consider the following circuit:
The current compiler will compile this to:
Notice how the measurement on qubit 1 starts after the measurement of 0 (start time is 2040). Since measurement pulses are usually long (in this example 2000ns), this results into significant qubit state deterioration before the measurement of qubit 1 starts, hence poor results.
With the fix in this PR the circuit is compiled into the following sequence instead:
P.S. with measurement this issue is most apparent because of the typical long durations of the measurement pulses, however in principle pulses start times could be messed up in specific situations for other gates as well.