Describe the bug
Repeated identical qd.Vector.ndarray.fill() or qd.Matrix.ndarray.fill() calls create a new internal fill_ndarray_matrix specialization on Windows/Vulkan.
To Reproduce
import quadrants as qd
from quadrants.lang import impl
qd.init(arch=qd.vulkan, offline_cache=False, src_ll_cache=False)
from quadrants._kernels import fill_ndarray_matrix
try:
arr = qd.Vector.ndarray(2, qd.f32, shape=(8,))
kernel = getattr(fill_ndarray_matrix, "_primal", fill_ndarray_matrix)
arr.fill(1.0)
first = len(kernel.materialized_kernels)
arr.fill(1.0)
second = len(kernel.materialized_kernels)
print(first, second, impl.get_runtime().get_num_compiled_functions())
assert second == first
finally:
qd.reset()
Log/Screenshots
The reproducer was run against the PyPI release with quadrants==1.3.0:
$ tmp\\quadrants-release-venv\\Scripts\\python.exe tmp\\repro_ndarray_fill_recompilation.py
[Quadrants] version 1.3.0, llvm 22.1.0, commit ab9a58ab, win, python 3.13.15
[Quadrants] Starting on arch=vulkan
python: 3.13.15
platform: Windows-11-10.0.26200-SP0
quadrants: (1, 3, 0) (C:\\Users\\15196\\Desktop\\workspace\\quadrants\\tmp\\quadrants-release-venv\\Lib\\site-packages\\quadrants\\__init__.py)
backend: Arch.vulkan
materialized fill_ndarray_matrix: 0 -> 1 -> 2
runtime compiled-function count: 1 -> 2
Traceback (most recent call last):
File "C:\\Users\\15196\\Desktop\\workspace\\quadrants\\tmp\\repro_ndarray_fill_recompilation.py", line 59, in <module>
assert after_second == after_first, (
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: same-value ndarray.fill() created a new fill_ndarray_matrix specialization: 1 -> 2
The same result was observed with qd.Matrix.ndarray(2, 2, qd.f32, shape=(8,)): materialized-kernel count 1 -> 2 after two identical fill(1.0) calls.
Environment:
OS: Windows 11 Pro for Workstations, build 26200, AMD64
Python: 3.13.15
Quadrants: 1.3.0, packaged commit ab9a58ab
LLVM: 22.1.0
Backend: qd.vulkan
GPU: NVIDIA GeForce RTX 5060
NVIDIA driver: 610.62
CUDA UMD: 13.3
Additional comments
The fill result is correct. The suspected cause is that the internal helper receives val as a qd.template() argument, while _fill_by_kernel() constructs a new Matrix/Vector object on every call and Matrix.__hash__() uses object identity (id(self)). Thus identical values produce distinct specialization keys.
The source checkout was not compiled for this report; the behavior above is from the installed PyPI wheel.
Describe the bug
Repeated identical
qd.Vector.ndarray.fill()orqd.Matrix.ndarray.fill()calls create a new internalfill_ndarray_matrixspecialization on Windows/Vulkan.To Reproduce
Log/Screenshots
The reproducer was run against the PyPI release with
quadrants==1.3.0:The same result was observed with
qd.Matrix.ndarray(2, 2, qd.f32, shape=(8,)): materialized-kernel count1 -> 2after two identicalfill(1.0)calls.Environment:
Additional comments
The fill result is correct. The suspected cause is that the internal helper receives
valas aqd.template()argument, while_fill_by_kernel()constructs a newMatrix/Vectorobject on every call andMatrix.__hash__()uses object identity (id(self)). Thus identical values produce distinct specialization keys.The source checkout was not compiled for this report; the behavior above is from the installed PyPI wheel.