Conversation
…nto han/gpt_oss_mi308
bride built, isolation test passes bash files to debug llama 1B in bf16 and mxfp4
nfrumkin
requested review from
YBouquet,
arkhodamoradi,
hann-wang and
zhitwang17
August 7, 2026 16:46
adjustments to run script and config registery
Collaborator
added comments
Update 3RHT implementation
hann-wang
reviewed
Aug 17, 2026
Comment on lines
+124
to
+128
| # with rounding you apply value_to_add on mantissa, | ||
| # i.e. 123.2 + 0.5 --> no carry to 124 | ||
| # value_to_add is 0.5 here but below, is actually 0.25 | ||
| # so anything <0.25 away from carry will be carried | ||
| # 7 in |
Collaborator
There was a problem hiding this comment.
The rounding does not work this way. The 0.25 value_to_add means that we will increase the exponent by 1 if the matissa is larger than 1.75.
For value_to_add, and 7 with value_to_add.
some optimizations
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.
Integrate RAD's LPT recipes
Summary
Integrates AMD Research's (RAD) low-precision-training (LPT) recipes into ALTO on top of the existing MXFP4 stack. The core addition is AdaHOP — per-slot Hadamard mode selection driven by a calibration phase — wired in through the
mxfp4_adahopscheme and vendored as the3rdparty/adahopsubmodule (AMDResearch/low-precision-training, branchAdaHOP_C42). Alongside it this PR brings in the supporting recipes and tooling that RAD's runs depend on:alto/modifiers/lpt/adahop.py,adahop_internals/): a singleMXFP4AdaHOPWrapperset at conversion time with all modes"none"(plain MXFP4), then flipped in place at the end of calibration — no wrapper-type swap and no newnn.Parameter, so optimizer state references stay valid across the Phase-A→Phase-B transition and across checkpoint resume. Isolated from AdaHOP's vendoredtorchtitanviaalto/_adahop_bridge.pyso it can never shadow ALTO's own torchtitan submodule.alto/kernels/fp4/mxfp4/mxfp_quantization.py): a generalSCALE_SELECTIONconstexpr flag in the quantization kernel (replacing a dedicated midmax path), plus theuos/uos6/deosc/midmaxrecipe variants.alto/components/m_adam.py): a hybrid additive (AdamW mantissa) / multiplicative (Madam-style exponent) optimizer with independent LR/WD/schedule on the exponent, wired into torchtitan'sconfig.optimizer.build(...)path, used for the de-oscillation (deosc) recipe.mxfp4_forward_only.py) and per-layer gradient clipping (alto/modifiers/lpt/grad_clip.py) modifiers.alto/modifiers/debug/): per-step tensor capture (DebugObserverModifier) and per-expert MoE outlier-pattern capture (MoEMatmulPatternObserverModifier) for the two Grouped GEMMs of gpt_oss MoE blocks, with visualizers underscripts/.config_registryentries for gpt_oss_20b (mxfp4_base,adahop,lpt_deosc,lpt_midmax,lpt_uos,lpt_uos6,moe_pattern_obs) and llama3 (adahop,adahop_debug,hadamard,fwdonly).plotting/plot_training_stats.py+.tomlconfigs): unified loss / grad-norm plotting from slurm.outlogs and/or TensorBoard event files.Dockerfile.multinode, RDMA test harness (rdma_tests/,RDMA.md), andrun_id/TensorBoard support inalto/train.py.Total: 84 files, ~9.1k insertions.
Validation
Unit tests — 84 new test functions, GPU-gated where they exercise kernels:
"none"mode matches plain MXFP4; per-mode grad_w bias and Hadamard forward error bounded vs the bf16 reference; SR reduces grad_w bias), wrapper lifecycle, bridge isolation, calibration hooks, modifier helpers, pattern aggregation.= 7.0) and scale-bump correctness against a pure-Python reference on crafted amax inputs (bump iffamax_normalized > 7.0).Numerical parity is checked against pure-PyTorch references (bf16 and plain-MXFP4), which keeps AdaHOP/kernel porting errors separable from MXFP4 quantization error. AdaHOP
"none"is asserted to reproduce the plain-MXFP4 baseline exactly.End-to-end: gpt_oss_20b MXFP4 training runs with the
adahop/deosc/midmaxrecipes vs themxfp4_basebaseline.mxfp4_base) final loss:<TODO><TODO><TODO>plotting/plot_training_stats.py)Integration smoke scripts added under
tests/integration/(llama3_debugmodel_baseline,llama3_debugmodel_adahop,llama3_debugmodel_adahop_short,llama3_1b_adahop) for a quick recipe-runs check.Scope
mxfp4_adahopscheme;full_precision_backwardremains restricted to the plainmxfp4scheme.MoEMatmulPatternObserverModifiermust run in eager mode (thetorch._grouped_mmmonkeypatch is invisible to a compiled graph); the low-precision path itself is backend-agnostic (CDNA3 loop fallback and CDNA4 kernels alike).MXFP4ForwardOnlyLinearFunctionsupports the non-CDNA4 (QDQ) path only (asserted at entry); midmax/SCALE_SELECTIONkernel paths use the CDNA4 (gfx950) ASM path where available.GradientClippingModifiermust be listed afterLowPrecisionTrainingModifierin a recipe soswap_paramshas already tagged the wrapped weights.3rdparty/adahopsubmodule is loaded by file path (never added tosys.modulesas a package) specifically so its vendoredtorchtitancannot shadow ALTO's.Reviewer Notes
"none"and mutates modes in place at the Phase-A→Phase-B boundary rather than swapping wrapper types or allocating new parameters — this is what keeps optimizer state and checkpoint resume valid. Resume logic inon_pre_stepinspects the checkpointedCalibrationStateManager: if calibration already completed it re-applies restored modes and skips calibration (clean resume).3rdparty/adahop(AMDResearch/low-precision-training, branchAdaHOP_C42) — reviewers/CI mustgit submodule update --init --recursive.SCALE_SELECTIONconstexpr, which also carries theuos/uos6variants.rad/midmax,rad/scale-selection, andyann_moe(M+Adam / de-oscillation). The final commits repoint the adahop/lpt recipe configs back to the original rad/lpt baseline files.