warp icon indicating copy to clipboard operation
warp copied to clipboard

[BUG] Warp does not auto-initialize when working with half precision

Open shi-eric opened this issue 3 months ago • 1 comments

Bug Description

The expected behavior is that the user shouldn't need to explicitly invoke wp.init() when using the public API functions.

>>> import warp as wp
>>> a = wp.vec2h(2,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/eshi/code-projects/warp/warp/types.py", line 324, in __init__
    super().__setitem__(i, vec_t.scalar_import(args[i]))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eshi/code-projects/warp/warp/types.py", line 181, in float_to_half_bits
    return warp.context.runtime.core.wp_float_to_half_bits(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'core'

This is because float_to_half_bits and half_bits_to_float both call into the native library.

System Information

No response

shi-eric avatar Sep 18 '25 16:09 shi-eric

Moving to backlog for now as this has the potential to add a lot of overhead.

shi-eric avatar Oct 08 '25 23:10 shi-eric