PennyLaneAI / PennyLaneAI/catalyst
Issues with `static_argnums` and `static_argnames` when using a pytree argument
Open
Nobody has claimed this yet.
bug
frontend
- Dominant language
- Python
- Stars
- 234
- Forks
- 84
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 66
Description
Seems to be a issues with qjit's static_argnames and static_argnums when an argument is a multi-argument pytree:
@qml.qjit(static_argnames="y")
def f(x, y):
if y:
return x['y']
return x['x']
@qml.qjit(static_argnums=1)
def g(x, y):
if y:
return x['y']
return x['x']
>>> f({"x": 0.0, "y": 1.0}, y="truthy")
CompileError: argnum 1 is beyond the valid range of [0, 1).```
>>> f({"x": 0.0, "y": 1.0}, "truthy")
TypeError: Argument 'truthy' of type <class 'str'> is not a valid JAX type
>>> g({"x": 0.0, "y": 1.0}, y="truthy")
CompileError: argnum 1 is beyond the valid range of [0, 1).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproducer for qjit with static_argnames and static_argnums exactly as shown, then trace how pytree arguments are counted and mapped to static arguments. Compare the reported CompileError and TypeError cases to the intended handling, and add coverage showing that both options work with the demonstrated pytree input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100