-
Notifications
You must be signed in to change notification settings - Fork 73
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
Make chip-contiguous-subschedule-from-last-instructions non-recursive #693
Conversation
f73467f
to
568dcbe
Compare
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.
Lisp single-link lists are still not entirely intuitive to me, so want to double check myself on the append and setf/cdr operation below.
Also, any reason to use setq in place of setf here or just generally?
src/addresser/outgoing-schedule.lisp
Outdated
(loop for predecessor in predecessors | ||
do (unless (gethash predecessor seen) | ||
(setf (gethash predecessor seen) t) | ||
(setf queue (append queue (list predecessor))))) |
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.
Is this operation efficient memory resource-wise?
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.
Generally, no. It will copy the entire queue
, and as a part of that copy, append the element. So it's O(N) in time and space. It's preferred to use an actual queue-like data structure instead of raw Lisp lists.
There are a couple options for FIFO queues in quilc. The first is to use cl-heap
. The second is to use the very simple queue data structure in god-table.lisp
(see cl-quil.clifford::make-queue
).
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.
If you instead just want a stack, then using push
and pop
on Lisp lists works fine, and is O(1). (I don't think a stack can be used for this BFS though.)
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.
I noted mostly style and efficiency concerns, which you may incorporate. After that, I'll be happy to check correctness.
src/addresser/outgoing-schedule.lisp
Outdated
(loop for predecessor in predecessors | ||
do (unless (gethash predecessor seen) | ||
(setf (gethash predecessor seen) t) | ||
(setf queue (append queue (list predecessor))))) |
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.
Generally, no. It will copy the entire queue
, and as a part of that copy, append the element. So it's O(N) in time and space. It's preferred to use an actual queue-like data structure instead of raw Lisp lists.
There are a couple options for FIFO queues in quilc. The first is to use cl-heap
. The second is to use the very simple queue data structure in god-table.lisp
(see cl-quil.clifford::make-queue
).
src/addresser/outgoing-schedule.lisp
Outdated
(loop for predecessor in predecessors | ||
do (unless (gethash predecessor seen) | ||
(setf (gethash predecessor seen) t) | ||
(setf queue (append queue (list predecessor))))) |
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.
If you instead just want a stack, then using push
and pop
on Lisp lists works fine, and is O(1). (I don't think a stack can be used for this BFS though.)
568dcbe
to
0d1084b
Compare
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.
Per discussion with Mark, I also owe a new test case that passes here but will blow up on the previous implementation.
0d1084b
to
9c35515
Compare
@@ -100,3 +100,26 @@ | |||
(quil::chip-contiguous-subschedule-from-last-instructions | |||
sched (quil::make-qubit-resource 0 2)) | |||
expected-subschedule)))))) | |||
|
|||
(deftest test-fidelity-addresser-subschedule-on-deep-circuit () |
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.
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.
we gotta work on your emacs theme at some point
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.
All I really care about is ENORMOUS FONT. Otherwise, I'm open.
FYI it looks like |
f7ad1f3
to
7331aee
Compare
((resource-subsetp (instruction-resources instr) | ||
resource) | ||
(map nil #'mark-predecessors-seen (gethash instr earlier-instrs))))) | ||
(bottoms-up (instr) |
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.
This was nice while it lasted 🍻
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.
🍻
@@ -100,3 +100,26 @@ | |||
(quil::chip-contiguous-subschedule-from-last-instructions | |||
sched (quil::make-qubit-resource 0 2)) | |||
expected-subschedule)))))) | |||
|
|||
(deftest test-fidelity-addresser-subschedule-on-deep-circuit () |
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.
we gotta work on your emacs theme at some point
7331aee
to
afb4812
Compare
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.
My comments are consistency-in-style nits. Otherwise looks good-to-go.
afb4812
to
a298cdf
Compare
|
Seems like a simple package issue, somewhere there's a |
4f56b08
to
576baef
Compare
Can this be closed in favour of #717, @erichulburd? |
Closes #697.