Skip to content

cuda: flashnext_batch, flashnext_gdn and qwen4_gdn take tf_common::warp_sum, SASS unchanged - #1550

Merged
ashhart merged 1 commit into
ashhart:mainfrom
jschmied:prims-1409-step2
Oct 29, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
jschmied:prims-1409-step2

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

What

Second step of #1409, on main after #1440. Pure refactor: cuobjdump -sass is identical for every function of every image that includes a touched file.

The last three float warp_sum copies (xor butterfly 16 down to 1, the same loop as common/reduce.cuh) give way to tf_common::warp_sum through #include "common/reduce.cuh" and a using declaration, as in #1440:

  • flashnext_batch.cu (inside fn_gdn)
  • flashnext_gdn.cu
  • qwen4_gdn.cu, the checked-in text Gdn.cuda generates from flashnext_gdn.cu (source_test.zig compares them), so both change together.

qwen4_gdn_cuda_host.zig, which turns that text into the CPU twin, now strips the include and the using declaration instead of the deleted function, the way qwen4_ple_cuda_host.zig handles glue_math.cuh in #1440. flashnext_gdn.cu's gradient-serving pin takes the new bytes. flashnext_batch.cu's two pins already differ on main and are left as they are.

5 files, +9 / −15.

Left alone on purpose

  • sample.cu's warp_sum_u: unsigned, a different type.
  • deepseek_v41/sampling.cu: double precision.
  • glm_kda.cu's warp_sum4: a different signature and reduction.

Verification

  • SASS, base main dd0a9cc5e, head aa9184554, nvcc 13.0: 3 images (flashnext_batch, flashnext_gdn, qwen4_gdn), 65 functions, sm_80/86/89/120/121: 0 changed, 0 added, 0 removed, 0 unstable. Before the rebase the same set was also identical with nvcc 13.2. The qwen4_gdn image is built from the checked-in unit, as the tool does for generated units.
    python3 tools/zig/cuda_sass_identity.py --repo . -j 3 --receipt sass.tsv origin/main HEAD
    
  • Planted control: a reversed warp_sum butterfly changes 35 functions in 3 of 3 images. The fp4pair control cannot be planted because none of these units includes common/qmm_frag.cuh, so the tool exits 1 on that line alone.
  • lean: 425 problems, 425 on the base, 0 new.
  • zig build test -Dnvcc=/usr/local/cuda/bin/nvcc: passes (RC 0).

Part of #1409.

jschmied added a commit to jschmied/TensorFold that referenced this pull request Oct 28, 2026
…ytes fp_pairs.cuh leaves

Both pins matched main before this branch. fp8_experts.cu's and nvfp4_experts.cu's pins already differ on main and are left as they are, as ashhart#1550 does for flashnext_batch.cu.
…rp_sum, SASS unchanged

The three remaining float warp_sum copies (xor butterfly 16..1) give way to common/reduce.cuh through a using
declaration, as in ashhart#1440. qwen4_gdn.cu is the checked-in text Gdn.cuda generates from flashnext_gdn.cu
(source_test), so both change together. qwen4_gdn_cuda_host.zig, which builds that text for the CPU, now strips
the include and the using declaration instead of the deleted function. flashnext_gdn.cu's gradient-serving pin
takes the new bytes; flashnext_batch.cu's two pins already differ on main and are left as they are.

cuobjdump -sass is identical for every function of the three images (65 functions, sm_80/86/89/120/121) with
nvcc 13.0 and 13.2, base prims-1409.
ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Oct 29, 2026
…ytes fp_pairs.cuh leaves

Both pins matched main before this branch. fp8_experts.cu's and nvfp4_experts.cu's pins already differ on main and are left as they are, as ashhart#1550 does for flashnext_batch.cu.
ashhart pushed a commit to jschmied/TensorFold that referenced this pull request Oct 29, 2026
…SS unchanged

Step 4 of ashhart#1409. The same-text activation copies move to tf_common in one header:
- sigmoidf_: gdn_train, drama3_common.cuh, glm_kda, and the file-local sigm of attn_train, train_attn,
  flashnext_train, qwen27_train and train_q4 (renamed at their call sites);
- softplusf_: gdn_train and drama3_common.cuh;
- silu: flashnext_train, qwen27_train, train_q4 and train;
- silu_grad: gdn_train, flashnext_train, qwen27_train, train_q4 and train (train's spelled the sigmoid inline).

Each file takes them by a using-declaration. glm_kda.cu's gradient-serving pin takes the new bytes.
Left out: flashnext_gdn, qwen4_gdn and flashnext_batch (ashhart#1550 edits them and qwen4_gdn's CPU twin), qwen4_gdn's
stable sigmoid, act_l2's __fdiv_rn silu, drama3's siluf_ and train's softplus (other names used elsewhere or not at
all), and deepseek_v41/pointwise's torch silu.
ashhart added a commit to jschmied/TensorFold that referenced this pull request Oct 29, 2026
@ashhart
ashhart merged commit 844ff07 into ashhart:main Oct 29, 2026
9 checks passed
ashhart pushed a commit that referenced this pull request Oct 29, 2026
…ytes fp_pairs.cuh leaves

Both pins matched main before this branch. fp8_experts.cu's and nvfp4_experts.cu's pins already differ on main and are left as they are, as #1550 does for flashnext_batch.cu.
ashhart pushed a commit that referenced this pull request Oct 29, 2026
…SS unchanged

Step 4 of #1409. The same-text activation copies move to tf_common in one header:
- sigmoidf_: gdn_train, drama3_common.cuh, glm_kda, and the file-local sigm of attn_train, train_attn,
  flashnext_train, qwen27_train and train_q4 (renamed at their call sites);
- softplusf_: gdn_train and drama3_common.cuh;
- silu: flashnext_train, qwen27_train, train_q4 and train;
- silu_grad: gdn_train, flashnext_train, qwen27_train, train_q4 and train (train's spelled the sigmoid inline).

Each file takes them by a using-declaration. glm_kda.cu's gradient-serving pin takes the new bytes.
Left out: flashnext_gdn, qwen4_gdn and flashnext_batch (#1550 edits them and qwen4_gdn's CPU twin), qwen4_gdn's
stable sigmoid, act_l2's __fdiv_rn silu, drama3's siluf_ and train's softplus (other names used elsewhere or not at
all), and deepseek_v41/pointwise's torch silu.
ashhart added a commit that referenced this pull request Oct 29, 2026
@ashhart

ashhart commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied, landed with #1550, #1555 and #1556 together on main (changelog in 5b6c254). We rebuilt every CUDA image from main and from the stack at sm_121 and sm_80: all 1,866 functions in the 104 images compile to identical SASS.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants