Skip to content
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

fix wasm issues #1691

Merged
merged 23 commits into from
Nov 26, 2024
Merged

fix wasm issues #1691

merged 23 commits into from
Nov 26, 2024

Conversation

cqc-melf
Copy link
Contributor

@cqc-melf cqc-melf commented Nov 21, 2024

Description

Fixes:
#1641
#1504
#1546

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

@cqc-melf cqc-melf force-pushed the melf/fix-wasm-issue branch from 8879c3e to db9cdd6 Compare November 21, 2024 18:39
@cqc-melf cqc-melf requested a review from cqc-alec November 21, 2024 18:43
@cqc-melf cqc-melf marked this pull request as ready for review November 21, 2024 22:14
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the appending tests here involve appending to an empty circuit. Could we add some tests appending to a circuit that already contains WASM wires?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added one, see d9e6dac

There is also one in the python tests already.

pytket/tests/classical_test.py Show resolved Hide resolved
tket/src/Circuit/macro_manipulation.cpp Show resolved Hide resolved
@@ -413,6 +413,9 @@ void def_circuit(py::class_<Circuit, std::shared_ptr<Circuit>> &pyCircuit) {
.def_property_readonly(
"n_gates", &Circuit::n_gates,
":return: the number of gates in the Circuit")
.def_property_readonly(
"wasm_uid", &Circuit::get_wasm_file_uid,
":return: the wasm uid of the first wasmop found in the circuit")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a circuit contain more than one WASM UID? If so it would be preferable to return the full set here. If not, we can be explicit about this in the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only be one

@cqc-melf cqc-melf force-pushed the melf/fix-wasm-issue branch from c035e24 to ac1eb5a Compare November 22, 2024 13:52
@cqc-melf cqc-melf force-pushed the melf/fix-wasm-issue branch from ac1eb5a to 14b5146 Compare November 22, 2024 13:56
@cqc-melf cqc-melf requested a review from cqc-alec November 22, 2024 14:30
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one suggestion, making the wasm ID an optional string (None if no WASM ID).


assert c.depth() == 0
with pytest.raises(ValueError):
c.wasm_uid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a bit nicer if this returned None when there is no WASM wire, rather than throw an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in de111a1

@cqc-melf
Copy link
Contributor Author

@cqc-alec Is it expected that some changes to the stubs do not make the check fail? As you can see in the last commit, there have been some changes, that did not show up on the CI?

std::optional<std::string> result;
try {
result = circ.get_wasm_file_uid();
} catch (const std::exception &) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we propagate the change to the C++, i.e. male get_wasm_file_uid() return a std::optional<std::string>? I think that's better than a catch-all exception handler, and could actually make the C++ code nicer too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 00c3b30

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from math import isclose, pow
from math import isclose, pow # noqa: A004
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest just removing the pow import and using the built-in one; as used in this file there is no difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in the merge commit

@cqc-alec
Copy link
Collaborator

@cqc-alec Is it expected that some changes to the stubs do not make the check fail? As you can see in the last commit, there have been some changes, that did not show up on the CI?

Not sure what you mean here. In the last commit both the binder code and the stubs changed, so I would not expect the check fail?

"""
:return: the wasm uid of the first wasmop found in the circuit
:return: the unique wasm uid of the circuit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cqc-alec this line was already changed in the other commit, but the stubs check has not shown this difference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly it should fail if they don't match, but I'm struggling to see where there is/was a mismatch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was changed in 14b5146, but the CI check has not show this difference.

@cqc-melf cqc-melf requested a review from cqc-alec November 22, 2024 17:48
pytket/binders/circuit/Circuit/main.cpp Show resolved Hide resolved
pytket/binders/circuit/Circuit/main.cpp Outdated Show resolved Hide resolved
tket/src/Circuit/macro_manipulation.cpp Outdated Show resolved Hide resolved
@@ -1,13 +1,22 @@
Changelog
=========

Unreleased
----------
1.36.0 (unreleased)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to keep this as "Unreleased" only. We don't know if it will be 1.36.0 or 1.35.1 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 37f0f1b

cqc-melf and others added 8 commits November 26, 2024 09:14
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
@cqc-melf cqc-melf force-pushed the melf/fix-wasm-issue branch from 4c2a42f to 218ccd5 Compare November 26, 2024 12:00
@cqc-melf cqc-melf requested a review from cqc-alec November 26, 2024 13:15
@cqc-melf cqc-melf merged commit a5f3169 into main Nov 26, 2024
32 checks passed
@cqc-melf cqc-melf deleted the melf/fix-wasm-issue branch November 26, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants