-
Notifications
You must be signed in to change notification settings - Fork 4
feat: next-gen jobs #152
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
Merged
Merged
feat: next-gen jobs #152
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
035a456
chore: commit devenv.lock
vanyae-cqc 03a8bcc
chore: wip next-gen jobs
vanyae-cqc d26a242
wip next gen
vanyae-cqc ac64100
Merge branch 'main' into feat/next-gen-jobs
vanyae-cqc e0a5964
wip
vanyae-cqc d0d409d
chore: merge main
vanyae-cqc b8ac2a6
feat: next-gen jobs
vanyae-cqc 443af97
feat: result_type in process-job-item list
vanyae-cqc ac8f090
feat: next-gen results
vanyae-cqc 808f127
chore: use quantinuum-schemas 2.1.0
vanyae-cqc bf456c1
chore: mypy fixes
vanyae-cqc c23556a
chore: update respx for compatibility with httpx
vanyae-cqc 4cb18f5
test: add qsys execution job test
vanyae-cqc 0a6fd0f
chore: disable hugr compression for now
vanyae-cqc e30210f
test: ci integration test qsys device
vanyae-cqc c7ed2c0
chore: correct variable name
vanyae-cqc c5d67d7
chore: clean up PR
vanyae-cqc 54104f8
test: skip qsys integration test for now
vanyae-cqc fd470f7
test: fix skipped test importing
vanyae-cqc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| # qnexus integration test suite | ||
|
|
||
| These tests are intended to be runnable against any Nexus environment by any user (with quotas enabled for basic Nexus usage). | ||
| The tests will login the user and create all projects/resources required, deleting them once the test suite has run (TODO). | ||
| The tests will login the user and create all projects/resources required, deleting them once the test suite has run. | ||
|
|
||
| In general we target the Nexus staging environment at https://staging.myqos.com using the | ||
| In general we target the Nexus QA environment at https://qa.myqos.com using the | ||
| QA test user with email: 'qa_nexus_staging_pytket-nexus@mailsac.com'. | ||
|
|
||
| Requires the following environment variables to be set: | ||
|
|
||
| - NEXUS_USER_EMAIL | ||
| - NEXUS_USER_PASSWORD | ||
| - NEXUS_HOST (to avoid targetting prod by default) | ||
| - NEXUS_QA_QSYS_DEVICE (for executing HUGR programs on a next-gen qsys device) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| """Tests related to running jobs against QSys devices.""" | ||
| import os | ||
| from datetime import datetime | ||
| from typing import cast | ||
|
|
||
| from guppylang import guppy | ||
| from guppylang.std.builtins import result | ||
| from guppylang.std.quantum import cx, h, measure, qubit, x, z | ||
| from pytket.backends.backendinfo import BackendInfo | ||
| from quantinuum_schemas.models.result import QSysResult | ||
|
|
||
| import qnexus as qnx | ||
|
|
||
| QSYS_QA_DEVICE_NAME = os.environ["NEXUS_QA_QSYS_DEVICE"] | ||
| N_SHOTS = 10 | ||
|
|
||
|
|
||
| def prepare_teleportation(): | ||
| """Prepares the teleportation circuit.""" | ||
|
|
||
| @guppy | ||
| def bell() -> tuple[qubit, qubit]: | ||
| # pylint: disable=too-many-function-args | ||
| """Constructs a bell state.""" | ||
| q1, q2 = qubit(), qubit() | ||
| h(q1) | ||
| cx(q1, q2) | ||
| return q1, q2 | ||
|
|
||
| @guppy | ||
| def main() -> None: | ||
| # pylint: disable=too-many-function-args | ||
| src = qubit() | ||
| x(src) | ||
| alice, bob = bell() | ||
|
|
||
| cx(src, alice) | ||
| h(src) | ||
| if measure(alice): | ||
| x(bob) | ||
| if measure(src): | ||
| z(bob) | ||
|
|
||
| result("teleported", measure(bob)) # type: ignore | ||
|
|
||
| return main.compile() | ||
|
|
||
|
|
||
| def test_guppy_execution( | ||
| _authenticated_nexus: None, | ||
| qa_project_name: str, | ||
| ) -> None: | ||
| """Test the execution of a guppy program | ||
| on a next-generation QSys device.""" | ||
|
|
||
| # Compile the guppy program | ||
| compiled_module = prepare_teleportation() | ||
| hugr_package = compiled_module.to_executable_package().package | ||
|
|
||
| project_ref = qnx.projects.get_or_create(name=qa_project_name) | ||
|
|
||
| hugr_ref = qnx.hugr.upload( | ||
| hugr_package=hugr_package, | ||
| name="QA testing teleportation program", | ||
| project=project_ref, | ||
| ) | ||
|
|
||
| job_ref = qnx.start_execute_job( | ||
| circuits=[hugr_ref], | ||
| n_shots=[N_SHOTS], | ||
| backend_config=qnx.QuantinuumConfig(device_name=QSYS_QA_DEVICE_NAME), | ||
| project=project_ref, | ||
| name=f"QA Test QSys job from {datetime.now()}", | ||
| ) | ||
|
|
||
| # QSYS QA device might not always be online, so we might expect failures for now | ||
| qnx.jobs.wait_for(job_ref) | ||
|
|
||
| results = qnx.jobs.results(job_ref) | ||
|
|
||
| assert len(results) == 1 | ||
| result_ref = results[0] | ||
|
|
||
| assert isinstance(result_ref.download_backend_info(), BackendInfo) | ||
| assert isinstance(result_ref.get_input(), hugr_package) | ||
|
|
||
| assert result_ref.get_input().id == hugr_ref.id | ||
|
|
||
| qsys_result = cast(QSysResult, result_ref.download_result()) | ||
| assert len(qsys_result) == N_SHOTS | ||
| assert qsys_result[0][0][0] == "teleported" | ||
| assert qsys_result[0][0][1] == 0 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the comments (and the reality) about the QSYS QA device not always being online, should we consider marking this test with @Skip for now?
Also - if the env var "NEXUS_QA_QSYS_DEVICE" is not present, this python file will raise an exception on import. Maybe we could
skip_ifthe env var is absent. Then normal runs of the tests will continue to work as before. Just a suggestion thoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could certainly, wasn't sure what the best approach was here but wanted to make sure there was at least some sort of test. Think its ok to @Skip for now and then look towards a proper test device in the future (e.g. selene)