-
Notifications
You must be signed in to change notification settings - Fork 58
fix wasm issue #2151
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
Open
cqc-melf
wants to merge
7
commits into
main
Choose a base branch
from
melf/melf/fix-wasm-box
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix wasm issue #2151
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d898f92
fix wasm issue
cqc-melf 824d715
Update pytket/docs/changelog.md
cqc-melf 2927cc3
add fix for rng
cqc-melf 9d021a8
add link to issues
cqc-melf 5eb0c01
remove comment
cqc-melf 275465c
update tests
cqc-melf 3471f59
fix ci
cqc-melf 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 +1 @@ | ||
| 2.1.79 | ||
| 2.1.80 |
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 |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ | |
| reg_lt, | ||
| reg_neq, | ||
| ) | ||
| from pytket.passes import DecomposeClassicalExp | ||
| from pytket.passes import DecomposeBoxes, DecomposeClassicalExp | ||
|
|
||
| curr_file_path = Path(__file__).resolve().parent | ||
|
|
||
|
|
@@ -904,6 +904,52 @@ def test_wasm_circuit_bits() -> None: | |
| DrawType = Callable[[SearchStrategy[T]], T] | ||
|
|
||
|
|
||
| def test_wasm_box() -> None: | ||
|
|
||
| wasm_module = wasm.WasmFileHandler("testfile.wasm") | ||
|
|
||
| A = BitRegister("A", 1) | ||
| B = BitRegister("B", 1) | ||
|
|
||
| c0 = Circuit() | ||
| c0.add_c_register(A) | ||
| c0.add_c_register(B) | ||
| c0.add_wasm_to_reg("add_one", wasm_module, [A], [B]) | ||
| c0box = CircBox(c0) | ||
|
|
||
| c1 = Circuit() | ||
| c1.add_c_register(A) | ||
| c1.add_c_register(B) | ||
| c1.add_circbox_regwise(c0box, qregs=[], cregs=[A, B]) | ||
|
|
||
| DecomposeBoxes().apply(c1) | ||
|
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. For completeness' sake can we add some test assertion about the result?
Contributor
Author
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. Done, see @cqc-melf |
||
|
|
||
| assert c1.depth() == 1 | ||
| assert str(c1.get_commands()[0]) == "WASM A[0], B[0], _w[0];" | ||
|
|
||
|
|
||
| def test_rng_box() -> None: | ||
|
|
||
| A = BitRegister("A", 32) | ||
|
|
||
| c0 = Circuit() | ||
| c0.add_c_register(A) | ||
| c0.get_rng_num(A) | ||
| c0box = CircBox(c0) | ||
|
|
||
| c1 = Circuit() | ||
| c1.add_c_register(A) | ||
| c1.add_circbox_regwise(c0box, qregs=[], cregs=[A]) | ||
|
|
||
| DecomposeBoxes().apply(c1) | ||
|
|
||
| assert c1.depth() == 1 | ||
| assert ( | ||
| str(c1.get_commands()[0]) | ||
| == "RNGNum A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[8], A[9], A[10], A[11], A[12], A[13], A[14], A[15], A[16], A[17], A[18], A[19], A[20], A[21], A[22], A[23], A[24], A[25], A[26], A[27], A[28], A[29], A[30], A[31], _r[0];" | ||
| ) | ||
|
|
||
|
|
||
| @strategies.composite | ||
| def bit_register( | ||
| draw: DrawType, | ||
|
|
||
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
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.
I suggest (here and below) adding a comment explaining the cause of this and that multiple WASM wires could still be an issue (though unlikely to arise in practice).
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.
done, see @cqc-melf
add link to issues
9d021a8