Open notmgsk opened 1 year ago
This looks like a solid plan to me. I wonder if it would make sense to add this as an option to CompilerOpts
on the qcs-sdk-rust
side, then expose that to get_qc
and the compiler implementation.
Is quilc
used outside of the qc.compile
call, and if so, how is it used?
If not, I think it might make sense to put the new optional argument on qc.compile
, but I may be missing something.
Issue Description
libquil-sys
provides a Rust interface to the Quilc shared library. There is on-going work inqcs-sdk-rust
to uselibquil-sys
which will allow users ofqcs-sdk-rust
to use Quilc via TCP (RPCQ) or FFI (libquil-sys
). Providing that option means that users no longer have to manage the Quilc server, which has in the past been a source of some headaches.I would like to make that option available in pyquil v4. The problem this poses is a design question: how do we fit this new feature in alongside what currently exists?
Requirements:
Proposed Solution
The standard way of interacting with pyquil looks something like
To satisfy (c) above, I feel like the natural place for this change to be exposed is in
get_qc
where a new optional parameterquilc_mode
is introduced:QuilcMode
is Python enumThe
get_qc
machinery then passes this along to the appropriateAbstractCompiler
implementation, which can in turn use that information to decide (withinquil_to_native_quil
) whether to use RPCQ or libquil-sys. That logic will interpret aNone
value for thequilc_mode
parameter as being equivalent toQuilcMode.RPCQ
. Thus, requirement (a) above is satisfied.If a user opts-in to using
libquil-sys
, the change to their program would be minimal and look likewhich (IMO) satisfies both requirements (b) and (c).
To satisfy requirement (d) we would have to allow the initial implementation of
QuilcMode
to contain the singleRPCQ
variant, and thequil_to_native_quil
implementations would essentially ignore the argument. Later, when the full functionality is supported on the qcs-sdk-rust side, we can extend the enum to includeLIBQUIL
and amend thequil_to_native_quil
code to use theQuilcMode
appropriately.