rigetti / quil-rs

Quil Parser & Program Builder
https://rigetti.github.io/quil-rs/
Apache License 2.0
18 stars 9 forks source link

Feature: Program simplification variant that removes unused calibrations #341

Open mhodson-rigetti opened 6 months ago

mhodson-rigetti commented 6 months ago

When users build Quil-T programs, they often add the full set of production calibrations to the Quil program. This makes the program very large to persist and slower than necessary to parse. Given the set of instructions in the program, it would be desirable to remove all of unused Quil-T calibrations, frames, and waveforms. For feature completeness, it should also be considered to remove any DEFGATE or DEFCIRCUIT that are not referred to.

This is similar to the existing Program.into_simplified(), except that the calibrations would not be expanded. It may be most appropriate for this feature to be implemented here first, and then exposed suitably through pyquil.

mhodson-rigetti commented 6 months ago

Further suggestion: In common use cases, users bring a Program with instructions and some optional subset of new calibrations, frames and waveforms, meant to support novel instructions or to override those available from a prior process. In the override case it is not preferred to add inconsistent duplicates to a single Program and rely on some ordering rule to resolve. It might be preferred to provide a Program to resolve, and then a (potentially empty) ordered list of other calibration-only Programs which are successively used to resolve calibrations, frames and waveforms. Any matched across that ordered resolution fold up into the final result.