Skip to content

feat(kimi-k3): add expert LoRA and tune full SFT - #3683

Draft
HuiyingLi wants to merge 2 commits into
mainfrom
huiyingl/feat/k3-expert-lora-recipe
Draft

feat(kimi-k3): add expert LoRA and tune full SFT#3683
HuiyingLi wants to merge 2 commits into
mainfrom
huiyingl/feat/k3-expert-lora-recipe

Conversation

@HuiyingLi

@HuiyingLi HuiyingLi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Adds a production-scale Kimi K3 ordinary-LoRA SFT example and updates the existing full-FT SFT recipe to use HybridEP with reshard-after-forward.

Changelog

  • Add examples/llm_finetune/kimi/k3_hellaswag_lora.yaml with PP4/DP32/EP32, HybridEP, torch_mm experts, selective activation checkpointing, and reshard-after-forward.
  • Apply ordinary rank-32 LoRA to all supported linear modules and enable moe_rank_scaling, which gives the 16-active-expert K3 MoE modules rank 2.
  • Save a consolidated safetensors adapter at the final step.
  • Update examples/llm_finetune/kimi/k3_hellaswag.yaml full FT from the torch dispatcher to HybridEP and enable reshard-after-forward.
  • Add focused CPU recipe-contract tests for both the full-FT and expert-LoRA configurations.

Before your PR is "Ready for review"

Pre checks:

  • Read and followed the contributor guidelines.
  • Added the necessary focused tests.
  • Added the runnable example recipe and inline topology documentation.

Validation

  • pytest -q tests/unit_tests/recipes/llm/test_k3_lora_recipe.py (2 passed after the full-FT HybridEP/reshard update)
  • pytest -q tests/unit_tests/recipes/llm/test_k3_lora_recipe.py tests/unit_tests/models/kimi_k3/test_state_dict_adapter.py tests/unit_tests/moe/test_moe_lora_state_dict.py tests/unit_tests/_transformers/test_recipe_doc_coverage.py (39 passed, 3 skipped before the full-FT config-only update)
  • python tests/ci_tests/utils/validate_new_recipe_ci.py examples/llm_finetune/kimi/k3_hellaswag_lora.yaml
  • ruff format .
  • ruff check --fix .
  • Four-GPU, four-layer K3 smoke: two train steps, validation, and consolidated adapter save passed with HybridEP + torch_mm + selective AC + resharding. The adapter contained all routed-expert LoRA tensors at expert rank 2.

Additional Information

Based on main after HybridEP token-count equalization in #3641. K3 expert-LoRA HF adapter key conversion is already covered by #3435. The full-FT HybridEP/reshard update is covered here by a config-contract test; it has not yet been rerun as a separate GPU job in this PR.

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi
HuiyingLi requested a review from a team as a code owner August 26, 2026 03:48
@copy-pr-bot

copy-pr-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@HuiyingLi HuiyingLi changed the title feat(kimi-k3): add expert LoRA SFT recipe feat(kimi-k3): add expert LoRA recipe Aug 26, 2026
akoumpa
akoumpa previously approved these changes Aug 26, 2026
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi HuiyingLi changed the title feat(kimi-k3): add expert LoRA recipe feat(kimi-k3): add expert LoRA and tune full SFT Aug 26, 2026
@HuiyingLi
HuiyingLi marked this pull request as draft August 26, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants