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
{{ message }}
Repository navigation
SWITCH LoRA kernel: int32 index overflow -> CUDA illegal memory access on large intermediate_size (granite-4.1-30b) #160
Serving a composed adapter on granite-4.1-30b crashes at inference with a CUDA illegal memory access from the SWITCH fused-LoRA Triton kernel. Compose succeeds; the crash is on the first forward.
File "granite_switch/kernels/switch_lora_kernel.py", line 435, in switch_lora_expand
_switch_lora_expand_kernel[grid](...)
RuntimeError: Triton Error [CUDA]: an illegal memory access was encountered
granite-4.1-3b and granite-4.1-8b are unaffected.
Root cause
In the expand kernels the packed lora_B element offset is
Serve the composed checkpoint under vLLM and run a single generation → illegal memory access.
Proposed fix
Promote the index tensor operands to int64 so the offset arithmetic is 64-bit — n_range / h_range / m_range and the per-tier r16..r512 ranges via .to(tl.int64) — in the three LBPACK kernels (_switch_lora_expand_kernel, _accum_slice_delta, _switch_lora_shrink_expand_kernel). The lb_off_* scalars can stay Python ints; promotion happens because a tensor operand in each sum is int64. (tl.int64(x) is not callable — the cast must be tensor.to(tl.int64).)
Validation
On H200: granite-4.1-3b load+generate unchanged (no regression on the common path), and granite-4.1-30b loads and generates where it previously crashed; a 12-domain 30B eval sweep then ran with zero illegal-memory failures.
PR with the fix: thinkahead/granite-switch fix/switch-kernel-int64-overflow.
Root-cause correction, for the record: the int32 term that overflows is the x_ext row offset m * stride_xe_m, not the packed lora_B offset. On granite-4.1-30b the gate/up row width is ~65.5k, so a forward of ~32.8k tokens passes 2³¹ (8B, at ~25.6k width, would need ~83.8k tokens). The lora_B offset only overflows when sum(NA_r * r) > 2^31 / N, which no realistic checkpoint reaches. The int64 casts in #161 fix both; #161 now also has a kernel comment and a regression test (tests/unit/test_switch_kernel_int64_offsets.py).
Activity
Document the x_ext row-offset overflow and add an int32-limit regress…
yairallouche commentedon Nov 17, 2026
Root-cause correction, for the record: the int32 term that overflows is the
x_extrow offsetm * stride_xe_m, not the packedlora_Boffset. On granite-4.1-30b the gate/up row width is ~65.5k, so a forward of ~32.8k tokens passes 2³¹ (8B, at ~25.6k width, would need ~83.8k tokens). Thelora_Boffset only overflows whensum(NA_r * r) > 2^31 / N, which no realistic checkpoint reaches. The int64 casts in #161 fix both; #161 now also has a kernel comment and a regression test (tests/unit/test_switch_kernel_int64_offsets.py).Document the x_ext row-offset overflow and add an int32-limit regress…