Skip to content

[BUG] abstracted_axes throws AttributeError in Pennylane QJIT #1781

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
1 task done
sengthai opened this issue Jun 3, 2025 · 0 comments
Open
1 task done

[BUG] abstracted_axes throws AttributeError in Pennylane QJIT #1781

sengthai opened this issue Jun 3, 2025 · 0 comments

Comments

@sengthai
Copy link
Contributor

sengthai commented Jun 3, 2025

Expected behavior

The code should run without errors and produce 1 and 4.

Actual behavior

Throws the error message:


AttributeError: 'tensor' object has no attribute 'aval'. Did you mean: 'ravel'?

Additional information

No response

Source code

import pennylane as qml
from pennylane import qjit
import pennylane.numpy as jnp

dev = qml.device("lightning.qubit", wires=1)

@qjit(verbose=True, abstracted_axes={0:"n"})
def sum_abstracted(arr):
    return jnp.sum(arr)

print(sum_abstracted(jnp.array([1])))  
print(sum_abstracted(jnp.array([1, 1, 2])))

Tracebacks

Traceback (most recent call last):
  File "/Users/sengthai.heng/Developer/test/pennylane_qjit.py", line 15, in <module>
    print(sum_abstracted(jnp.array([1])))  
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/pennylane/logging/decorators.py", line 61, in wrapper_entry
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/catalyst/jit.py", line 606, in __call__
    return self.run(args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/catalyst/debug/instruments.py", line 145, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/pennylane/logging/decorators.py", line 61, in wrapper_entry
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/catalyst/jit.py", line 820, in run
    results = self.compiled_function(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/catalyst/compiled_functions.py", line 337, in __call__
    dynamic_args = get_implicit_and_explicit_flat_args(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/catalyst/jax_extras/tracing.py", line 491, in get_implicit_and_explicit_flat_args
    implicit_args = _extract_implicit_args(in_type, explicit_args)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sengthai.heng/Developer/test/.venv/lib/python3.12/site-packages/jax/_src/pjit.py", line 657, in _extract_implicit_args
    for d1, d2 in zip(aval.shape, arg.aval.shape):
                                  ^^^^^^^^
                                  ^^^^^^^^
AttributeError: 'tensor' object has no attribute 'aval'. Did you mean: 'ravel'?

System information

Name: PennyLane
Version: 0.41.1
Platform info:           macOS-15.5-arm64-arm-64bit
Python version:          3.12.0
Numpy version:           2.0.2
Scipy version:           1.15.1

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
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

No branches or pull requests

1 participant