#2014·warp

`wp.static()` around a built-in function raises `AttributeError: 'Function' object has no attribute 'user_overloads'`

Author: songyinggohCreated Sep 30, 2026Updated Sep 30, 2026

Bug Description

Wrapping a built-in function such as wp.tanh in wp.static() crashes while the module is being hashed. The same construct with a user @wp.func works.

python
import warp as wp

ACTIVATION = wp.tanh  # chosen at import time, e.g. from a config


@wp.kernel
def activate(x: wp.array[float]):
    i = wp.tid()
    x[i] = wp.static(ACTIVATION)(x[i])


x = wp.full(4, 0.5, dtype=float)
wp.launch(activate, dim=4, inputs=[x])
print(x.numpy())

Expected:

[0.4621172 0.4621172 0.4621172 0.4621172]

Actual, at wp.launch (or at declaration with module="unique"):

  File ".../warp/_src/context.py", line 11601, in launch
  File ".../warp/_src/context.py", line 4895, in load
  File ".../warp/_src/codegen.py", line 1822, in locked_call
  File ".../warp/_src/context.py", line 4389, in get_module_hash
  File ".../warp/_src/context.py", line 3036, in __init__
  File ".../warp/_src/context.py", line 3072, in hash_kernel
  File ".../warp/_src/context.py", line 3093, in _hash_kernel_identity
  File ".../warp/_src/context.py", line 3232, in hash_adjoint
  File ".../warp/_src/context.py", line 3126, in hash_function
AttributeError: 'Function' object has no attribute 'user_overloads'. Did you mean: 'get_overload'?

It also fails with wp.static(wp.sin)(x[i]) written literally, and with wp.tile_map(wp.static(op), t).

Likely cause. The wp.static() loop in ModuleHasher.hash_adjoint passes every Function to hash_function, which reads the user-function attribute user_overloads. The referenced-functions loop a few lines further down already sends built-ins to hash_builtin_function. Giving the static loop the same branch:

python
if isinstance(v, Function):
    if v.is_builtin():
        ch.update(self.hash_builtin_function(v))
    elif v not in self.functions_in_progress:
        ch.update(self.hash_function(v))

makes the repro above print the expected values, and test_module_hashing, test_static and test_codegen_instancing still pass (127 tests, CPU and CUDA).

How it affects my use. I build kernels from a factory that captures an op, like make_kernel(wp.exp). Without wp.static, factory kernels that differ only in a captured built-in get the same module hash and silently run the first op's code (the class of problem in #637). I reached for wp.static() to make the captured op part of the module hash, and with the change above that works: factory kernels for wp.sin, wp.exp and wp.sqrt get distinct modules and each computes its own op, both as wp.static(op)(x[i]) and as wp.tile_map(wp.static(op), t).

I'd be glad to open a PR with this change and a regression test, if an outside PR is wanted.

System Information

  • Warp 1.17.0 (PyPI) and 1.19.0.dev20260928 (784479fc); same code on main at 79067793e
  • Python 3.12.11, Windows 11
  • NVIDIA GeForce RTX 4070 Laptop GPU (sm_89), driver 617.14 (CUDA 13.4)
  • The error comes from module hashing, before anything is compiled, so it shouldn't depend on the device.