liger-autopatch

Generate and validate Liger Kernel monkey-patches for HuggingFace Transformers models.

6.6k|578|Updated Aug 6, 2024
One-click install
npx skills add https://github.com/linkedin/Liger-Kernel --skill liger-autopatch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: liger-autopatch
Source: https://github.com/linkedin/Liger-Kernel/tree/main/.claude/skills/liger-autopatch
Command: npx skills add https://github.com/linkedin/Liger-Kernel --skill liger-autopatch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill streamlines the complex, error-prone work of adding or updating Liger Kernel support for HuggingFace Transformers models by analyzing model code, generating lce_forward implementations and monkey-patch functions, updating tests and README entries, and validating changes with test runs and human checkpoints.

Core Features & Use Cases

  • Model Analysis: Reads modeling_*.py and produces a detailed model profile guided by a 12-question decision matrix to determine norms, MLP types, RoPE variant, MoE structure, and other architecture details.
  • Code Generation: Produces or modifies lce_forward files, monkey_patch registrations, init exports, output classes, convergence test entries, revert helpers, and README patching table entries using templates and reference implementations.
  • Validation Pipeline: Runs instance patching tests, convergence tests, lint/checkstyle, and retry logic with mandatory human checkpoints between Analyze → Generate → Validate stages, supporting both create and modify workflows.
  • Use Cases: Add a new model to Liger Kernel, extend existing kernel mappings, fix instance-level patching bugs, update patches for upstream HF changes, or add new kernels/activations/norm variants.

Quick Start

Run the liger-autopatch pipeline to analyze the target HuggingFace model, generate or modify the lce_forward and monkey-patch code, and validate the changes with instance and convergence tests while reviewing the human checkpoints.

Frequently Asked Questions about liger-autopatch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate Liger Kernel monkey-patching for HuggingFace Transformers models?

You can automate Liger Kernel monkey-patching by running a pipeline that analyzes the target HuggingFace model architecture, generates lce_forward implementations and patch functions, and updates tests. It uses a decision matrix to determine model norms, MLP types, and RoPE variants.

What is the process to add a new HuggingFace model to Liger Kernel?

Adding a new HuggingFace model to Liger Kernel involves analyzing the modeling file, generating lce_forward code and monkey-patch registrations, and updating convergence tests. The workflow requires human checkpoints between the analysis, generation, and validation stages.

How do I fix instance-level patching bugs in Liger Kernel for upstream HuggingFace changes?

To fix instance-level patching bugs or upstream HuggingFace changes, you can use a modify workflow that updates existing lce_forward files and monkey-patch functions. It then runs instance-patching and convergence validations with retry logic to ensure correctness.

Does Liger Kernel patching support different MLP types and RoPE variants in HuggingFace models?

Yes, Liger Kernel patching supports different MLP types, RoPE variants, MoE structures, and norm variants. The model analysis stage reads the modeling code and uses a 12-question decision matrix to identify these specific architecture details before generating patches.

What are the limitations of automating Liger Kernel patches for HuggingFace models?

The automation requires mandatory human checkpoints before code generation and after validation to ensure correctness. While it generates code, updates tests, and runs convergence checks with retry logic, it cannot bypass these manual review stages.

How does the liger-autopatch pipeline validate generated monkey-patches?

The pipeline validates generated monkey-patches by running instance-patching tests, convergence tests, and lint checks. It incorporates retry logic for failures and requires a final human checkpoint after the validation stage completes.