You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ggml-cuda: make the weight row padding per-architecture and tunable
The alias stride and the pad were compile-time constants gated to RDNA3.5. Both
follow from the cache geometry -- line size times number of sets -- so another
architecture needs different values, and neither CUDA nor HIP report enough to
derive them: hipDeviceProp_t::l2CacheSize is documented as always returning 0,
and set associativity is not exposed at all.
Move the pair into cuda_device_info, resolved once per device from a table keyed
on the compute capability, then overridden by GGML_CUDA_ROW_ALIAS_STRIDE and
GGML_CUDA_ROW_PAD. Porting to another architecture becomes a table entry, and
the values can be swept without rebuilding. Architectures with no entry keep
packed rows, so each one is opted in only after being measured.
Resolving once per device is also where the settings are validated: an alias
stride that is not a power of two, or a pad that is a multiple of it and so
leaves the rows aliasing, warns and falls back to no padding.
GGML_CUDA_NO_PAD_WEIGHTS now resolves to a zero pad, leaving a single way for
the padding to be off.
Add the per-type check that was missing: ggml_cuda_should_use_mmf and
ggml_cuda_should_use_mmvf reject a src0 whose strides are not a multiple of
2*type_size, so a pad that misses this would not fail or corrupt anything, it
would quietly stop those kernels from being selected.
Also correct the reason quantized weights are excluded. The matmul kernels do
read the row stride, as nb[1]/type_size in mmq.cu and mmvq.cu; what a 128 byte
pad breaks is that division being exact.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments