Prhub

#27726 [Docs] Update MegaMoE handling and rerun benchmarks

原始 PR 作者 zijiexia 合并时间 2026-06-10 10:00 文件变更 8 提交数 1 评论 1 代码增减 +133 / -193

执行摘要

更新 DeepSeek-V4 playground 的 MegaMoE 处理并刷新基准数据

PR body指出三点:

1) update MegaMoE handling in playground;
2) update the high-throughput to use megamoe w4a8 instead of w4a4 for accuracy degradation concern;
3) update benchmark results。同时伴随cookbook-add-model技能的模板和文档同步。

值得关注的设计决策:将MegaMoE从独立axis合并到moe axis,减少UI层级并利用已有的backend选择机制;通过requiresHw实现硬件门控,通过megamoeQuant子选择分离量化配置,保持了模块化。建议文档维护者留意配置与运行时一致性。

讨论亮点

PR无review评论,仅有一个approve(wisclmy0611)。变更主要为自包含的文档更新,未产生实质性技术讨论。

实现拆解

  1. Playground引擎(_playground.jsx):移除独立的megamoe axis,在moe axis handler中增加mmQuant状态,新增deriveFromBase从base环境变量(SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS)派生出w4a4/w4a8revertHidden增加MegaMoE硬件/策略门控检查;apply增加MegaMoE量化子选择的环境变量注入逻辑。
  2. DeepSeek-V4配置(deepseek-v4.jsx):将moe轴的backend选项中原有的megamoeOn禁用逻辑替换为requiresHw门控;删除独立的megamoe axis配置,新增megamoeQuant子配置块(含stripEnvw4a8/w4a4选项);高吞吐策略默认使用W4A8;增加--warmup-requests 64到speed命令,调整numPromptsByConc
  3. 基准数据(deepseek-v4-benchmarks.jsx):更新B200/B300各策略下的TTFT、TPOT和吞吐数值(例如B200 low-latency flash TTFT从428ms降至87ms),移除部分pro high-throughput条目。
  4. 技能模板与文档:同步更新.claude/skills/cookbook-add-model/下的config.jsx.tmpl(增加MegaMoE/megamoeQuant模板注释)、engine-axis.md(轴数量从8减为7,MegaMoE归入moe)和authoring-reference.md(moe轴说明更新)。
文件 模块 状态 重要度
docs_new/src/snippets/_playground.jsx Playground 引擎 modified 8.18
docs_new/src/snippets/configs/deepseek-ai/deepseek-v4.jsx 模型配置 modified 6.68
docs_new/src/snippets/configs/deepseek-ai/deepseek-v4-benchmarks.jsx 基准数据 modified 6.37
.claude/skills/cookbook-add-model/templates/config.jsx.tmpl 技能模板 modified 4.35

关键符号

baseEnv mmOpt opt

关键源码片段

docs_new/src/snippets/_playground.jsx core-logic

核心 Playground 引擎变更:将 MegaMoE 从独立 axis 迁移到 moe axis 内,作为后端选项并添加量化子选择,同时更新注释和条件逻辑。

// moe axis handler 关键方法(合并 MegaMoE 后)
moe: {
  initState: () => ({ backend: null, ep: null, mmQuant: null }),  // 从 base cell 推导初始状态:检查环境变量判断是否为 W4A4
  deriveFromBase: (cell, fc, h) => {
    const flags = (cell && cell.flags) || [];
    const baseEnv = (cell && cell.env) || [];
    const a2a = h.findFlagArg(flags, "--moe-a2a-backend");
    const runner = h.findFlagArg(flags, "--moe-runner-backend");
    // 检测 FP4 activations 环境变量以区分 W4A8/W4A4
    const fp4Acts = baseEnv.some(
      (e) => e.startsWith("SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS"));
    return {
      backend: a2a || runner || null,
      ep: h.parseIntFlag(flags, "--ep"),
      mmQuant: fp4Acts ? "w4a4" : "w4a8",
    };
  },  // 回退隐藏:当用户选择被隐藏时置 null;新增 MegaMoE 可用性门控
  revertHidden: (value, fc, base, h) => {
    let changed = false;
    const next = { ...value };
    if (next.backend !== null && fc.backend?.options
        && h.isHidden(fc.backend.options, next.backend, base)) {
      next.backend = null; changed = true;
    }
    // 检查 MegaMoE 选项是否因硬件 / 策略被隐藏
    const mmOpt = (fc.backend?.options || []).find((o) => o.id === "megamoe");
    const mmAvail = !!mmOpt
      && (!mmOpt.requiresHw || mmOpt.requiresHw.includes(base.hw))
      && (!mmOpt.excludesStrategy || !mmOpt.excludesStrategy.includes(base.strategy));
    if (next.backend === "megamoe" && !mmAvail) {
      next.backend = null; changed = true;
    }
    if (next.ep !== null && fc.ep?.values
        && h.isHidden(fc.ep.values, next.ep, base)) {
      next.ep = null; changed = true;
    }
    return changed ? next : value;
  },  // apply 方法也相应更新(注入 MegaMoE 量化环境变量)
}
docs_new/src/snippets/configs/deepseek-ai/deepseek-v4.jsx data-contract

DeepSeek-V4 配置更新:调整 MegaMoE backend 选项(移除原有 megamoe axis 配置,改为 moe 轴内的子选项)、增加 megamoeQuant 量化子配置、更新高吞吐策略为 W4A8、调整 numPromptsByConc 和添加 warmup-requests。

// moe 轴 backend 选项中的 MegaMoE 条目(新增 requiresHw 硬件门控)
options: [
  { id: null, label: "Inherited" },
  { id: "deepep", label: "DeepEP",
    flags: ["--moe-a2a-backend deepep"] },
  // Blackwell-only; 无策略门控,playground 允许任何策略实验
  { id: "megamoe", label: "MegaMoE",
    flags: ["--moe-a2a-backend megamoe"],
    requiresHw: ["b200", "b300", "gb200", "gb300"] },
  { id: "flashinfer_mxfp4", label: "FlashInfer (MXFP4)",
    flags: ["--moe-runner-backend flashinfer_mxfp4"] },
  { id: "marlin", label: "Marlin (W4A16)",
    flags: ["--moe-runner-backend marlin"] },
],// 新增:MegaMoE 量化子选择(仅在 backend === "megamoe" 时显示)
megamoeQuant: {
  // 选择任一量化都会 strip DeepEP 环境变量
  stripEnv: ["SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK"],
  options: [
    { id: "w4a8", label: "W4A8",
      // 仅设置 NUM_MAX
      env: ["SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=8320"] },
    { id: "w4a4", label: "W4A4",
      // 额外设置 FP4 激活和 MXF4 内核
      env: [
        "SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=8320",
        "SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_FP4_ACTS=1",
        "SGLANG_OPT_DEEPGEMM_MEGA_MOE_USE_MXF4_KIND=1",
      ] },
  ],
},

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

风险极低,仅影响交互式文档的配置示例和基准展示。需注意:

1) playground配置与运行时实际支持的选项可能存在偏差(如requiresHw与实际硬件限制);
2) 基准数字更新可能依赖于特定sglang版本,用户运行结果可能不同。

影响范围集中:DeepSeek-V4 cookbook页面的Playground组件和Benchmark卡片;用户通过文档获取的配置示例将反映MegaMoE的新交互方式;cookbook作者需了解MegaMoE不再作为独立axis。

文档配置可能过时 示例可能与实际行为不同步

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论