Repository navigation
Proposal: add a scaling-law fit and C200 forecast tool (new nexttransformer/scaling/fit.py) #47
yangyifei729
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Motivation
The scaling protocol defines four fitting steps, and
scaling/contribute.mdinvites work on the fits, but the repository has no code for them yet:nexttransformer/scaling/holds the configuration, trainer, optimizer, checkpoint and export modules only. Once the first T3 and T4 records arrive, every forecast inevidence/forecasts/will need the same fit. A shared, tested implementation would let anyone reproduce a forecast from the records, and would let the maintainers check submitted forecasts the same way.I would like to write it. Before starting, I'd like to agree on the scope and on a few questions below.
Proposed scope
A module
nexttransformer/scaling/fit.pywith a small CLI,python -m nexttransformer.scaling.fit, that readsresults/scaling/ladder.jsonandresults/scaling/runs/*.jsonand implements the protocol's steps:L(N, D) = E + A / N^α + B / D^βper family, withLthe record'sfinalBpb.val,Nits block parameters andDtraining.inputTokens. The estimator follows Chinchilla's Approach 3: Huber loss onlog Lwith the log-sum-exp parametrisation, minimised by L-BFGS from a grid of initial values, keeping the best.log Nand report whether its minimum lies inside the five sizes.D = C200 budget / FLOPs per token, with FLOPs per token fromnexttransformer.models.native.model.theoretical_training_flopsso that the accounting matches the trainer, and select the size with the lowest predicted loss. Reportlayers, block and total parameters, tokens, and the predicted final validation BPB.--forecast <family>prints a file in theevidence/forecasts/format, which the author then reviews and submits; the tool never writes intoevidence/itself.Tests in
tests/test_scaling_fit.py, CPU only: recover known parameters from synthetic records generated from a knownL(N, D); flag a tier whose minimum lies outside its sizes; check that the C200 token count reproduces the ladder's cells for the same layers; and check that the CLI output validates against the forecast format.No dependency is added.
pyproject.tomlhas no SciPy, so the optimiser istorch.optim.LBFGSin float64, which is already a dependency. The module is outside the contract paths innexttransformer/checks/changes.pyand is not part of any cost proof, so no published result or proof changes.Questions
dense_200bpart of the Dense fit? Its record names protocolnextt-scale-200b-4k-v1, whileladder.jsonnamesnextt-scale-4k-v1. The protocol says cells of different versions are not mixed in one fit, but step 1 also fits "its recorded C200 runs", and the ladder listsdense-C200-L40withrecord: dense_200b. I would include it only if the two versions share the recipe, and otherwise report it as a held-out check.N? The ladder'sblockParametersis exactly12·d²·L(3,145,728,000 for L40), while the record'sparameters.blocksalso counts 4,800 gate and scalar weights (3,145,732,800). The difference is negligible for the fit; I would use the record field and say so.If the scope looks right, I'll open a pull request with the module, its tests and a short section in
scaling/contribute.md(English and Chinese) on how to run it.All reactions