Skip to content

feat: add performance.yaml example and enable gradient_checkpointing in borealis_1b (issue #6 items 6-7) - #22

Merged
marksverdhei merged 1 commit into
marksverdhei:mainfrom
hai-pilgrim:feat/performance-example
Mar 29, 2026
Merged

marksverdhei merged 1 commit into
marksverdhei:mainfrom
hai-pilgrim:feat/performance-example

Conversation

@hai-pilgrim

Copy link
Copy Markdown

Summary

Closes parts of #6 (items 6 and 7):

  • New examples/performance.yaml: A single annotated config showcasing all high-impact performance knobs:

    • gradient_checkpointing: true — saves VRAM, enables larger batches
    • optim: "adamw_bnb_8bit" — 8-bit Adam via bitsandbytes, cuts optimizer memory ~75%
    • attn_implementation: "flash_attention_2" — 2-4x attention speedup on long sequences
    • per_device_train_batch_size: 4 + gradient_accumulation_steps: 2 — effective batch 8
    • target_modules: all-linear — targets every linear layer for maximum adapter coverage
    • Each knob has an inline comment explaining the tradeoff
  • examples/borealis_1b.yaml: Enable gradient_checkpointing: true (was false). For a 1B model on 24GB VRAM, the memory savings allow larger batch sizes that more than recover the ~20-30% wall-clock overhead noted in the issue.

Remaining issue #6 items

Item Status
1. Unsloth Done in #14
2. Flash Attention Done (attn_implementation field + examples already used sdpa)
3. Vectorize logit loop Done in #20
4. Batch trajectory generation Done in #17
5. Pre-compute prompt lengths Already cached via _prompt_length_cache
6. Gradient checkpointing defaults This PR
7. 8-bit optimizer This PR (in performance.yaml)
8. Move tokenization to collator Not yet

Test plan

  • All 51 non-benchmark tests pass
  • examples/performance.yaml is valid YAML
  • borealis_1b.yaml now has gradient_checkpointing: true

🤖 Generated with Claude Code

@marksverdhei

Copy link
Copy Markdown
Owner

Review

The performance.yaml example is well-documented and the gradient_checkpointing change in borealis_1b makes sense. Good addition.

Needs rebase: This PR includes the bitsandbytes skip guard that was already merged via #21. Please rebase onto main to drop the duplicate diff — the rest of the PR is clean and ready to merge after that.

…in borealis_1b (issue marksverdhei#6 items 6-7)

Addresses issue marksverdhei#6 items 6 (gradient checkpointing) and 7 (8-bit Adam):

- New `examples/performance.yaml`: demonstrates all high-impact perf
  knobs in one place — gradient_checkpointing, adamw_bnb_8bit,
  flash_attention_2, larger batch with accumulation, and all-linear
  LoRA targets. Includes inline comments explaining each tradeoff.

- `examples/borealis_1b.yaml`: enables gradient_checkpointing (was
  false). For a 1B model on a 24GB GPU the VRAM savings allow batch_size
  to increase, more than recovering the ~20-30% wall-clock overhead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hai-pilgrim
hai-pilgrim force-pushed the feat/performance-example branch from e2ecebc to bfcda9b Compare March 29, 2026 17:48

@marksverdhei marksverdhei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. The performance.yaml example is well-documented with clear comments explaining each knob. The gradient_checkpointing flip in borealis_1b is appropriate for 1B+ models. The bitsandbytes skip guard overlap with #21 resolved cleanly. LGTM.

@marksverdhei
marksverdhei merged commit 7a20b63 into marksverdhei:main Mar 29, 2026
2 checks passed
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