Repository navigation
feat(ml): thread primitive + train_hslm windows on N threads, bit-identical at any count (#10876) - #10896
Open
gHashTag wants to merge 7 commits into
Open
feat(ml): thread primitive + train_hslm windows on N threads, bit-identical at any count (#10876)#10896gHashTag wants to merge 7 commits into
gHashTag wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nds (#10850) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…now std.os.linux.timespec (#10850) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… threads (#10876) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
This was referenced Oct 19, 2026
This was referenced Oct 19, 2026
Merged
Contributor
7 of 8 tasks
…in_hslm.t27 and its seal kept at the thread version) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10876
What
Lever (a) of #10850: the 66 windows of one
tr_train_step_kstep run on N worker threads instead of one.threadlocal varform andthread_spawn/thread_join/thread_coresbuiltins for--backend ml(bootstrap/src/compiler.rs, +40/-47, dead code deleted;FROZEN_HASHmoved).specs/ml/thread_model.t27(6 tests; parts on N threads sum bit-identically to the fixed-order sum, per-thread state starts at its initializer and does not leak).specs/ml/train_hslm.t27: cfg keythreads(default = cores,threads=1is the serial path). Each window writes its own gradient slot inwin_g; slots are summed in window order, so the result does not depend on the thread count. nn/hslm state and theb3_*scratch arrays arethreadlocal. New testone_two_and_three_threads_give_one_step_the_same_bits_at_speed_2_and_3.Association change (stated, not hidden)
The old step kept one running sum over windows. The new step sums per-window slots in fixed window order. Floating-point addition is not associative, so:
240eb9893ad8eba1(old) vsa9f594b18f9fc17e(new). Loss agrees to 4 digits (train 6.5916, valid 6.5637) and the.binhash is the same.The new value is the same for every thread count, which is the point: determinism no longer depends on the machine.
Lab proof (Railway lab, 48 cores, 8 steps, seed 1729, loaded: load average 55-72 during the runs, so these are floors)
State hash after 8 steps,
sha256(ckpt_8.state)[:16]:a9f594b18f9fc17eat threads = 1, 2, 4, 8, 16, 24, 48, at speed 2 and at speed 3. Loss identical at every count.Speed-up at 16 threads: 5.4x at speed 2, 4.1x vs the old speed-3 binary. Past 24 threads the lab is oversubscribed (load > 48) and throughput falls.
Known costs
threads=1at speed=3 is about 16% slower than the old binary (407 vs 484 tok/s): thread-local access on theb3_*scratch. At speed 2 it is level (238-246 vs 245). Not fixed here; a follow-up.undefinedas 0xaa into.data, 1.1 GB forwin_g.win_gnow starts from a zero initializer (.bss),.datais 178 MB.specs/ml/eval_hslm.t27is BLOCKED (use of undeclared identifier 'b3_q'). Inherited from spec(ml): train_hslm speed=3 -- one matrix over the 27 positions, bit-identical to speed=2 (Closes #10849) #10866 (it fails at this PR's base too), not caused here; follow-up.Stack
This branch contains the commits of #10857 (issue #10850) until that merges; the diff of this PR alone is the thread work.
Tests on the lab:
thread_model6/6,train_hslm30/30,t27t17/17,ngram_hslm8/8, all with 0 vacuous passes. Seals saved forml_train_hslmandml_thread_model.🤖 Generated with Claude Code