quil-lang / quilc

The optimizing Quil compiler.
Apache License 2.0
460 stars 72 forks source link

Addresser-state creation takes long for higher number of qubits #769

Open ghost opened 2 years ago

ghost commented 2 years ago

Addresser-state creation is done every time a compilation is done (every call to compiler-hook), either once or twice depending on parameters. The addresser state of a given class can generally be the same each call, assuming the chip type does not change. Although the current implementation of fidelity-addresser-state does some randomization, there's no particular need for the randomization to be done each call; it could be done just once. For fully-connected chip type, qubits = 70 and fidelity-addresser-state, calling compiler-hook as done in benchmark-nq (recently added benchmarking make target), the overhead of just creating the addresser state (which happens twice) is typically over 80 seconds.

ghost commented 2 years ago

This is an issue that's in a sense for this PR: "add performance tweaks, primarily addresser-state caching, and some s… #757"

stylewarning commented 2 years ago

PR #757 effectively solves this issue by way of caching the addresser state as effectively an immutable object.

We ultimately decided to shelve #757 for now because the addresser is presently in flux and we don't want to add anything stateful. We may revisit #757 after we feel confident the design of the addresser interface has settled down.