Skip to content

[BUG] EXL3 had_r_128 launches a zero-row grid on M=0 inputs (always taken on ROCm); M=0 fix in cbf5994 incomplete #4550

Closed

Description

@devin-ai-integration

Component: gptqmodel_ext/exllamav3/quant/hadamard.cu L105-184, had_r_128 and had_r_128_dual.
Fix it is incomplete for: cbf599409 ("pack strided activations, bind devices, widen offsets, handle M=0", #4042/#4047). Scanned HEAD: 2195761.

Problem: cbf5994 added zero-batch early returns to the gptqmodel_ext/hadamard bindings and to NF12. In the same commit it hardened EXL3's had_r_128/had_r_128_dual (contiguity checks, 64-bit row offsets) but did not add the zero-row return. With rows == 0, had_r_128 launches gridDim(0, cols/128). The runtime rejects that launch configuration, and cuda_check(cudaPeekAtLastError()) raises.

ExllamaV3Linear.forward(x with 0 rows) -> LinearEXL3.forward
  --torch_mode (always on ROCm; params['reconstruct'] on CUDA)--> ext.had_r_128(x[0, K], ...)
  -> gridDim(rows=0, blocks) launch -> invalid configuration -> cuda_check raises

Trigger / repro: An EXL3 layer forward with an empty activation on ROCm, where LinearEXL3.forward always sets torch_mode = True when torch.version.hip is set. On CUDA it is reached only when reconstruct is forced; the default bc_linear_exl3_run path handles size_m=0. Neither ExllamaV3Linear.forward nor LinearEXL3.forward checks numel() == 0.

Expected: An empty (0, out_features) result, the contract cbf5994 set for the other Hadamard paths.

Actual (from code reading): The kernel launch fails and an exception is raised. tests/test_hadamard_empty_input.py covers only the gptqmodel_ext/hadamard ops, not EXL3's had_r_128.

Impact: ROCm EXL3 inference raises on zero-row inputs instead of returning an empty tensor. Whether real callers send zero-row activations (for example MoE expert loops that do not skip empty experts) is an assumption and was not reproduced.

Fix:

  • In had_r_128 and had_r_128_dual, return right after the shape checks when input.size(0) == 0.
  • Optionally, return the empty y early in LinearEXL3.forward when x.shape[0] == 0.
  • Extend tests/test_hadamard_empty_input.py with an EXL3 had_r_128 / ROCm torch_mode zero-row case.

Validation status: not validated. Static analysis only. Validation needs ROCm hardware (or CUDA with reconstruct forced) and a built exllamav3 extension, and neither was available.

Activity

  1. added
    bug
    on Nov 17, 2026
  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    Collaborator

    Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions