mindspore-ai / mindspore-ai/hyper-parallel

[Feature]: support DeepSeek-V4.1 clamped SwiGLU in MegaMoe

Open
#856 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
53
Forks
63
Avg merge
23h 45m
Merged PRs (30d)
63

Description

功能描述

DeepSeek-V4.1 的 MoE expert 使用 clipped SwiGLU 语义:gate 分支仅进行正向上界 clamp,up 分支进行对称 clamp,且前反向必须采用一致的导数掩码。当前 MegaMoe 基于 CANN ops-nn v9.1.0.pre 的常规 SwiGLU 前反向接口,无法传递该任务级参数,因此在边界输入下无法与原始 DeepSeek-V4.1 expert + EP adapter 路径逐 bit 对齐。

目标是在保持 CANN 9.1 依赖版本不变的前提下,使 MegaMoe 能通过 Python 接口配置该语义,并在未配置时保留既有路径和性能。

现有替代方案

  1. 直接使用 CANN 9.2 的官方 ClippedSwiGLU 算子。该方案需要单独升级或混用 CANN 依赖版本,增加部署和 A3 兼容风险。
  2. 继续使用未 clamp 的常规 SwiGLU。该方案无法与 DeepSeek-V4.1 专家路径逐 bit 对齐。
  3. 在现有锁定的 ops-nn v9.1.0.pre 源码上增加最小 patch。该方案复用当前构建链路和算子实现,避免引入额外 CANN 版本,因此选用。

与 DFX 相关性

该功能面向 DeepSeek-V4.1 的 MoE 整网训练接入。默认 swiglu_limit=None 继续使用既有 SwiGLU 前反向实现,不引入额外 kernel 或执行分支。配置正数时,clamp 值通过既有 task descriptor 传递给融合 kernel,避免在 Python 层拆分激活计算。后续 A3 跨机测试可复用同一 CANN 9.1 依赖锁定与构建入口。

提议的新 API

MegaMoeExperts 增加仅关键字参数 swiglu_limit: float | None = None。传入有限正数时启用 clipped SwiGLU;传入 None 时保持既有行为。非法值在 Python 层和 task 构建层拒绝。

是否影响现有 API

新增参数有默认值且为可选关键字参数。未配置时 task descriptor 的新增字段保持为零,融合 kernel 执行原有未 clamp 分支,因此现有模型调用方式、算子路径和性能不变。

补充信息

在 Ascend 910B、EP8 的确定性对照中,启用 clamp 后 MegaMoe 输出、输入梯度、路由权重梯度、专家梯度和一步 SGD 后参数与原始 DeepSeek-V4.1 路径逐 bit 一致;未启用 clamp 时保留预期数值差异。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the MegaMoeExperts Python API and the existing CANN ops-nn v9.1.0.pre SwiGLU forward/backward and task-descriptor path. Check how a finite positive swiglu_limit, None, and invalid values are represented and rejected. Done means the configured path matches the stated DeepSeek-V4.1 comparisons while the default path and performance remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.