Prhub

#23532 docs: add Hunyuan 3 Preview cookbook

原始 PR 作者 JustinTong0323 合并时间 2026-04-23 17:44 文件变更 3 提交数 2 评论 1 代码增减 +707 / -0

执行摘要

为 Hunyuan 3 Preview 添加部署 cookbook 和交互式生成器。

为即将发布的 Hunyuan 3 Preview 模型提供官方部署指南,使用户能够快速上手。PR body 强调模型代码尚未 upstream,文档先行以降低发布后的沟通成本。

值得阅读的是交互式生成器的硬件配置逻辑(generateCommand 函数),它体现了 Blackwell 架构的特殊 attention backend 选择。其他部分为标准 cookbook 格式,适合作为文档编写参考。

讨论亮点

无显著讨论。审核者 Qiaolin-Yu 直接批准,未留下评论。

实现拆解

  1. 创建文档主体:在 docs_new/cookbook/autoregressive/Tencent/Hunyuan3-Preview.mdx 中编写 527 行 Mintlify 格式文档,涵盖模型架构(MoE 276B/20B active)、混合推理(reasoning_effort)、工具调用、256K 上下文、MTP 推测解码等特性,并附上推荐生成参数表格和 GPU 硬件需求表格。
  2. 开发交互式部署命令生成器:在 docs_new/src/snippets/autoregressive/hunyuan3-preview-deployment.jsx 中新增 React 组件 Hunyuan3PreviewDeployment,允许用户选择硬件平台(H200/B200/B300/GB300)、推理解析器、工具调用解析器和推测解码开关,实时生成带 --tp--reasoning-parser hunyuan--tool-call-parser hunyuan--speculative-algorithm EAGLE 等参数的 sglang serve 命令。对 Blackwell 硬件自动追加 --attention-backend trtllm_mha
  3. 更新导航配置:在 docs_new/docs.json 的 Autoregressive Models 分组末尾添加 Tencent 子分组,指向新文档路径。
文件 模块 状态 重要度
docs_new/cookbook/autoregressive/Tencent/Hunyuan3-Preview.mdx 文档 added 6.02
docs_new/src/snippets/autoregressive/hunyuan3-preview-deployment.jsx 交互式组件 added 8.77
docs_new/docs.json 导航配置 modified 3.37

关键符号

Hunyuan3PreviewDeployment resolveItems getInitialState checkDarkMode handleRadioChange generateCommand

关键源码片段

docs_new/src/snippets/autoregressive/hunyuan3-preview-deployment.jsx core-logic

交互式部署命令生成器,用户通过单选按钮调整参数,实时生成 sglang serve 命令。

export const Hunyuan3PreviewDeployment = () => {
  // 定义可选的硬件平台及对应的 tp 值和显存占用
  const options = {
    hardware: {
      name: 'hardware',
      title: 'Hardware Platform',
      items: [
        { id: 'h200', label: 'H200', default: true },
        { id: 'b200', label: 'B200', default: false },
        { id: 'b300', label: 'B300', default: false },
        { id: 'gb300', label: 'GB300', default: false }
      ]
    },
    reasoning: {
      name: 'reasoning',
      title: 'Reasoning Parser',
      items: [
        { id: 'disabled', label: 'Disabled', default: false },
        { id: 'enabled', label: 'Enabled', default: true }
      ]
    },
    toolcall: {
      name: 'toolcall',
      title: 'Tool Call Parser',
      items: [
        { id: 'disabled', label: 'Disabled', default: false },
        { id: 'enabled', label: 'Enabled', default: true }
      ]
    },
    speculative: {
      name: 'speculative',
      title: 'Speculative Decoding (MTP)',
      items: [
        { id: 'disabled', label: 'Disabled', default: true },
        { id: 'enabled', label: 'Enabled', subtitle: 'Low Latency', default: false }
      ]
    }
  };  // 每个硬件对应的配置:tp 和 mem_fraction
  const modelConfigs = {
    h200: { tp: 8, mem: 0.9 },
    b200: { tp: 8, mem: 0.9 },
    b300: { tp: 4, mem: 0.9 },
    gb300: { tp: 4, mem: 0.9 }
  };  // ... ( 中间的状态管理和暗模式检测略 )  /**
   * 根据用户选择生成 sglang serve 命令
   * - 若启用推测解码,前置环境变量 SGLANG_ENABLE_SPEC_V2=1
   * - Blackwell 硬件自动追加 --attention-backend trtllm_mha
   */
  const generateCommand = () => {
    const { hardware } = values;
    const isBlackwell = hardware === 'b200' || hardware === 'b300' || hardware === 'gb300';
    const hwConfig = modelConfigs[hardware];
    if (!hwConfig) return '# Configuration not available for the selected hardware.';    const modelName = 'tencent/Hy3-preview';
    const tpValue = hwConfig.tp;
    const memFraction = hwConfig.mem;
    const enableSpec = values.speculative === 'enabled';    let cmd = '';
    if (enableSpec) cmd += 'SGLANG_ENABLE_SPEC_V2=1 ';
    cmd += 'sglang serve \\n';
    cmd += `  --model-path ${modelName}`;
    cmd += ` \\n  --tp ${tpValue}`;    if (values.reasoning === 'enabled') cmd += ' \\n  --reasoning-parser hunyuan';
    if (values.toolcall === 'enabled') cmd += ' \\n  --tool-call-parser hunyuan';
    if (enableSpec) {
      cmd += ' \\n  --speculative-algorithm EAGLE';
      cmd += ' \\n  --speculative-num-steps 3';
      cmd += ' \\n  --speculative-eagle-topk 1';
      cmd += ' \\n  --speculative-num-draft-tokens 4';
    }
    cmd += ' \\n  --trust-remote-code';
    cmd += ` \\n  --mem-fraction-static ${memFraction}`;
    if (isBlackwell) cmd += ' \\n  --attention-backend trtllm_mha';
    return cmd;
  };

评论区精华

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

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

风险与影响

  1. 占位符依赖:Section 2 的 Docker tag lmsysorg/sglang:hy3-preview{,-cu130} 和 License 行均为占位符,需在模型代码发布后更新,否则用户可能混淆。
  2. 模型代码未上游HYV3ForCausalLMhunyuan 解析器、MTP 加载器尚未合入主分支,文档中的命令在无对应代码时无法工作。
  3. 硬件配置假设:交互生成器移除了 A100/H100(因 BF16 权重无法单节点容纳),但若未来提供更低精度版本,此假设需调整。

对用户:提供清晰的 Hunyuan 3 Preview 部署路径,降低上手门槛;对系统:无代码变更,不影响运行时代码;对团队:文档维护成本低,但需在模型代码发布时同步更新占位符。

占位符需更新 依赖未上游

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论