Skip to content

Living Weights on CUDA: a split product adds its slices in a fixed order, so a lesson repeats run to run - #632

Merged
ashhart merged 1 commit into
ashhart:mainfrom
ZackSample:cuda-fixed-order-gemm
Oct 10, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
ZackSample:cuda-fixed-order-gemm

Conversation

@ZackSample

Copy link
Copy Markdown
Contributor

Follow-up 1 from #591: a CUDA lesson now repeats run to run.

What changed

  • With one slice, tf_train_gemm adds into C as the only writer of its elements: a plain add, no atomic.
  • With more slices, each slice writes its part to a new parts region of the backward's buffers (f32 [split, m, n]), and tf_train_gemm_sum adds them into C in slice order.
  • split() keeps slices times 64 x 64 tiles within its 192 blocks, so parts is 3 MiB. It is counted in Trainer.memory through Bufs.total.
  • tf-cuda-test train now runs each product twice and requires the same bits.

No atomicAdd is left in the training kernels (train.cu, train_mixers.cu). The expert plan's atomicAdd only counts each expert's members in shared memory, and their places come from a rank, so it was already deterministic.

Checks on a GB10 (driver 580.178.04, CUDA 13.0)

  • tf-cuda-test train: pass with the same accuracy (8.42e-7 and 2.40e-6 for the split cases). Run twice, 0 of 349,440 values differ in any bit.
  • tf-cuda-test train-mixers, slide-grad (1.0267 at layer 51, the same as main) and zig build test: pass. Lean check 542 problems, the same as main.
  • Step times are unchanged (slide-bench, median of 10, two runs each): learn 223 ms at 26 rows and 490 ms at 87 rows on both builds.

Each fact taught twice through /v1/slide/learn on a fresh copy of the folder

Fact main (9041e20) this branch
"My sister is called Ana." (taken out both times) Losses differ: 0.529 and 0.526 after round 1, 0.010 and 0.009 at the end The same log, line for line
"My favorite food is lasagna." (kept both times) Losses differ (0.102 and 0.090 in the plain round), and all four shards differ in bytes The same log and the same shard bytes

After rebasing onto 6ed796d, which brings #605's grouped experts, the lasagna lesson again saved the same bytes twice, and the same bytes as on 9041e20.

For @zweck: this takes atomicAdd out of the split-K path. It sits on main, which is already green on your card, so this branch should stay green there too. It doesn't apply to 3d9671b as is, because cuda_train_back.zig has moved since. If you want to try it on the build that fails, I can put the same change on top of 3d9671b.

Follow-up 2 (slide-grad's span rule) is not in this PR.

🤖 Generated with Claude Code

…der, so a lesson repeats run to run

tf_train_gemm cut K into slices that each added their part into C with atomicAdd, so the adds landed in a different
order on every run and every gradient differed in its last bits; ashhart#591's six facts kept Lisbon in one run and took it
out in the next. One slice now adds into C as the only writer of its elements. More slices each write their part to
the backward's new parts buffer (f32 [split, m, n]: split() keeps slices times 64 x 64 tiles within its 192 blocks, so
3 MiB, counted in Trainer.memory through Bufs.total), and tf_train_gemm_sum adds them into C in slice order.
tf-cuda-test train runs each product twice and requires the same bits.

On a GB10, each fact taught twice through /v1/slide/learn on a fresh copy of the folder:
- "My sister is called Ana." (taken out both times): main's losses differ between the runs (0.529 and 0.526 after the
  first round); this branch's logs are the same line for line.
- "My favorite food is lasagna." (kept both times): main saved different bytes into all four shards; this branch saved
  the same bytes.
The kernels' accuracy (8.42e-7 and 2.40e-6 for the split cases), train-mixers, slide-grad (1.0267 at layer 51) and the
step times (223 ms at 26 rows, 490 ms at 87) are unchanged.
@ashhart
ashhart merged commit dfb08ff into ashhart:main Oct 10, 2026
2 checks passed
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @ZackSample, for taking the follow-up so quickly. This is merged into main (dfb08ff), your commit as it was, and it ships in 1.0.6. On a GB10 we ran tf-cuda-test train twice and every RESULT line came out identical, with the same accuracy as before (within 2.40e-6 of float64). train-mixers passes. Without --slide, nothing changes: 29 of 29 served replies and the four release prompts equal main's, with decode and cold prompts within noise. A lesson that repeats run to run also makes the Lisbon kept-or-taken-out split from the #591 runs easy to study.

@ZackSample
ZackSample deleted the cuda-fixed-order-gemm branch October 10, 2026 22:03
@ashhart ashhart mentioned this pull request Oct 10, 2026
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
…series and PRO 6000 Blackwell, NVFP4 Nemotron

1.0.6 ships what main gathered since 1.0.5 and tonight's landings (the CHANGELOG lists them): structured output and
required tool calls on the native server with drafting on, the Qwen3.8-27B serving concurrent requests and drafting
sampled ones, sm_120 kernels in the Linux archives, NVIDIA's NVFP4 Nemotron checkpoint on CUDA, Living Weights on a
GB10, and the fix for 1.0.5's known issue (GLM pair prose decode). The CHANGELOG heading, build.zig.zon, the README and
the RUNBOOK's download lines name 1.0.6; the CHANGELOG credits ashhart#632 and lists the contributor-facing PRs.
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
…ct, and the CHANGELOG

The guide explains the pocket (64 neurons beside each shared expert, keyed on the reply or the subject), the /slide
3D view, the GB10's trainer memory, what was measured (personal facts on three machines, short and long documents,
time a fact, serving cost) and the startup refusal of folders taught by 1.0.3 to 1.0.5. The README mentions documents
and the 3D view. The CHANGELOG's Unreleased entries replace ashhart#591, ashhart#599 and ashhart#632's with the pocket learner, the speed
work and the view, crediting them.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…lices in a fixed order, so a lesson repeats run to run

Thanks @ZackSample.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…series and PRO 6000 Blackwell, NVFP4 Nemotron

1.0.6 ships what main gathered since 1.0.5 and tonight's landings (the CHANGELOG lists them): structured output and
required tool calls on the native server with drafting on, the Qwen3.8-27B serving concurrent requests and drafting
sampled ones, sm_120 kernels in the Linux archives, NVIDIA's NVFP4 Nemotron checkpoint on CUDA, Living Weights on a
GB10, and the fix for 1.0.5's known issue (GLM pair prose decode). The CHANGELOG heading, build.zig.zon, the README and
the RUNBOOK's download lines name 1.0.6; the CHANGELOG credits ashhart#632 and lists the contributor-facing PRs.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…ct, and the CHANGELOG

The guide explains the pocket (64 neurons beside each shared expert, keyed on the reply or the subject), the /slide
3D view, the GB10's trainer memory, what was measured (personal facts on three machines, short and long documents,
time a fact, serving cost) and the startup refusal of folders taught by 1.0.3 to 1.0.5. The README mentions documents
and the 3D view. The CHANGELOG's Unreleased entries replace ashhart#591, ashhart#599 and ashhart#632's with the pocket learner, the speed
work and the view, crediting them.
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