Add support for direct Jaqal ingestion with JaqalService()#1364
Conversation
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for compiling Jaqal program strings directly via a new Service.jaqal_compile() API, while also refactoring shared QSCOUT option validation and consolidating duplicated CompilerOutput logic into general_superstaq.
Changes:
- Add
Service.jaqal_compile()to compile Jaqal strings for QSCOUT targets, including ECA support. - Centralize QSCOUT option validation in
general_superstaq.validation.get_validated_qscout_options()and reuse it from Cirq/Qiskit QSCOUT compile entrypoints. - Introduce
general_superstaq.compiler_output.BaseCompilerOutputand migrate Cirq/QiskitCompilerOutputto inherit from it.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| qiskit-superstaq/qiskit_superstaq/superstaq_backend.py | Refactors QSCOUT option-building to use shared validation helper. |
| qiskit-superstaq/qiskit_superstaq/compiler_output.py | Switches CompilerOutput to inherit from shared base; updates Jaqal subcircuit aggregation call site. |
| general-superstaq/general_superstaq/validation.py | Adds Jaqal qubit inference and a shared QSCOUT options validator. |
| general-superstaq/general_superstaq/validation_test.py | Adds unit tests for Jaqal qubit inference. |
| general-superstaq/general_superstaq/service.py | Adds Service.jaqal_compile() for direct Jaqal ingestion/compilation. |
| general-superstaq/general_superstaq/service_test.py | Adds tests covering jaqal_compile() behaviors (single, list, ECA, invalid inputs). |
| general-superstaq/general_superstaq/compiler_output.py | New shared BaseCompilerOutput and Jaqal-specific read_json_jaqal(). |
| general-superstaq/general_superstaq/compiler_output_test.py | Adds tests for new compiler output behavior (repr/eq basics). |
| general-superstaq/general_superstaq/init.py | Exports BaseCompilerOutput and compiler_output module. |
| cirq-superstaq/cirq_superstaq/service.py | Refactors QSCOUT option-building to use shared validation helper. |
| cirq-superstaq/cirq_superstaq/compiler_output.py | Switches CompilerOutput to inherit from shared base; updates Jaqal subcircuit aggregation call site. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
|
Discussion from dev meeting: instead of |
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
| `jaqal_programs`. | ||
| """ | ||
| target = gss.validation.validate_target(target) | ||
| circuits_is_list = not isinstance(jaqal_programs, str) |
There was a problem hiding this comment.
if this is a string could it still contain subcircuits? if so maybe we just make this
| circuits_is_list = not isinstance(jaqal_programs, str) | |
| circuits_is_list = True |
to avoid randomly changing return types between one and two+ subcircuits
There was a problem hiding this comment.
Currently, the server will always return a list, so if there were subcircuits, that is handled via the check in read_json_jaqal:
If circuits_is_list is always True, we wouldn't be able to use the singular .circuit attribute right?
There was a problem hiding this comment.
ah, missed the check in read_json_jaqal, and also forgot we provide .jaqal_program(s) regardless of circuits_is_list (though maybe that raises a question about whether the compiler output from jaqal service should just use .circuit(s) instead of .jaqal_program(s)?)
we wouldn't be able to use the singular .circuit attribute right?
my thinking was that this would make sense in this case, because if i pass a single jaqal string there's no way to tell if i intended it to be a standalone circuit or a program with a single subcircuit (and imo it's not great to change switch just given the number of circuits, because it makes the result type inconsistent in any sort of scripting). but feel less strongly due to the existence of .jaqal_program(s) (and the coming deprecation of compiler outputs anyway)
There was a problem hiding this comment.
I initially went with circuits_is_list = True, so I'm not opposed to it since the attribute change isn't elegant (I think I didn't want to index by 0 for single-str inputs). However, in light of the review, I've just made it always a list with 77ca880. Let me know if that works better
| Q = TypeVar("Q") | ||
|
|
||
|
|
||
| class BaseCompilerOutput(Generic[C, Q]): # noqa: PLW1641 |
There was a problem hiding this comment.
love the use of generics here - wondering if we could do something similar for BaseService (obviously not for this pr though)
There was a problem hiding this comment.
Yeah probably, but feels like we would end up implementing the specific overrides anyway (e.g., because of different serializations etc), so would have to see how much more is consolidated and not duplicated. Regardless, will leave for another PR when the SuperstaqClientV3 becomes the norm
There was a problem hiding this comment.
ah good point, that's probably true
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
Signed-off-by: Bharath <bharath.thotakura@infleqtion.com>
jaqal_compile()JaqalService()
richrines1
left a comment
There was a problem hiding this comment.
lgtm! (assuming tests will pass after #1380)
Yup, they should (except for the unrequired notebook checks) |
No description provided.