‹ 首页

liger-autopatch

@linkedin · 收录于 昨天 · 上游提交 昨天

Adds Liger Kernel support for a new HuggingFace Transformers model, or modifies existing monkey-patching. Generates lce_forward, monkey-patch function, tests, and README entry. Use when adding a new model to Liger Kernel, when a user asks to patch an unsupported model, when extending MODEL_TYPE_TO_APPLY_LIGER_FN, or when modifying/updating/fixing an existing monkey-patch (e.g., adding a new kernel to an already-supported model, fixing instance patching, updating a patch for upstream HF changes).

适合你,如果你需要为 Transformers 模型快速添加 Liger Kernel 支持

/ 通过 npx 安装 校验哈希
npx oh-my-skill add linkedin/liger-kernel/liger-autopatch
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- linkedin/liger-kernel/liger-autopatch
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify linkedin/liger-kernel/liger-autopatch
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
6536GitHub stars
~1.1K最小装载
~5.8K含声明引用
~8.2K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 e9bbef0 · 表述以原文为准
它做什么

安装后,如果你要求添加或修改Liger Kernel对HuggingFace模型的支持,Claude会自动分析模型代码、生成补丁文件、运行测试,并在每个阶段请你确认。

什么时候触发

当你要求为Liger Kernel添加一个新模型的支持,或者更新、修复、扩展现有的模型补丁时触发。关键词如“添加”、“更新”、“修复”等。

装好后可以这样说
Claude会开始创建新模型补丁的完整流程。
Claude会进入修改模式,分析变更并应用修复。
技能原文 SKILL.md作者撰写 · BSD-3-Clause · e9bbef0

Liger Auto-Patch

Adds Liger Kernel optimization support for a new HuggingFace model, or modifies existing monkey-patching, through a staged pipeline with human review between stages. Supports creating new model patches and modifying existing ones.

Mode Detection
  • Create mode: User asks to add/patch/support a new model → full pipeline (Analyze → Generate → Validate)
  • Modify mode: User asks to update/fix/change/extend an existing monkey-patch → lighter pipeline (Change Impact Analysis → Apply Changes → Validate)

Keywords that suggest modify mode: update, fix, change, add [kernel] to [existing model], extend, modify, new activation, new norm, bug in patch, upstream changed

Pipeline (Create Mode)
Stage 1: Analyze

Follow the Model Analyzer workflow in [model-analyzer.md](model-analyzer.md). If the host runtime supports parallel subagents, this stage may be delegated to one; otherwise execute the workflow directly.

This stage reads the HF modeling_*.py source and produces a model profile answering 12 architectural questions from [decision-matrix.md](decision-matrix.md).

Human checkpoint: Present the profile. Confirm before proceeding.

Stage 2: Generate

Follow the Code Generator workflow in [code-generator.md](code-generator.md).

Generates/modifies up to 13 files:

  1. src/liger_kernel/transformers/model/{model}.py — NEW lce_forward
  2. src/liger_kernel/transformers/monkey_patch.py — MODIFY
  3. src/liger_kernel/transformers/__init__.py — MODIFY
  4. src/liger_kernel/transformers/model/output_classes.py — MODIFY if needed
  5. test/transformers/test_monkey_patch.py — MODIFY
  6. test/convergence/bf16/test_mini_models.py — MODIFY (FLCE path)
  7. test/convergence/bf16/test_mini_models_with_logits.py — MODIFY (non-FLCE path)
  8. test/convergence/fp32/test_mini_models.py — MODIFY (FLCE path)
  9. test/convergence/fp32/test_mini_models_with_logits.py — MODIFY (non-FLCE path)
  10. test/convergence/bf16/test_mini_models_multimodal.py — MODIFY if VL model
  11. test/convergence/fp32/test_mini_models_multimodal.py — MODIFY if VL model
  12. test/utils.py — MODIFY
  13. README.md — MODIFY

Human checkpoint: Present changes for review.

Stage 3: Validate

Follow the Validator workflow in [validator.md](validator.md).

Runs instance patching test, convergence test, and lint check. Retries up to 3 times on failure.

Human checkpoint: Report final test results.

Pipeline (Modify Mode)
Stage 1: Change Impact Analysis

Read the existing apply_liger_kernel_to_{model_type} function in monkey_patch.py and the relevant section of the upstream HF modeling_{model_type}.py. Produce a short change plan:

  • What is being added/changed/fixed
  • Which Liger kernel(s) are involved
  • Which files need modification (subset of the 13 files from create mode)
  • What the expected behavior should be after the change

Human checkpoint: Present the change plan. Confirm before proceeding.

Stage 2: Apply Changes

Follow the Code Generator workflow in [code-generator.md](code-generator.md) in modify mode.

Human checkpoint: Present changes for review.

Stage 3: Validate

Follow the Validator workflow in [validator.md](validator.md). This stage is mandatory — do not skip it. At minimum, run:

  1. Instance patching test: pytest test/transformers/test_monkey_patch.py -k "{model_type}" -xvs
  2. All convergence tests for the model:
  3. pytest test/convergence/bf16/test_mini_models.py -k "{model_type}" -xvs (FLCE, bf16)
  4. pytest test/convergence/bf16/test_mini_models_with_logits.py -k "{model_type}" -xvs (non-FLCE, bf16)
  5. pytest test/convergence/fp32/test_mini_models.py -k "{model_type}" -xvs (FLCE, fp32)
  6. pytest test/convergence/fp32/test_mini_models_with_logits.py -k "{model_type}" -xvs (non-FLCE, fp32)
  7. If VL (multimodal) model, also run:
  8. pytest test/convergence/bf16/test_mini_models_multimodal.py -k "{model_type}" -xvs
  9. pytest test/convergence/fp32/test_mini_models_multimodal.py -k "{model_type}" -xvs
  10. Checkstyle: make checkstyle

Human checkpoint: Report final test results.

Reference Files
  • [decision-matrix.md](decision-matrix.md) — 12 architectural decisions to resolve per model
  • [examples/llama-profile.md](examples/llama-profile.md) — Reference profile for standard dense model
  • [examples/gemma-profile.md](examples/gemma-profile.md) — Reference profile showing GeGLU + offset variant
  • Templates in [templates/](templates/) — Code generation patterns for each file type
按 BSD-3-Clause 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。