-
Notifications
You must be signed in to change notification settings - Fork 6
Fix/pytket_worker #211
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
Fix/pytket_worker #211
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b7b039
Make qir dependents optional
philipp-seitz 507967a
Update lockfile
philipp-seitz 6071069
Add optional timeout parameter
philipp-seitz 692bb58
Add new builtins
philipp-seitz eb918f9
Update dependencies to be optional not group
philipp-seitz af48222
Make just run with all extras
philipp-seitz fe5b689
Add n_qubits_function
philipp-seitz 2eb2dde
Add stubs to main repo
philipp-seitz 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| uvrun := "uv run" | ||
| uvrun := "uv run --all-extras" | ||
|
|
||
| default: | ||
| @just --list | ||
|
|
||
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
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
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 |
|---|---|---|
|
|
@@ -17,11 +17,9 @@ | |
| from pytket.passes import BasePass | ||
| from pytket.pauli import QubitPauliString | ||
| from pytket.qasm.qasm import circuit_from_qasm_str, circuit_to_qasm_str | ||
| from pytket.qir.conversion.api import pytket_to_qir | ||
| from pytket.transform import Transform | ||
| from pytket.utils.expectations import expectation_from_counts | ||
| from pytket.utils.measurements import append_pauli_measurement | ||
| from pytket_qirpass import qir_to_pytket | ||
| from tierkreis.exceptions import TierkreisError | ||
|
|
||
| from tierkreis import Worker | ||
|
|
@@ -318,6 +316,10 @@ def to_qir_bytes(circuit: Circuit) -> bytes: | |
| :return: The circuit as QIR bytecode. | ||
| :rtype: bytes | ||
| """ | ||
| try: | ||
| from pytket.qir.conversion.api import pytket_to_qir | ||
| except ModuleNotFoundError: | ||
| raise TierkreisError("Could not resolve pytket.qir") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... do we specifically handle TierkreisError somewhere? If not then I wonder how much information this error message is adding? |
||
| ret = pytket_to_qir(circuit) | ||
| if not isinstance(ret, bytes): | ||
| raise TierkreisError("Error when converting Circuit to QIR.") | ||
|
|
@@ -333,6 +335,10 @@ def from_qir_bytes(qir: bytes) -> Circuit: | |
| :return: The corresponding pytket circuit. | ||
| :rtype: Circuit | ||
| """ | ||
| try: | ||
| from pytket_qirpass import qir_to_pytket | ||
| except ModuleNotFoundError: | ||
| raise TierkreisError("Could not resolve pytket_qirpass") | ||
| return qir_to_pytket(qir) | ||
|
|
||
|
|
||
|
|
@@ -349,6 +355,18 @@ def expectation(backend_result: BackendResult) -> float: | |
| return expectation | ||
|
|
||
|
|
||
| @worker.task() | ||
| def n_qubits(circuit: Circuit) -> int: | ||
| """Wrapper for pytket.Circuit.n_qubits. | ||
|
|
||
| :param circuit: The pytket circuit. | ||
| :type circuit: Circuit | ||
| :return: The number of qubits in that circuit. | ||
| :rtype: int | ||
| """ | ||
| return circuit.n_qubits | ||
|
|
||
|
|
||
| def main(): | ||
| worker.app(argv) | ||
|
|
||
|
|
||
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
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.
Is this still required now that we background the command?