Skip to content

Opt-in execution speedups (--speedups): review of #26 and merge decision #27

Closed

Description

@Selen-Suyue

This issue records the maintainers' review of #26 by @henry-y (ResearchBoost-Agent), the measurements behind the decision, and the rules --speedups follows once merged. CONTRIBUTING asks for an issue before a change to shared code; this one documents the agreement.

Decision

Merge #26 together with the maintainer changes listed below.

  • --speedups is off by default: without the flag, training is the current main, bit for bit.
  • Users may opt in with --speedups exact, --speedups all or a comma list of components.
  • Formal runs accept only exact (or a selection of its parts), which reproduces the default path bit for bit. all, cudnn and merge change rounding and stay in research mode.
  • Published results, audits and cost proofs are unaffected. Merging changes native_source_sha256, so a formal run in progress continues on its own commit.

The submission

#26 was opened on 2026-11-06 by @henry-y and prepared with Claude Code. Three commits:

  1. 4933b29 removes a host synchronization per micro batch from the default path (same value).
  2. 99a69bf adds --speedups: run-time patches of 13 shared functions with Triton kernels under nexttransformer/runtime/speedups/; nexttransformer/models/ and nanochat/ are untouched.
  3. c1c6be8 adds python -m nexttransformer.checks.speedups (GPU tests, timing, bit identity, resume, numerics).

Reported on the submitter's GPUs: dense_full on 8 GPUs 1375 → 851 ms/update with exact (1.62×) and 690 ms with all (1.99×), peak memory 75.0 → 60.9 GiB, bit identity on 1 and 4 GPUs.

What we checked

CPU (the CI suite). The fast tests pass, checks.golden finds every method bitwise identical, every cost proof matches, checks.changes lists no published method, and the public check is clean. FLOPs are charged from the cost proofs, so the kernels cannot change the compute ledger.

GPU. One node of eight 80 GB Ampere-generation GPUs, torch 2.9.1, SDPA flash (no FlashAttention-3), bounded research runs on the real data:

  • The 45 GPU tests of the PR pass.
  • Bit identity (checks.speedups bits, 8 GPUs, deterministic attention), exact against main: dense_full (30 updates) and gdn, moba_hybrid, deeploop, mhc, ouro, mla_nope, residual_standard, attnres (6 updates each). Parameters, optimizer state, data cursor, logged losses and theory_flops are identical. This includes the default-path change of 4933b29.
  • Resume: 6 + 6 updates equal 12 continuous updates, for exact and for all.

Speed, dense_full, 8 GPUs, micro batch 16, reference and optimized runs alternating:

ms/update speedup peak memory
default 4384 1.00× 75.0 GiB
exact 3183 1.38× 63.1 GiB
exact,merge 3128 1.40×
exact,cudnn 3300 1.33×
all 3244 1.35× 60.9 GiB

On these GPUs cuDNN attention is slower than SDPA flash, so all is slower than exact. On one GPU with micro batch 8, all gave 1.12× (mhc) to 1.46× (ouro) across eight methods (dense_full 1.29×, moba_hybrid 1.25×, attnres 1.19×, gdn_hybrid 1.16×, mla_nope 1.15×, nsa 1.14×) and lowered peak memory by 6–17 GiB.

Numerics of all (no deterministic attention, so two identical runs differ too):

final val BPB mean loss, last updates mean |Δloss|
dense_full, 300 updates: exact ×2 0.99846, 1.00011 3.27658, 3.27504 exact–exact 0.0043
dense_full, 300 updates: all ×2 0.99905, 0.99645 3.27565, 3.27650 exact–all 0.0045, 0.0055
ouro, 120 updates: exact ×2 1.27788, 1.28279 4.13349, 4.13043 exact–exact 0.0051
ouro, 120 updates: all ×1 1.27736 4.13578 exact–all 0.0069

Found in review and fixed before merging

Maintainer commits on #26:

  1. --formal accepted --speedups all, and the exported result did not record the selection. Formal runs now accept only selections inside exact, the audit rejects formal segments with anything else, and export_run writes proof.speedups (records of runs without speedups are unchanged).
  2. Resume compared the selection in one direction only: a run started with speedups could continue without them. It is now compared both ways.
  3. A model class that overrides _token_loss, as a plugin may, received the uncapped logits of the fused readout. In a probe its loss went from 18.50 to 27.13 without an error. Such a class now keeps the original readout; a GPU test covers it.
  4. checks.speedups bits counted software/git_commit as a difference between two checkouts. It is now ignored.
  5. A change to one of the 13 patched functions no longer needs to touch the speedups: the fast tests warn, and --speedups refuses to start until its patch is reviewed.

Documentation: the protocol overview (English and Chinese) states the formal rule, the changing-shared-code guide mentions the patched functions, and the package README lists the measurements above.

Re-checked after these changes: CPU suite 540 passed; GPU tests 48 passed; --formal --speedups all is refused at parse time; --formal --speedups exact runs and records exact; resuming an exact run without the flag is refused; dense_full remains bitwise identical to main.

Limits

  • Gains depend on the GPU. We did not measure GPUs with FlashAttention-3, where cudnn has no effect.
  • all was measured over at most 300 updates. On ouro its loss deviation exceeded the run-to-run noise in a single 120-update run, so it stays research only.
  • The kernels pin torch 2.9.1's reduction order. A torch upgrade or a change to a patched function disables --speedups until the patches are reviewed. @henry-y is the point of contact for the kernels.

Activity

  1. added
    enhancement
    contract
    on Nov 6, 2026
  2. added a commit that references this issue on Nov 6, 2026
  3. Selen-Suyue commented on Nov 6, 2026

    @Selen-Suyue
    MemberAuthor

    Done: #26 merged in 5943c54 with the maintainer changes above, and ResearchBoost-Agent added to the community projects in #28.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    contractenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions