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

check user lattice name vs compiler lattice name #771

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pyquil/api/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,24 @@ def _collect_memory_descriptors(program: Program) -> Dict[str, ParameterSpec]:

class QPUCompiler(AbstractCompiler):
@_record_call
def __init__(self, endpoint: str, device: AbstractDevice, timeout: int = 10) -> None:
def __init__(self,
endpoint: str,
device: AbstractDevice,
timeout: int = 10,
name: Optional[str] = None) -> None:
"""
Client to communicate with the Compiler Server.

:param endpoint: TCP or IPC endpoint of the Compiler Server
:param device: PyQuil Device object to use as compilation target
:param timeout: Number of seconds to wait for a response from the client.
:param name: Name of the lattice being targeted
"""

self.client = Client(endpoint, timeout=timeout)
self.target_device = TargetDevice(isa=device.get_isa().to_dict(),
specs=device.get_specs().to_dict())
self.name = name

def get_version_info(self) -> dict:
return self.client.call('get_version_info')
Expand All @@ -160,6 +166,11 @@ def native_quil_to_executable(self, nq_program: Program) -> BinaryExecutableResp
"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!")
if self.name is not None:
targeted_lattice = self.client.call('get_config_info')['lattice_name']
if targeted_lattice and targeted_lattice != self.name:
warnings.warn(f'You requested compilation for device {self.name}, '
f'but you are engaged on device {targeted_lattice}.')

arithmetic_request = RewriteArithmeticRequest(quil=nq_program.out())
arithmetic_response = self.client.call('resolve_gate_parameter_arithmetic', arithmetic_request)
Expand Down
3 changes: 2 additions & 1 deletion pyquil/api/_quantum_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ def get_qc(name: str, *, as_qvm: bool = None, noisy: bool = None,
device=device,
compiler=QPUCompiler(
endpoint=pyquil_config.compiler_url,
device=device))
device=device,
name=prefix))


@contextmanager
Expand Down