PennyLaneAI / PennyLaneAI/catalyst

Not detecting need for recompilation triggered by keyword arguments

Open
#2,182 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

qjit is not detecting the need for recompilation when keyword arguments change shape.

For example:

@qml.qjit
def f(x, y):
    return x + y
>>> f(1, y=2), f(1, y=jnp.array([2,2]))
(Array(3, dtype=int64), Array(3, dtype=int64))
>>> # redefine f
>>> f(1, y=jnp.array([3, 3])), f(1, y=2)
(Array([4, 4], dtype=int64), Array([3, 1], dtype=int64))

I would expect the behaviour with keyword arguments to match the behaviour where everything is passed positionally.

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 by reproducing the qjit example with positional and keyword arguments, comparing behavior when the keyword argument changes from a scalar to an array. Trace the recompilation path for qjit calls and add coverage for this case; done means keyword-argument shape changes trigger the same recompilation behavior as positional arguments.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.