Add optional Liger kernels for DFlash training#824
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughChangesThe DFlash model now supports optional Liger RMSNorm and MLP kernels through a new dependency extra, kernel factories, CLI selection, model-construction propagation, and unit-test coverage. DFlash Liger kernel integration
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/models/test_dflash_liger.py`:
- Around line 57-70: Rename the shadowing globals and locals parameters in the
missing_liger __import__ mock within
test_missing_liger_extra_has_actionable_error to non-builtin names, and update
the positional call accordingly without changing the mock’s behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7bd68d0e-29be-4de4-b284-640a97740a38
📒 Files selected for processing (8)
pyproject.tomlscripts/train.pysrc/speculators/models/dflash/core.pysrc/speculators/models/dflash/kernels.pysrc/speculators/models/dflash/model_definitions.pytests/unit/models/test_dflash_liger.pytests/unit/train/test_cli_args.pytests/unit/train/test_draft_config_init.py
speculatorsbot
left a comment
There was a problem hiding this comment.
Clean integration -- the factory-based kernel injection via DFlashKernels avoids the global monkey-patching that Liger's apply_liger_kernel_to_* helpers typically use, preserving instance isolation and checkpoint compatibility. All three initialization paths (from-scratch, config-only, pretrained) are wired and tested. Lazy import keeps liger-kernel truly optional.
One process note: per CONTRIBUTING.md, changes adding CLI/API surface and touching 3+ files should reference an assigned issue.
LGTM with one non-blocking item below. Recommend approving.
🤖 Generated with Claude Code using the /pr-review skill
| parser.add_argument( | ||
| "--use-liger-kernel", | ||
| action="store_true", | ||
| help=( | ||
| "Use Liger Qwen3 RMSNorm/SwiGLU kernels for DFlash. Requires " | ||
| "the optional `speculators[liger]` extra." | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Non-blocking: docs/cli/train.md comprehensively documents all training flags. --use-liger-kernel should be added there (Model Arguments section, near --speculator-type), along with a note about the speculators[liger] optional dependency.
There was a problem hiding this comment.
Documented under DFlash-specific arguments, including the optional dependency.
WindChimeRan
left a comment
There was a problem hiding this comment.
Please benchmark the performance gain on this.
fe4fb87 to
1193a43
Compare
Add --use-liger-kernel for DFlash training. Resolve Liger Qwen3 RMSNorm/SwiGLU modules lazily and inject them through per-model factories, leaving the native path unchanged by default. Cover CLI scope, initialization paths, instance isolation, and checkpoint compatibility. Signed-off-by: jessiewei7 <jessiewei747@gmail.com>
1193a43 to
b3529db
Compare
Merge Protections🔴 1 of 1 protections blocking · waiting on 👀 reviews
🔴 Require approval from approved reviewers listWaiting for any of
This rule is failing.All pull requests must have at least one approving review from a member of the approved reviewers list before merging.
|
|
This pull request has merge conflicts that must be resolved before it can be |
Summary
Adds
--use-liger-kernelfor DFlash training to opt into Liger's fusedQwen3 RMSNorm and SwiGLU kernels.
The kernels are resolved lazily and injected through per-model DFlash
factories. This keeps the default path native, avoids global Transformers
class changes, and does not depend on import order. The flag is limited to
--speculator-type dflashand is provided throughspeculators[liger].Validation