Skip to content

[JAX] Add JAX SiTU fallback to MoEBlock - #3928

Draft
pggPL wants to merge 14 commits into
NVIDIA:mainfrom
pggPL:jax_moe_situ
Draft

pggPL wants to merge 14 commits into
NVIDIA:mainfrom
pggPL:jax_moe_situ

Conversation

@pggPL

@pggPL pggPL commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Follow-up to NVIDIA/TransformerEngine#3873, now merged into main. Add a pure JAX SiTU-GLU fallback to MoEBlock for BF16 and configurations where the cuDNN Frontend fusions do not apply. No group-aware activation kernels are added.

Eligible MXFP8 configurations continue using cuDNN SiTU-GLU/dGLU fusion. With use_cudnn_fusion=False, or when fusion is unavailable, evaluate both soft caps in FP32 using JAX between the existing grouped GEMMs and compute both branch gradients with jax.vjp. Device expert counts mask inactive values and gradients, including NaN-filled receive-buffer tails. Activation output keeps the projection dtype, and fallback MXFP8 quantization remains separate. Ineligible fusion requests warn and fall back using the existing MoE policy.

After updating to main (a6393d0), validated 59 focused cases on RTX 5880 Ada, using the actual shared parameter and tensor classes, existing activation/VJP routines and complete per-shard forward/backward source. This includes existing default/custom parameter-forwarding tests with mocked cuDNN, fusion selection for SM89/100/103/107, FP32/FP16/BF16 activation and gradient checks, inactive/empty capacity, dynamic counts, vmap/rematerialization, and forward/backward composition with early/late routing weights, biases and SwiGLU controls. Native grouped GEMM/quantization are JAX test doubles in the backward harness; this is not a full TE/EP or fused-cuDNN GPU integration result. Also passed 48 existing adapter compatibility cases on CPU, full JAX/common Python lint (10.00/10), pre-commit, source license and diff checks. Distributed SiTU cases are prepared in the existing MoE suite; full Blackwell/NCCL/EP and Kimi-K3 training were not rerun.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

  • Add SiTU gate/up operations to the shared activation converter and reuse _jax_act_lu / _jax_quantize_dact_dbias in MoE, with capacity masking at the call sites.
  • Reuse the activation string and shared ActivationParams plumbing introduced in NVIDIA/TransformerEngine#3873.
  • Allow SiTU with disabled or unsupported cuDNN fusion, retaining existing eligible fusion selection.
  • Preserve projection dtypes, early routing-weight gradients, grouped GEMMs and grouped quantization.
  • Cover fallback behavior and update the existing API, distributed numerical tests and documentation.

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

pggPL and others added 14 commits November 16, 2026 11:45
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Reuse the upstream SiTU activation string and ActivationParams container. Keep eligible cuDNN fusion and use masked JAX activation operations with a VJP for unfused execution.

Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Define SiTU gate and up operations in the existing parameter-aware activation converter. Use one masked gated-activation helper and VJP for SiTU and SwiGLU, and move fallback documentation from the API index to the moe parameters.

Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Remove _apply_ffn_activation and call the existing JAX activation and VJP routines. Keep receive-capacity masking at the MoE call sites and exercise the actual forward/backward composition.

Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>

This branch has not been deployed

No deployments
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.

1 participant