Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
self._connect_qpu_compiler()
if nq_program.native_quil_metadata is None:
warnings.warn(
"It looks like you're trying to call `native_quil_to_binary` on a "
"Program that hasn't been compiled via `quil_to_native_quil`. This is "
"ok if you've hand-compiled your program to our native gateset, "
"but be careful!"
)
arithmetic_request = RewriteArithmeticRequest(quil=nq_program.out())
arithmetic_response = self.quilc_client.call("rewrite_arithmetic", arithmetic_request)
request = BinaryExecutableRequest(
quil=arithmetic_response.quil, num_shots=nq_program.num_shots
)
response = self.qpu_compiler_client.call("native_quil_to_binary", request)
# hack! we're storing a little extra info in the executable binary that we don't want to
# expose to anyone outside of our own private lives: not the user, not the Forest server,
# not anyone.
response.recalculation_table = arithmetic_response.recalculation_table
response.memory_descriptors = _collect_memory_descriptors(nq_program)
response.ro_sources = _collect_classical_memory_write_locations(nq_program)
return response