Repository navigation
Skip the list conversion of envelopes when the QickSoc is local - #444
Merged
Merged
Conversation
load_envelopes converted every envelope and weight array to a Python list for Pyro. QickSoc.load_envelope then converts the list back to an array. On a local board, this round trip is the slowest step of a program load. On a ZCU111 with a 60320-sample envelope, acquire_decimated took 715 ms, and 5 ms without the round trip. That test used a tProc v1 program, and v2 programs use the same load_envelopes. load_envelopes now converts to a list only when soc is a Pyro proxy (it has _pyroUri). A local QickSoc gets the int16 array as it is. Remote use does not change. See openquantumhardware#411. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #411.
load_envelopesconverts every envelope and weight array to a Python list "for pyro compatibility". ThenQickSoc.load_envelopeconverts the list back to an array. With a local QickSoc, this round trip is the largest part of loading a program that has a long envelope, because the board CPU is slow at it.On our ZCU111, a 60,320-sample envelope took 715 ms in
acquire_decimated. Withload_envelopespatched to skip the conversion, it took 5 ms. That test used a tProc v1 program, and v2 programs call the sameload_envelopes. It matches the extra ~500 ms that #411 reports for a ~60,000-sample envelope.This PR converts to a list only when
socis a Pyro proxy, which it detects by the_pyroUriattribute that every Pyro4 proxy has. A local QickSoc gets the int16 array as it is. Nothing changes for remote use. The lists stay for the proxy because, assetup.pynotes, PYNQ boards run NumPy 1, which cannot read NumPy 2 pickles.load_weightsgets the same change.Testing (no board): a fake soc records the type of data it gets.
numpy.ndarray, a fake proxy with_pyroUrigets alist, and both load the same samples.load_envelopeswith a 65,536-sample envelope on an Apple M-series CPU takes 0.004 ms for a local soc and 7.4 ms through the list. The board CPU is much slower at the list round trip than this.On this branch:
3 passed. On main, the local-soc test fails (assert [<class 'list'>] == [<class 'numpy.ndarray'>]).The 715 ms → 5 ms numbers come from our patched install on the board, not from this branch. I can measure this branch on the board if that helps.