[PR #838] [CLOSED] #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too #2863

Closed
opened 2026-11-04 02:03:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/838
Author: @sergqwer
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: pr/q8_1-finite-fused


📝 Commits (1)

  • 69b3e95 #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too

📊 Changes

3 files changed (+24 additions, -13 deletions)

View changed files

📝 src/kernels/cuda/iq_kernels.cu (+3 -3)
📝 src/kernels/cuda/native_mmvq.cu (+3 -3)
📝 src/kernels/iq_multi_parity.cpp (+18 -7)

📄 Description

Completes the #606 clamp. 0.1.39 made two q8_1 activation quantizers keep the block's fp16 scale and sum finite: q8_1_store in iq_kernels.cu and native_quantize_q8_1_kernel in native_mmvq.cu. Two fused SwiGLU + q8_1 kernels still store the block raw:

kernel where it runs
native_swiglu_quantize_q8_1_kernel (native_mmvq.cu:166-169) the shared expert, decode (shared_expert.cu:203) and the multi-token pass (:310); on by default (STRATA_FUSED_SWIGLU_Q81 unset)
native_gu_fused_kernel (iq_kernels.cu:2416-2420) the routed experts' fused gate/up on gfx906 builds with STRATA_EXP_MODE=8 (IQ types 18/21/22/23)

Both now go through q8_1_finite / q8_1_quant / q8_1_ds, the same three lines as their siblings. Every block that was finite before is stored bit for bit as before, so normal output does not change.

rwkeyes found the first one in #606 but has no NVIDIA card to test it. The second one turned up in a sweep for amax / 127.0f after it; nothing else in src stores a q8_1 block without the clamp now.

Test

iq_multi_parity's #606 check now runs native_swiglu_quantize_q8_1 as a third path. It uses gate = 32 and up = x / 32: silu(32) is exactly 32 in float, so the fused kernel sees the same activations x as the other two paths and is held to the same expectations.

RTX 5090, CUDA 13, sm_120:

# this branch
q8_1 finite (quantize_q8_1_rows): 237 finite blocks as before, 3 overflowed blocks clamped finite
q8_1 finite (native_quantize_q8_1): 237 finite blocks as before, 3 overflowed blocks clamped finite
q8_1 finite (native_swiglu_quantize_q8_1): 237 finite blocks as before, 3 overflowed blocks clamped finite
iq_multi_parity: 0 failures

# the same test with native_mmvq.cu from v0.1.39
q8_1 finite (native_swiglu_quantize_q8_1): 237 finite blocks as before, 0 overflowed blocks clamped finite  FAIL
iq_multi_parity: 4 failures

The gfx906 kernel is not covered: I have no gfx906 card to run it on. Its change is the same three lines as q8_1_store in the same file.

Data point

On a fork of 0.1.39 (RTX 5090), a Qwen3.8-Flash-Next served conversation also turned into '!' (token 0) mid-thinking at about 99K positions, and later requests carrying that history kept producing it. Replaying the conversation up to that point did not reproduce it. So I cannot tie that run to this kernel; it is only the same symptom #606 describes, on a build that still had this store unclamped.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/838 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/q8_1-finite-fused` --- ### 📝 Commits (1) - [`69b3e95`](https://github.com/Niko1221/Strata/commit/69b3e956db1e42c494bdff22e9b92c8ee7b19fc8) #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too ### 📊 Changes **3 files changed** (+24 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/kernels/cuda/iq_kernels.cu` (+3 -3) 📝 `src/kernels/cuda/native_mmvq.cu` (+3 -3) 📝 `src/kernels/iq_multi_parity.cpp` (+18 -7) </details> ### 📄 Description Completes the #606 clamp. 0.1.39 made two q8_1 activation quantizers keep the block's fp16 scale and sum finite: `q8_1_store` in iq_kernels.cu and `native_quantize_q8_1_kernel` in native_mmvq.cu. Two fused SwiGLU + q8_1 kernels still store the block raw: | kernel | where it runs | |---|---| | `native_swiglu_quantize_q8_1_kernel` (native_mmvq.cu:166-169) | the shared expert, decode (shared_expert.cu:203) and the multi-token pass (:310); on by default (`STRATA_FUSED_SWIGLU_Q81` unset) | | `native_gu_fused_kernel` (iq_kernels.cu:2416-2420) | the routed experts' fused gate/up on gfx906 builds with `STRATA_EXP_MODE=8` (IQ types 18/21/22/23) | Both now go through `q8_1_finite` / `q8_1_quant` / `q8_1_ds`, the same three lines as their siblings. Every block that was finite before is stored bit for bit as before, so normal output does not change. rwkeyes found the first one in #606 but has no NVIDIA card to test it. The second one turned up in a sweep for `amax / 127.0f` after it; nothing else in `src` stores a q8_1 block without the clamp now. ### Test `iq_multi_parity`'s #606 check now runs `native_swiglu_quantize_q8_1` as a third path. It uses gate = 32 and up = x / 32: `silu(32)` is exactly 32 in float, so the fused kernel sees the same activations x as the other two paths and is held to the same expectations. RTX 5090, CUDA 13, sm_120: ``` # this branch q8_1 finite (quantize_q8_1_rows): 237 finite blocks as before, 3 overflowed blocks clamped finite q8_1 finite (native_quantize_q8_1): 237 finite blocks as before, 3 overflowed blocks clamped finite q8_1 finite (native_swiglu_quantize_q8_1): 237 finite blocks as before, 3 overflowed blocks clamped finite iq_multi_parity: 0 failures # the same test with native_mmvq.cu from v0.1.39 q8_1 finite (native_swiglu_quantize_q8_1): 237 finite blocks as before, 0 overflowed blocks clamped finite FAIL iq_multi_parity: 4 failures ``` The gfx906 kernel is not covered: I have no gfx906 card to run it on. Its change is the same three lines as `q8_1_store` in the same file. ### Data point On a fork of 0.1.39 (RTX 5090), a Qwen3.8-Flash-Next served conversation also turned into '!' (token 0) mid-thinking at about 99K positions, and later requests carrying that history kept producing it. Replaying the conversation up to that point did not reproduce it. So I cannot tie that run to this kernel; it is only the same symptom #606 describes, on a build that still had this store unclamped. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2863
No description provided.