Skip to content
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

fix: only rewrite arithmetic when targeting Aspen processors #1679

Merged
merged 10 commits into from
Oct 18, 2023
16 changes: 13 additions & 3 deletions pyquil/api/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,20 @@ def native_quil_to_executable(

If `api_options` is provided, it overrides the options set on `self`.
"""
rewrite_response = rewrite_arithmetic(nq_program.out())
program = nq_program.out()
recalculation_table = []
# NOTE: There is an incompatibility between backends v1 and v2: v1 expects
# arithmetic to have been rewritten by the client, while v2 expects
# arithmetic _not_ to have been rewritten by the client. Since Aspen-M-3
# is the last of our QPUs that requires backend v1, we only rewrite arithmetic
# for that particular QPU. Once Aspen-M-3 is EOL, we can remove this.
if self.quantum_processor_id == "Aspen-M-3":
notmgsk marked this conversation as resolved.
Show resolved Hide resolved
rewrite_response = rewrite_arithmetic(nq_program.out())
program = rewrite_response.program
recalculation_table = list(rewrite_response.recalculation_table)

translated_program = translate(
native_quil=rewrite_response.program,
native_quil=program,
num_shots=nq_program.num_shots,
quantum_processor_id=self.quantum_processor_id,
translation_options=api_options or self.api_options,
Expand All @@ -121,7 +131,7 @@ def native_quil_to_executable(
program=translated_program.program,
memory_descriptors=_collect_memory_descriptors(nq_program),
ro_sources={parse_mref(mref): source for mref, source in ro_sources.items() or []},
recalculation_table=list(rewrite_response.recalculation_table),
recalculation_table=recalculation_table,
)

def _fetch_calibration_program(self) -> Program:
Expand Down