kompute
kompute copied to clipboard
pyshader appears to be retired and failing
So pyshader github repo seems to be retired, and the examples are failing for me with
pytest ./test_array_multiplication.py
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.12.2, pytest-7.4.3, pluggy-1.3.0
rootdir: /fast/devel/kompute
collected 1 item
test_array_multiplication.py F [100%]
=============================================================================== FAILURES ================================================================================
_______________________________________________________________________ test_array_multiplication _______________________________________________________________________
def test_array_multiplication():
# 1. Create Kompute Manager (selects device 0 by default)
mgr = kp.Manager()
# 2. Create Kompute Tensors to hold data
tensor_in_a = mgr.tensor(np.array([2, 2, 2]))
tensor_in_b = mgr.tensor(np.array([1, 2, 3]))
tensor_out = mgr.tensor(np.array([0, 0, 0]))
params = [tensor_in_a, tensor_in_b, tensor_out]
# 4. Define the multiplication shader code to run on the GPU
> @ps.python2shader
test_array_multiplication.py:19:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/airlied/.local/lib/python3.12/site-packages/pyshader/py.py:43: in python2shader
converter.convert(func, shader_type)
/home/airlied/.local/lib/python3.12/site-packages/pyshader/py.py:181: in convert
self._convert()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pyshader.py.PyBytecode2Bytecode object at 0x7f6ff032f920>
def _convert(self):
self._line_bump_index = 0
self._pointer = 0
while self._pointer < len(self._py_bytecode):
if (
self._loops_to_handle
and self._pointer == self._loops_to_handle[0]["start"]
):
self._start_loop(self._loops_to_handle.pop(0))
elif self._pointer == self._loop_stack[-1].get("end"):
self._end_loop()
elif (
self._pointer in self._labels
and self._pointer not in self._protected_labels
):
label = self._labels[self._pointer]
last_opcode = self._opcodes[-1][0]
if last_opcode not in (
"co_branch",
"co_branch_conditional",
"co_branch_loop",
):
self.emit(op.co_branch, label)
self.emit(op.co_label, label)
for instruction in self._insert_at.get(self._pointer, []):
self.emit(*instruction)
opname, arg = self._next()
print(opname.lower())
method_name = "_op_" + opname.lower()
method = getattr(self, method_name, None)
if method is None:
pprint_bytecode(self._co)
> raise RuntimeError(
self.errinfo()
+ f"Cannot parse py's {opname} yet (no {method_name}())."
)
E RuntimeError:
E Source file "/fast/devel/kompute/python/test/test_array_multiplication.py", line 19, in compute_mult
E @ps.python2shader
E Cannot parse py's BUILD_MAP_UNPACK_WITH_CALL yet (no _op_build_map_unpack_with_call()).
/home/airlied/.local/lib/python3.12/site-packages/pyshader/py.py:255: RuntimeError
------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
build_map_unpack_with_call
19 0 RESUME 0
24 2 LOAD_FAST 0 (index)
4 LOAD_ATTR 0 (x)
24 STORE_FAST 4 (i)
25 26 LOAD_FAST 1 (data1)
28 LOAD_FAST 4 (i)
30 BINARY_SUBSCR
34 LOAD_FAST 2 (data2)
36 LOAD_FAST 4 (i)
38 BINARY_SUBSCR
42 BINARY_OP 5 (*)
46 LOAD_FAST 3 (data3)
48 LOAD_FAST 4 (i)
50 STORE_SUBSCR
54 RETURN_CONST 0 (None)
=========================================================================== warnings summary ============================================================================
python/test/test_array_multiplication.py::test_array_multiplication
/home/airlied/.local/lib/python3.12/site-packages/pyshader/py.py:57: DeprecationWarning: co_lnotab is deprecated, use co_lines instead.
for i in range(0, len(co.co_lnotab), 2):
python/test/test_array_multiplication.py::test_array_multiplication
python/test/test_array_multiplication.py::test_array_multiplication
/home/airlied/.local/lib/python3.12/site-packages/pyshader/py.py:58: DeprecationWarning: co_lnotab is deprecated, use co_lines instead.
addr_incr = co.co_lnotab[i]
python/test/test_array_multiplication.py::test_array_multiplication
python/test/test_array_multiplication.py::test_array_multiplication
/home/airlied/.local/lib/python3.12/site-packages/pyshader/py.py:59: DeprecationWarning: co_lnotab is deprecated, use co_lines instead.
line_incr = co.co_lnotab[i + 1]
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================== short test summary info ========================================================================
FAILED test_array_multiplication.py::test_array_multiplication - RuntimeError:
===================================================================== 1 failed, 5 warnings in 0.24s =====================================================================
This seems like a bug in pyshader, but it isn't getting updates then it probably should be moved on from.
I would be keen to find an alternative to pyshader but seems there's no similar libraries to achieve this - currently CI examples are passing, perhaps this is a python compatibility issue