Skip to content

cookbook(finetune): document how to enable LoRA in the SFT recipes - #303

Draft
lfengad wants to merge 1 commit into
mainfrom
liangf/cookbook-lora-guide
Draft

cookbook(finetune): document how to enable LoRA in the SFT recipes#303
lfengad wants to merge 1 commit into
mainfrom
liangf/cookbook-lora-guide

Conversation

@lfengad

@lfengad lfengad commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a LoRA fine-tuning section to both finetune cookbook READMEs:

Both cookbooks already ship LoRA-capable recipes, but neither explains how to turn LoRA on — today you'd have to reverse it out of the framework's TOML schema.

Approach

Written as a guide, not a second set of recipes. No new TOML or launch shell is added; the section explains how to convert an existing recipe:

  • which TOML sections to touch, what each knob does, and why
  • concrete numbers appear only as examples to start from (rank/alpha with tuning direction), and the LR is framed as "take the recipe's full-FT value and go up"
  • only the mechanically required bits stay prescriptive (lora_enabled, keys_to_select = ["lora_"], keys_to_skip_loading, EMA/compile, and the Edge lora_exclude_path_regex) — getting these wrong fails silently rather than loudly

launch_sft_vision_super.sh is surfaced in both READMEs as the ready-made LoRA recipe to read alongside: directly in the generator cookbook, and by relative link from the reasoner one as the vfm-side reference for the same mechanism.

vfm vs vlm

The mechanism is identical; four things differ, and each README covers its own side:

vision (vfm) reasoner (vlm)
lora_target_modules q/k/v/o_proj_moe_gen q/k/v/o_proj
lora_exclude_path_regex n/a required on Cosmos3-Edge (SigLIP2 tower shares projection names with the LLM)
checkpoint.keys_to_skip_loading add "lora_" stays [] (HF safetensors, not DCP)
EMA / torch.compile on in these recipes, must be disabled already false

Merge order

The reasoner section depends on VLM LoRA support landing in cosmos-framework (liangf/vlm-lora-sft) — on today's main, PATH_REMAPS["vlm"] still skips the lora_* keys. Filed as draft for that reason; the generator section is accurate against the released framework as-is.

Verification

Every claim was checked against the corresponding TOMLs, the framework source, or actual runs — including one fix caught during review: extending vfm LoRA to the FFN needs path-qualified targets (mlp_moe_gen.up_proj), because a bare up_proj also matches the understanding tower's mlp.up_proj and there is no path-exclusion knob on the vfm side.

🤖 Generated with Claude Code

Both finetune cookbooks ship LoRA-capable recipes but never explain how to
turn LoRA on, so anyone starting from a full fine-tune recipe has to reverse
it out of the framework's TOML schema.

Add a "LoRA fine-tuning" section to each README, written as a guide rather
than a second set of recipes: which TOML sections to touch, what each knob
does, and why. Concrete numbers appear only as examples to start from, with
the learning rate framed as "take the recipe's full-FT value and go up".

The generator section points at launch_sft_vision_super.sh and its TOML as a
ready-made LoRA recipe; the reasoner section links to the same script as the
vfm-side reference for the identical mechanism.

The two sides differ in four places, and each README covers its own:
  * target module names -- q/k/v/o_proj_moe_gen (vfm) vs q/k/v/o_proj (vlm)
  * lora_exclude_path_regex -- vlm only, required on the Cosmos3-Edge
    backbone whose SigLIP2 tower shares projection names with the LLM
  * checkpoint.keys_to_skip_loading -- vfm must add "lora_", vlm stays []
  * EMA / torch.compile -- on in the vfm recipes, already off in the vlm ones

No TOML or launch shell is added; the guide converts the existing ones.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant