Skip to content

bioreason: default GRPO LoRA to q_proj/v_proj and add a target lister - #11

Open
balajiadarsha wants to merge 3 commits into
mainfrom
bioreason-yaml-lora-targets
Open

balajiadarsha wants to merge 3 commits into
mainfrom
bioreason-yaml-lora-targets

Conversation

@balajiadarsha

Copy link
Copy Markdown
Contributor

Description

Follow-up to #9, which makes training.lora_target_modules take effect. This branch is built on #9's latest commit (5c9e8c2), so merge #9 first. Until then the diff below also shows #9's changes. The only new commit is the last one. Independent of #10; they touch different files.

  1. GRPO adapts only q_proj and v_proj by default. bioreason_grpo.yaml now ships lora_target_modules: [q_proj, v_proj]. On OLMo-1B that is 32 of 112 linear layers (0.164% of backbone params trainable instead of 0.933%).
  2. SFT declares the key as null, keeping its behavior (every nn.Linear except lm_head). With the key declared in both YAMLs, training.lora_target_modules=[...] overrides it without Hydra's + prefix; before, no YAML declared it and the plain override failed in struct mode.
  3. tools/list_lora_targets.py lists the leaf names that can be targeted for any model, with layer counts. It builds the backbone on the meta device (only config.json is read, no weights) and uses the trainer's own _select_lora_targets, so its list matches what training accepts:
    $ python tools/list_lora_targets.py model=prism_olmo_1b
    Backbone: allenai/OLMo-1B-0724-hf
    LoRA-targetable nn.Linear leaf names (excluded: ['lm_head']):
      down_proj                  16 layers
      gate_proj                  16 layers
      k_proj                     16 layers
      o_proj                     16 layers
      q_proj                     16 layers
      up_proj                    16 layers
      v_proj                     16 layers
      total                     112 layers
    
    --backbone-id <HF id or path> skips Hydra. Both YAMLs and the notebook (section 9b) point to it.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation update
  • Infrastructure, CI, or tooling

Compatibility

  • src.* import paths
  • the prism CLI surface
  • Hydra config keys
  • checkpoint keys
  • launcher flags
  • None of the above

training.lora_target_modules is now declared in bioreason_grpo.yaml and bioreason_sft.yaml. BioReason GRPO results change: new GRPO runs adapt q/v only, so they are not directly comparable with earlier all-layer GRPO runs. Pass training.lora_target_modules=null to get the old behavior.

How Has This Been Tested?

Aurora login node, CPU only:

pytest tests/test_bioreason_lora_targets_config.py tests/test_lora_target_modules.py \
       tests/test_train_coerce.py tests/test_isoflop_plan.py      # 53 passed, 3 skipped (torchtune)
ruff check src tests tools scripts applications examples        # ruff 0.16.9: all checks passed
python tools/list_lora_targets.py model=prism_olmo_1b           # 112 layers, 7 names (above)
python tools/list_lora_targets.py                               # OLMo-7B-0724: 224 layers
python tools/list_lora_targets.py --backbone-id Qwen/Qwen3-0.6B # 196 layers

New tests (no torchtune needed, so they run in CI): the shipped defaults for both YAMLs, the plain override without + (list and null) giving a real list, and the tool's name counting.

End-to-end: GRPO with [q_proj, v_proj] was already run on Aurora when testing #9 (passed: 32 layers adapted, adapter saved and merged at eval). Aurora runs of this branch's defaults are in progress and will be reported here.

New Dependencies, Data, or Assets

None.

Checklist

  • I have performed a self-review of my own changes
  • The code follows the project's style guidelines (ruff check, ruff 0.16.9 per requirements/ci.txt)
  • I have commented my code where the intent is not obvious
  • I have made corresponding changes to the documentation
  • I have added tests that cover this change, or explained why none are needed
  • New and existing tests pass locally
  • No secrets, credentials, or absolute institutional paths are included

AI/LLM Assistance

  • AI/LLM tools were primarily used to generate code or artifacts in this PR
  • I have reviewed all such output line-by-line and understand it

Written with Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

jenny-luo-0727 and others added 3 commits October 14, 2026 12:00
training.lora_target_modules was written to the adapter sidecar but never
passed to apply_lora_torchtune, so every nn.Linear except lm_head was
adapted regardless of the setting. Setting it via Hydra also crashed
save_lora_adapter, because json cannot serialize an OmegaConf ListConfig.

apply_lora_torchtune now takes target_modules (leaf names, matched like
exclude) and raises on a name that matches no layer, an empty list, or a
bare string. ZoneATrainer and ZoneDTrainer pass the config value through.
With target_modules unset the result is unchanged (state dict bit-identical
on a seeded toy backbone).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmpnEoNqJpQjR59ie7ZMek
Review follow-ups on #9.

- Move layer selection and the target_modules name checks out of
  apply_lora_torchtune into _select_lora_targets, which needs no torchtune.
  The selection and bad-name tests now run in CI (which does not install
  torchtune); only the LoRALinear and sidecar tests still skip without it.
- Convert lora_target_modules from an OmegaConf ListConfig to a plain list
  in build_training_config, so the config the trainers dump into
  training_state.json records a list rather than its string form. A bare
  string passes through unchanged, so apply_lora_torchtune still rejects it.
- Update the BioReason demo notebook, which still described
  lora_target_modules as metadata only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bioreason_grpo.yaml now ships lora_target_modules: [q_proj, v_proj], so
GRPO adapts only the attention query/value projections (OLMo-1B: 32 of
112 layers) instead of every nn.Linear. bioreason_sft.yaml declares the
key as null, keeping SFT's behavior. Declaring it in both lets
training.lora_target_modules=[...] be overridden without Hydra's "+".

tools/list_lora_targets.py prints the leaf names that can be targeted
for any model, with layer counts. It builds the backbone on the meta
device (config.json only, no weights) and uses the trainer's own
_select_lora_targets. Both YAMLs and the notebook point to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@balajiadarsha
balajiadarsha requested a review from a team as a code owner October 15, 2026 20:52
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.

3 participants