implementations and experimentation on mHC by deepseek - https://arxiv.org/abs/2512.24880
Shell
377
60 commits
updated Feb 17, 2026
Research implementation of mHC (DeepSeek; https://arxiv.org/abs/2512.24880) as a drop-in variant of Hyper-Connections (https://arxiv.org/abs/2409.19606).
A runnable PyTorch implementation of the mHC layer update
x_{l+1} = H_l^{res} x_l + H_l^{post,T} F(H_l^{pre} x_l, W_l)
with the key constraints:
H_res: doubly stochastic (Birkhoff polytope; entries ≥ 0, rows sum to 1, cols sum to 1), via Sinkhorn-Knopp.H_pre, H_post: non-negative mixing maps.Static per-layer matrices:
H_res_logits ∈ R^{s×s} and project to H_res with SinkhornH_pre_logits, H_post_logits and map to non-negative weights (e.g. softmax)This is a research prototype aimed at correctness + clarity, not the paper's systems optimizations.
Run from examples/nanogpt/. Adjust --nproc_per_node to match your GPU count.
6-layer configs (~20M params):
python train.py config/train_fineweb10B.py
python train.py config/train_fineweb10B_hc.py
python train.py config/train_fineweb10B_mhc.py
python train.py config/train_fineweb10B_vres.py
python train.py config/train_fineweb10B_vres_mhc.py
python train.py config/train_fineweb10B_cvres_mhc.py
48-layer configs (~20M params):
python train.py config/train_fineweb10B_48l.py
python train.py config/train_fineweb10B_hc_48l.py
python train.py config/train_fineweb10B_mhc_48l.py
python train.py config/train_fineweb10B_vres_48l.py
python train.py config/train_fineweb10B_vres_mhc_48l.py
python train.py config/train_fineweb10B_cvres_mhc_48l.py
Multi-GPU example:
torchrun --standalone --nproc_per_node=4 train.py config/train_fineweb10B_mhc_48l.py
mHC supports an orthostochastic H_res projection via Newton-Schulz. Set mhc_h_res_proj = "orthostochastic" in your config.
By default, configs use fixed Newton-Schulz coefficients (ns_steps=5, ns_coeffs=(3.0, -3.2, 1.2)). For research, ns_coeffs can also be a per-step schedule (tuple of (a, b, c) triplets); set ns_steps = len(ns_coeffs).
For an ablation that keeps residual routing close to identity, enable:
mhc_residual_identity_mix = Truemhc_residual_alpha = 0.01This applies H_res = (1-α) * I + α * S where S is the projected matrix (Sinkhorn or orthostochastic) and α is learned.
train_fineweb10B_vres*.py enables value residual only.train_fineweb10B_vres_mhc*.py combines vRes + mHC.train_fineweb10B_cvres_mhc*.py combines vRes + mHC with v_residual_constrained=True (convex mixing via softmax).(1−α)*I + α*S instead of full doubly stochasticBuilt using code snippets from nanogpt, lucidrains/hyper-connections and my own mHC implementation.
Apache 2.0
60 commits
Shell
55.0%
Python
45.0%
implementations and experimentation on mHC by deepseek - https://arxiv.org/abs/2512.24880
Shell
377
60 commits
updated Feb 17, 2026
Research implementation of mHC (DeepSeek; https://arxiv.org/abs/2512.24880) as a drop-in variant of Hyper-Connections (https://arxiv.org/abs/2409.19606).
A runnable PyTorch implementation of the mHC layer update
x_{l+1} = H_l^{res} x_l + H_l^{post,T} F(H_l^{pre} x_l, W_l)
with the key constraints:
H_res: doubly stochastic (Birkhoff polytope; entries ≥ 0, rows sum to 1, cols sum to 1), via Sinkhorn-Knopp.H_pre, H_post: non-negative mixing maps.Static per-layer matrices:
H_res_logits ∈ R^{s×s} and project to H_res with SinkhornH_pre_logits, H_post_logits and map to non-negative weights (e.g. softmax)This is a research prototype aimed at correctness + clarity, not the paper's systems optimizations.
Run from examples/nanogpt/. Adjust --nproc_per_node to match your GPU count.
6-layer configs (~20M params):
python train.py config/train_fineweb10B.py
python train.py config/train_fineweb10B_hc.py
python train.py config/train_fineweb10B_mhc.py
python train.py config/train_fineweb10B_vres.py
python train.py config/train_fineweb10B_vres_mhc.py
python train.py config/train_fineweb10B_cvres_mhc.py
48-layer configs (~20M params):
python train.py config/train_fineweb10B_48l.py
python train.py config/train_fineweb10B_hc_48l.py
python train.py config/train_fineweb10B_mhc_48l.py
python train.py config/train_fineweb10B_vres_48l.py
python train.py config/train_fineweb10B_vres_mhc_48l.py
python train.py config/train_fineweb10B_cvres_mhc_48l.py
Multi-GPU example:
torchrun --standalone --nproc_per_node=4 train.py config/train_fineweb10B_mhc_48l.py
mHC supports an orthostochastic H_res projection via Newton-Schulz. Set mhc_h_res_proj = "orthostochastic" in your config.
By default, configs use fixed Newton-Schulz coefficients (ns_steps=5, ns_coeffs=(3.0, -3.2, 1.2)). For research, ns_coeffs can also be a per-step schedule (tuple of (a, b, c) triplets); set ns_steps = len(ns_coeffs).
For an ablation that keeps residual routing close to identity, enable:
mhc_residual_identity_mix = Truemhc_residual_alpha = 0.01This applies H_res = (1-α) * I + α * S where S is the projected matrix (Sinkhorn or orthostochastic) and α is learned.
train_fineweb10B_vres*.py enables value residual only.train_fineweb10B_vres_mhc*.py combines vRes + mHC.train_fineweb10B_cvres_mhc*.py combines vRes + mHC with v_residual_constrained=True (convex mixing via softmax).(1−α)*I + α*S instead of full doubly stochasticBuilt using code snippets from nanogpt, lucidrains/hyper-connections and my own mHC implementation.
Apache 2.0
60 commits
Shell
55.0%
Python
45.0%