PennyLaneAI / PennyLaneAI/catalyst

`split_non_commuting`'s expected `PyTreeDef` does not match observed `PyTreeDef`

Open
#1,099 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
234
Forks
84
Avg merge
2d 15h
Merged PRs (30d)
66

Description

  • Expected behavior:

In pytest/test_transform.py, when changing @sum_expand in TestSumExpand to @qml.transforms.split_non_commuting as suggested by the warning, I expect the tree def to remain the same.

  • Actual behavior: A tuple is returned instead of a list.
diff --git a/frontend/test/pytest/test_transform.py b/frontend/test/pytest/test_transform.py
index 9fcb8457..a616bdb6 100644
--- a/frontend/test/pytest/test_transform.py
+++ b/frontend/test/pytest/test_transform.py
@@ -41,7 +41,7 @@ try:
 except:  # pylint: disable=bare-except
     from pennylane.transforms import qcut
 
-from pennylane.transforms import merge_rotations, sum_expand
+from pennylane.transforms import merge_rotations
 
 from catalyst import measure, qjit
 from catalyst.utils.exceptions import CompileError
@@ -375,7 +375,7 @@ class TestSumExpand:
         def qnode_builder(device_name):
             """Builder"""
 
-            @sum_expand
+            @qml.transforms.split_non_commuting
             @qml.qnode(qml.device(device_name, wires=2, shots=None))
             def qfunc():
                 """Example taken from PL tests"""

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in frontend/test/pytest/test_transform.py, focusing on TestSumExpand and its qnode_builder. Compare the behavior of @sum_expand with @qml.transforms.split_non_commuting and run the relevant transform test. Done means the replacement produces the expected PyTreeDef rather than returning a tuple where a list is expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.