Skip to content

DMuon

Dedicated ownership for matrix optimizers on PyTorch DDP, FSDP2, and HSDP.

PYTORCH · MATRIX OPTIMIZATION

One owner per logical matrix.

Run each Muon matrix update on its owner rank. Choose optimizer routes, wrapping boundaries, and matrix layouts independently, using your existing PyTorch model.

Get started Explore matrix layouts

News

  • Native multi-parallelism with OwnershipDomain

    November 27, 2026

    Combine DP, HSDP, CP, EP, PP, and TP in one dedicate_params() call with per-domain grad_scale, domain-local checkpointing, and global or per-algorithm gradient clipping.

    Ownership domains guide

  • Matrix layouts for fused weights and MoE

    November 9, 2026

    Configure QKV, per-head, and per-expert Muon updates without changing your model. Batched CUDA copies combine layout conversion and dtype casting.

    Matrix layout guide

  • DMuon Ascend is available

    October 14, 2026

    Experimental native Ascend 950DT support through the same public API.

    Ascend installation

What DMuon Can Do

LLM Pretraining — Llama, Qwen, Mistral on FSDP2/HSDP

Train transformer language models with Muon at near-AdamW cost. Dedicated ownership routes each projection parameter to a single owner; Newton-Schulz runs once per step with zero optimizer all-gather. Tested on Qwen2.5 (1.5B–7B) and Llama-3 (3B–8B) on 8×A800, with step overhead of only 4–13% vs FSDP2+AdamW.

import dmuon
from torch.distributed.fsdp import fully_shard

dmuon.dedicate_params(
    model, mesh,
    predicate=lambda n, p: "proj" in n and p.ndim == 2,
)
for layer in model.layers:
    fully_shard(layer, mesh=mesh)
fully_shard(model, mesh=mesh)

optimizer = dmuon.Muon(model, lr=0.02, ns_steps=5, adamw_lr=1e-3)
Multi-Node HSDP — 2D mesh with async broadcast hiding

Scale beyond one node using a (replicate, shard) 2D device mesh. DMuon performs a two-stage gradient reduce (shard → replicate) and dispatches the post-step replicate broadcast on a dedicated CUDA stream, hiding it behind the next iteration's forward compute. Bit-identical to the synchronous baseline; falls back automatically if the broadcast cannot hide.

hsdp = init_device_mesh(
    "cuda", (replicate_size, shard_size),
    mesh_dim_names=("replicate", "shard"),
)
dmuon.dedicate_params(
    model, hsdp["shard"],
    predicate=lambda n, p: "proj" in n and p.ndim == 2,
    replicate_mesh=hsdp["replicate"],
)
optimizer = dmuon.Muon(model, lr=0.02, replicate_async=True)
VLA and VLM — Vision-Language-Action and Vision-Language Models

DMuon's predicate-based selection works with any architecture. For VLMs and VLAs, start by applying the predicate to trainable attention and MLP projection layers that need Muon. Parameters not selected by the predicate, such as embeddings, frozen vision towers, or task heads, remain under standard FSDP2. If the vision encoder is trainable and uses compatible projection layers, include it by extending the predicate and hook boundaries. TP compatibility via Gram Newton-Schulz (O(d_model²) communication) keeps DMuon usable with column/row-parallel tensor parallelism.

MoE — Stacked experts and fused weights

Use MatrixLayout to specify independent expert, gate/up, or attention-head updates while preserving the model's modules and parameter shapes. Select layouts with parameter policies and keep communication grouped at decoder hook boundaries.

Configure matrix layouts.


Key Features

  • HSDP Native

    2D (replicate, shard) mesh with two-stage reduce and async forward-hidden broadcast. Single API change from 1D shard-only.

  • DMuon-Z2 / DMuon-Z3

    Mirror FSDP2's reshard_after_forward for Muon-target parameters. Z3 (default) is memory-optimal; Z2 saves one broadcast per layer.

  • Hook Boundary Control

    hook_boundary_predicate decouples hook attachment from partition. Align exactly with your fully_shard() boundaries for any architecture.

  • Bit-Identical Correctness

    Async and sync HSDP paths produce identical loss trajectories. Validated on 4-GPU (G=2, R=2) and tested via checkpoint restart.

  • FSDP2 Compatible

    No modifications to FSDP2 internals. A lightweight monkey-patch makes fully_shard() skip dedicated params automatically on import.

  • Apache 2.0

    Permissive license. Use in research or production without restriction.


Benchmarks

Current snapshot: A800-SXM4-80GB, bf16, seq=4096 for LLM runs, random initialization, synthetic data. MFU is computed from step-start intervals so cross-step communication overlap is not double-counted. These rows are point-in-time research-preview summaries from controlled A800 runs; use them as relative performance context rather than a public reproduction recipe.

LLM Z2/Z3 Scaling

Model / 128GPU AdamW MFU range DMuon MFU range Best DMuon topology
Qwen2.5-1.5B 36.3–43.6% 38.4–43.1% HSDP-Z2, 43.1%
Qwen2.5-7B 43.0–48.3% 39.7–48.0% FSDP-Z2, 48.0%
Llama-3.2-3B 46.1–48.1% 46.4–48.6% HSDP-Z2, 48.6%
Llama-3.1-8B 47.0–49.9% 41.1–46.2% FSDP-Z2, 46.2%

The 128GPU rows cover FSDP-Z2, FSDP-Z3, HSDP-Z2, and HSDP-Z3.


Getting Started

  • Installation

    Install DMuon from source and verify your CUDA environment.

    Installation

  • Quick Start

    Running scripts for DDP-style, FSDP2, and HSDP — pick your topology.

    Quick Start

  • Matrix Layouts

    Configure fused QKV, per-head updates, and stacked MoE experts.

    Matrix Layouts

  • HSDP Guide

    Complete walkthrough: 2D mesh, async mode, and checkpointing.

    HSDP Guide