Skip to content

Act offload lora fix#2928

Merged
winglian merged 3 commits into
mainfrom
act-offload-lora-fix
Jul 24, 2025
Merged

Act offload lora fix#2928
winglian merged 3 commits into
mainfrom
act-offload-lora-fix

Conversation

@winglian

@winglian winglian commented Jul 16, 2025

Copy link
Copy Markdown
Collaborator

Follow up to #2927 so that CUDA streams for activation offloading now works.

Summary by CodeRabbit

  • New Features

    • Enhanced activation offloading support for parameter-efficient fine-tuning (PEFT) models, including LoRA and QLoRA, for improved training efficiency.
    • Added an end-to-end test suite to verify activation offloading functionality across different adapter configurations.
  • Bug Fixes

    • Improved handling of activation offloading with LoRA adapters to avoid unnecessary offloading of output layers, reducing performance overhead.
  • Documentation

    • Added a new FAQ entry explaining how to address a specific activation offloading error and providing a recommended workaround.
  • Tests

    • Removed outdated tests related to legacy activation offloading logic with LoRA/QLoRA adapters.

@coderabbitai

coderabbitai Bot commented Jul 16, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes introduce specialized activation offloading for PEFT/LoRA models, refine activation offloading context management, simplify schema validation logic by removing special-case handling for LoRA adapters, update documentation with a new FAQ entry, and add end-to-end tests for activation offloading. Several obsolete unit tests are removed.

Changes

File(s) Change Summary
src/axolotl/core/trainers/mixins/activation_checkpointing.py Added LoRA/PEFT-specific activation offloading context manager, selectively disables offloading for output heads and certain modules.
src/axolotl/utils/schemas/validation.py Removed LoRA-specific activation offloading validation logic; now uses a unified warning and unconditional setting.
docs/faq.qmd Added FAQ entry explaining a specific activation offloading error and workaround.
tests/e2e/test_activation_offloading.py Added end-to-end test suite for activation offloading with LoRA, QLoRA, and no adapter.
tests/utils/schemas/validation/test_activation_offloading.py Removed unit tests for legacy LoRA/QLoRA activation offloading validation logic.

Estimated code review effort

3 (~45 minutes)

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • NanoCode012
  • SalmanMohammadi
  • djsaunde

Poem

In the meadow of code, the rabbits hop,
Offloading activations, they never stop.
LoRA and QLoRA, now handled with care,
Output heads spared, no burdens to bear.
With tests and docs fresh as morning dew,
This patch is a treat—hippity-hooray for you! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb0db6b and 0225747.

📒 Files selected for processing (5)
  • docs/faq.qmd (1 hunks)
  • src/axolotl/core/trainers/mixins/activation_checkpointing.py (3 hunks)
  • src/axolotl/utils/schemas/validation.py (1 hunks)
  • tests/e2e/test_activation_offloading.py (1 hunks)
  • tests/utils/schemas/validation/test_activation_offloading.py (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/utils/schemas/validation/test_activation_offloading.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/faq.qmd
  • tests/e2e/test_activation_offloading.py
  • src/axolotl/utils/schemas/validation.py
  • src/axolotl/core/trainers/mixins/activation_checkpointing.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: docker-e2e-tests-1st (126, 12.6.3, 3.11, 2.6.0, 1, Dockerfile-uv.jinja)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/e2e/test_activation_offloading.py (1)

46-46: Consider reducing the dataset split size for faster tests.

Using 10% of the dataset might be excessive for a test that only runs 2 steps. Consider reducing to 1% or using a fixed small number of examples.

-                        "split": "train[:10%]",
+                        "split": "train[:1%]",
src/axolotl/core/trainers/mixins/activation_checkpointing.py (1)

120-193: Comprehensive output head detection with room for extensibility.

The heuristic detection covers common output head patterns. However, consider documenting how users can extend this for custom model architectures.

Consider exposing a configuration option or hook mechanism for users to specify custom output head module names for non-standard model architectures.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36cbe13 and eb0db6b.

📒 Files selected for processing (5)
  • docs/faq.qmd (1 hunks)
  • src/axolotl/core/trainers/mixins/activation_checkpointing.py (3 hunks)
  • src/axolotl/utils/schemas/validation.py (1 hunks)
  • tests/e2e/test_activation_offloading.py (1 hunks)
  • tests/utils/schemas/validation/test_activation_offloading.py (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/utils/schemas/validation/test_activation_offloading.py
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/e2e/test_activation_offloading.py (4)
src/axolotl/utils/config/__init__.py (1)
  • validate_config (261-305)
src/axolotl/utils/dict.py (1)
  • DictDefault (6-38)
tests/e2e/utils.py (1)
  • check_model_output_exists (162-183)
tests/utils/schemas/validation/test_activation_offloading.py (1)
  • TestActivationOffloading (7-35)
src/axolotl/core/trainers/mixins/activation_checkpointing.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (42-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: pre-commit
  • GitHub Check: pre-commit
  • GitHub Check: preview
🔇 Additional comments (10)
docs/faq.qmd (1)

140-142: LGTM! Clear and helpful FAQ entry.

The documentation provides a practical workaround for users encountering edge cases with the new activation offloading implementation.

src/axolotl/utils/schemas/validation.py (1)

1076-1079: Good simplification aligned with the new LoRA-aware activation offloading.

The removal of special-case handling for LoRA adapters is appropriate since the new implementation in activation_checkpointing.py now handles PEFT/LoRA models with a specialized context manager.

tests/e2e/test_activation_offloading.py (2)

17-20: Well-structured test class for activation offloading.

Good approach to test activation offloading across different adapter configurations.


22-26: Good parameterization coverage.

Testing with lora, qlora, and no adapter ensures the new activation offloading logic works correctly across all supported configurations.

src/axolotl/core/trainers/mixins/activation_checkpointing.py (6)

7-23: Appropriate imports for PEFT support.

The new imports properly support the specialized activation offloading for PEFT/LoRA models.


33-40: Clean implementation of PEFT-specific activation offloading.

The conditional logic correctly identifies PEFT models and applies the specialized context manager, ensuring proper handling of LoRA wrapped models.


54-94: Well-documented function with comprehensive parameters.

The function signature and documentation clearly explain the purpose and parameters, making it easy for future maintainers to understand the activation offloading behavior for LoRA models.


110-118: Good model unwrapping logic.

The code properly handles different wrapper types including PEFT models, ensuring the base model is accessible for output head detection.


194-200: Helpful warning message for debugging.

The warning provides clear guidance when no output head is detected, helping users understand potential performance implications.


202-216: Smart handling of Liger modules and checkpoint-wrapped modules.

The logic correctly identifies and excludes modules that shouldn't be offloaded, ensuring compatibility with LoRA training.

Comment thread src/axolotl/core/trainers/mixins/activation_checkpointing.py
@github-actions

github-actions Bot commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

📖 Documentation Preview: https://687f779976a8840c25274406--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit 0225747

@codecov

codecov Bot commented Jul 16, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 50.00000% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...l/core/trainers/mixins/activation_checkpointing.py 48.27% 30 Missing ⚠️

📢 Thoughts on this report? Let us know!

@winglian winglian force-pushed the act-offload-lora-fix branch from eb0db6b to 0225747 Compare July 22, 2025 11:30
@winglian winglian merged commit 0ff2f17 into main Jul 24, 2025
26 of 28 checks passed
@winglian winglian deleted the act-offload-lora-fix branch July 24, 2025 20:10
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