megatron-migration-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Megatron Migration Generator

Megatron迁移生成器

Generate implementation-oriented migration artifacts for MindSpeed only after upstream change analysis and impact mapping have narrowed the work to a high-confidence set of items. The goal is to port the upstream feature into MindSpeed with the upstream commit as the primary reference, not to emit a tiny patch hint.
仅在完成上游变更分析和影响映射,将工作范围缩小到高置信度项目集合后,为MindSpeed生成面向实现的迁移工件。目标是以上游提交为主要参考,将上游功能移植到MindSpeed中,而非生成微小的补丁提示。

Default Output Mode

默认输出模式

Default to
report + patch
, and generate the final markdown deliverable in Chinese unless the user explicitly requests another locale.
Do not default to direct code edits or automatic commits. Default to an implementation-first package, not a minimal patch sketch.
默认采用
report + patch
模式,除非用户明确要求其他语言,否则生成最终的中文Markdown交付物。
请勿默认直接进行代码编辑或自动提交。 默认生成面向实现的完整包,而非最小化补丁草图。

Supported Modes

支持的模式

  1. report
    Produce a migration report only.
  2. patch
    Produce a migration report plus a full implementation reference package. Default to per-feature folders containing
    full.patch
    , split
    patches/
    , upstream reference metadata, implementation checklists, and explicit uncovered scope.
  3. apply
    Edit the local workspace without creating a commit. Use only when alignment and impact confidence are high.
  4. commit
    Reserve for explicit user requests after patch review. Do not use as the first-pass default.
  1. report
    仅生成迁移报告。
  2. patch
    生成迁移报告加上完整的实现参考包。默认按功能创建文件夹,包含
    full.patch
    、拆分的
    patches/
    目录、上游参考元数据、实现检查清单以及明确标注的未覆盖范围。
  3. apply
    编辑本地工作区但不创建提交。仅在对齐度和影响置信度较高时使用。
  4. commit
    仅在补丁审核后,用户明确要求时使用。请勿将其作为首次处理的默认选项。

Entry Conditions

准入条件

Proceed only when all of the following are true:
  • MindSpeed branch is known.
  • Megatron base branch is known.
  • Megatron target branch or change-set is known.
  • Relevant impact items already exist.
  • Each migration-worthy item includes upstream commit references and enough implementation scope to tell config/runtime/wrapper/test work apart.
If any of these are missing, stop and ask for or derive the missing prerequisite instead of guessing.
仅当以下所有条件均满足时才可执行:
  • 已知MindSpeed分支。
  • 已知Megatron基础分支。
  • 已知Megatron目标分支或变更集。
  • 已存在相关影响项。
  • 每个值得迁移的项均包含上游提交引用,且具备足够的实现范围,可区分配置/运行时/包装器/测试工作。
若缺少任何一项,请停止操作并请求或推导缺失的前提条件,切勿猜测。

Workflow

工作流程

  1. Read the impact report.
  2. Separate high-confidence items from speculative items.
  3. For each high-confidence item, describe: the upstream event, the upstream commit and changed files, the upstream implementation units, the local adaptation target, the intended code change, the uncertainty.
  4. Generate: one integrated
    migration_report.md
    impact_report.json
    if needed for carry-forward
    candidate_patch.md
    as a compact summary index a
    features/
    directory with one subfolder per migration item, each containing:
    full.patch
    for the full local implementation draft
    patches/
    for split patch series organized by implementation unit
    candidate.patch
    as the compatibility entry patch
    README.md
    ,
    checklist.md
    ,
    package_manifest.json
    , and
    upstream_reference.json
  5. If in
    apply
    mode, edit only the approved files and leave a clear explanation of what changed.
  1. 读取影响报告。
  2. 将高置信度项目与推测性项目分离。
  3. 针对每个高置信度项目,描述: 上游事件, 上游提交及变更文件, 上游实现单元, 本地适配目标, 预期代码变更, 不确定性。
  4. 生成: 一个整合的
    migration_report.md
    若需要后续使用则生成
    impact_report.json
    作为紧凑汇总索引的
    candidate_patch.md
    一个
    features/
    目录,每个迁移项对应一个子文件夹,包含: 完整本地实现草稿的
    full.patch
    按实现单元组织的拆分补丁系列
    patches/
    作为兼容性入口补丁的
    candidate.patch
    README.md
    checklist.md
    package_manifest.json
    upstream_reference.json
  5. 若处于
    apply
    模式,仅编辑已批准的文件,并留下清晰的变更说明。

Safety Rules

安全规则

  • Never generate migration code directly from raw commit history without an impact report.
  • Avoid direct edits in exploration mode.
  • When the target is
    megatron main
    , frame code output as a candidate adaptation draft, not a compatibility-guaranteed migration.
  • Prefer patch artifacts over commits because they are easier to review and safer when branch alignment is still evolving.
  • Do not treat one local file edit as a complete feature migration when the upstream commit spans config, runtime logic, wrappers, and tests.
  • When a full migration package cannot be completed from the available inputs, explicitly record uncovered implementation units, omitted scope, and manual follow-ups instead of pretending the feature is complete.
  • 切勿在无影响报告的情况下直接从原始提交历史生成迁移代码。
  • 在探索模式下避免直接编辑。
  • 当目标为
    megatron main
    时,将代码输出标注为候选适配草稿,而非保证兼容性的迁移版本。
  • 优先选择补丁工件而非提交,因为在分支对齐仍在演进时,补丁更易于审核且更安全。
  • 当上游提交涉及配置、运行时逻辑、包装器和测试时,请勿将单个本地文件编辑视为完整的功能迁移。
  • 若无法通过现有输入完成完整迁移包,请明确记录未覆盖的实现单元、省略的范围以及后续手动操作事项,切勿假装功能已完成。

Static Validation

静态验证

Keep validation lightweight and local:
  • patch applies cleanly
  • paths exist
  • names and arguments match local code structure
  • basic syntax or lint-level checks when available
  • the package explains which upstream implementation units are already ported and which remain to be ported
Do not imply that training correctness, performance, or numerical accuracy has been verified.
保持验证轻量化且本地化:
  • 补丁可干净地应用
  • 路径存在
  • 名称和参数匹配本地代码结构
  • 若可用则进行基本语法或 lint 级检查
  • 包中需说明哪些上游实现单元已移植,哪些仍待移植
请勿暗示已验证训练正确性、性能或数值精度。

References

参考资料

  • Read migration-modes.md before choosing the output form.
  • Read implementation-first-package.md before generating a migration package that claims to represent a feature implementation.
  • Read report-template.md for the expected integrated markdown deliverable structure. Default to Chinese report language.
  • Run synthesize_full_patch_series.py after impact mapping when you want known feature commits to expand into fuller multi-file patch series instead of staying as single-file placeholders.
  • Run render_migration_artifacts.py to turn an
    impact_report.json
    into reviewable report and patch-plan artifacts before any manual refinement.
  • 在选择输出形式前,请阅读migration-modes.md
  • 在生成声称代表功能实现的迁移包前,请阅读implementation-first-package.md
  • 如需了解预期的整合Markdown交付物结构,请阅读report-template.md。默认使用中文生成报告。
  • 当希望将已知功能提交扩展为更完整的多文件补丁系列而非单文件占位符时,请在影响映射后运行synthesize_full_patch_series.py
  • 在进行任何手动优化前,如需将
    impact_report.json
    转换为可审核的报告和补丁计划工件,请运行render_migration_artifacts.py