quil-lang / quilc

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

bugfix: copy-instance was not robust enough #905

Closed macrologist closed 11 months ago

macrologist commented 11 months ago

This partially addresses one source of "nondeterminism" in quilc compilation (see #676) that was due to a violation of referential transparency.

Specifically, non destructive compilation was not non-destructive enough: compiling the same parsed-program instance twice produced two different outputs. This was because copy-instance did not copy instances of measurement deeply, resulting in different outputs from compress-qubits, with downstream consequences.

This only addresses #676 in those cases where you are not parsing the same raw text-based source everytime you compile. Or equivalently, when you are not rebuilding your Program object from pyquil every time.

macrologist commented 11 months ago

(oh: I commented out the clifford tests b/c they've been failing for a while now and I wanted to sanity check my change, we might consider this PR, and any other wide-range-effect PRs to be blocked until the clifford modules and tests are loading, building, and passing again --- I think its just a quicklisp issue; waiting on an update.)

stylewarning commented 11 months ago

what a great find

stylewarning commented 11 months ago

re-enable clifford tests and we can merge

macrologist commented 11 months ago

turns out the cliffort tests are failing b/c the fucntion cl-permutation::iota-vector does not produce values of type cl-permutation::raw-perm. the former is being used to to produce permutation representations passed in to cl-permutation::%make-perm, throwing a type error. Sit tight.

macrologist commented 11 months ago

should be good