Skip to content

[tml] fp32 MoE activation and combine for bf16 inference alignment - #68

Merged
Zhichenzzz merged 1 commit into
miles-mainfrom
inkling-support
Jul 30, 2026
Merged

[tml] fp32 MoE activation and combine for bf16 inference alignment#68
Zhichenzzz merged 1 commit into
miles-mainfrom
inkling-support

Conversation

@Zhichenzzz

@Zhichenzzz Zhichenzzz commented Jul 15, 2026

Copy link
Copy Markdown

Two opt-in TransformerConfig knobs for MoE numerical precision on the routed-expert path, needed to match reference inference numerics for models trained with fp32 expert internals (e.g. Inkling):

  • moe_activation_in_fp32 — compute the inter-GEMM swiglu (× probs) in fp32 via _MoEActivationInFP32 (custom forward/backward), with a single rounding back to the params dtype. Grouped-GEMM path only.
  • moe_combine_in_fp32 — carry routing probs into the combine un-rounded and accumulate expert outputs in fp32, with one final round.

Both default False. Guard asserts: bf16/fp16 only (no fp8/fp4), no fused permute/unpermute, and --moe-router-dtype fp32 for combine. Existing configs are unaffected.

Rebased on latest miles-main; the NVMe optimizer store and checkpoint changes that used to live in this PR have been dropped from its scope.

@Zhichenzzz
Zhichenzzz marked this pull request as ready for review July 15, 2026 18:48
Two opt-in TransformerConfig knobs for MoE numerical precision on the routed-expert
path, needed to match reference inference numerics for models trained with fp32
expert internals:

- moe_activation_in_fp32: compute the inter-GEMM swiglu (x probs) in fp32 via
  _MoEActivationInFP32 (custom fwd/bwd), with a single rounding back to the params
  dtype. Grouped-GEMM path only.
- moe_combine_in_fp32: carry routing probs into the combine un-rounded and
  accumulate expert outputs in fp32, one final round.

Both default False and assert bf16/fp16 (no fp8/fp4), no fused permute, and fp32
router dtype for combine, so existing configs are unaffected.
@Zhichenzzz Zhichenzzz changed the title [tml] Inkling model support [tml] fp32 MoE activation and combine for bf16 inference alignment Jul 30, 2026
@Zhichenzzz
Zhichenzzz merged commit 50ac48e into miles-main Jul 30, 2026
1 check passed
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