Skip to content

fix(paro): index fused rotation rows in 64 bits (#5196) - #5253

Merged
Qubitium merged 1 commit into
mainfrom
fix/paro-rotation-int64-5196
Nov 18, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/paro-rotation-int64-5196

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #5196.

Problem

gptqmodel_ext/paro/rotation.cuh addressed activations and outputs with a 32-bit
row (row * h), and rotation.cu narrowed seq_len/h to int before the
kernel launch. A long prefill whose rows * in_features product exceeds 2^31
therefore wrapped to a negative element offset, producing HSA MEMORY_FAULT /
illegal address on every Paro layer that runs the fused rotation — on both
ParoLinear (CUDA) and ParoTritonLinear (ROCm).

#5164 widened only the GEMM; this is the activation-side half of #5096.

Change

  • rotation.cuh: s/h are int64_t in load_group/store_group/
    load_coeffs for all access structs (float, half, bf16-float-workspace), and
    row is computed in 64 bits before the row * h address.
  • rotation.cu: int64_t s/h/seq_len in rotate_kernel,
    rotate_kernel_bf16_float_workspace, rotate_pair_kernel and
    rotate_pair_grad_kernel; launchers widen h/seq_len, cast the grid
    extent, and size/scan partials in 64 bits. The pair-grad launcher no longer
    truncates seq_len to int.

Test

New tests/kernels/test_paro.py::test_paro_rotation_addresses_rows_above_int32_element_count
rotates a 8192-wide tensor with 2**31 // 8192 + 1 rows and a non-identity
theta, checks only the populated tail, and compares it to
apply_paro_rotation_reference. Note: the fused rotation extension cannot be
built on the development host (no CUDA toolkit / CUDA_HOME), so the new node
skips locally and runs in CI where the extension is available. The existing
Paro kernel tests were run on this host: 6 fail / 51 pass both before and after
this change, identically to a clean origin/main checkout, because they need
the same CUDA toolkit.

@Qubitium
Qubitium merged commit ecde195 into main Nov 18, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/paro-rotation-int64-5196 branch November 18, 2026 14:36
Qubitium added a commit that referenced this pull request Nov 19, 2026
Keep the stable-ABI surfaces while taking main's changes:
- marlin: adopt the MXFP4/MXFP8 microscaling fix (#5193): the e8m0 type is
  always available through torch_stable_compat.h, fp16 MXFP4 is rejected with
  the bfloat16-compute error, and the bf16 path keeps the e8m0 scale pointer.
- marlin: take the thread_k/thread_n/num_threads tile override (#5281) in the
  core schema and the torch-version adapter schema, so the boxed forward keeps
  matching arity.
- paro: keep main's 64-bit row indexing (#5253) and port its Meta kernels
  (#5225) to STABLE_TORCH_LIBRARY_IMPL, allocating with at::options().
- compat: do not take the AOTI empty fast path for Meta tensors, which have no
  accelerator index.
- exllamav3: register main's bf16 prescale/rescale wrappers with TORCH_BOX.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant