Skip to content

drop old patches and code that are no longer needed#3007

Merged
winglian merged 1 commit into
mainfrom
transformers-4530-drop-patches
Aug 6, 2025
Merged

drop old patches and code that are no longer needed#3007
winglian merged 1 commit into
mainfrom
transformers-4530-drop-patches

Conversation

@winglian

@winglian winglian commented Aug 2, 2025

Copy link
Copy Markdown
Collaborator

Description

Motivation and Context

How has this been tested?

Screenshots (if appropriate)

Types of changes

Social Handles (Optional)

Summary by CodeRabbit

  • Refactor
    • Removed support and configuration options for fused QKV flash attention across all relevant components and documentation.
    • Simplified flash attention patching logic for supported models.
    • Updated validation checks to only consider MLP fusion flags.
  • Documentation
    • Updated configuration documentation to reflect the removal of fused QKV options.
  • Tests
    • Updated test configurations to remove fused QKV flash attention settings.

@coderabbitai

coderabbitai Bot commented Aug 2, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This change set removes all code, configuration options, documentation, and test logic related to the flash_attn_fuse_qkv (fused QKV flash attention) feature across the codebase. Associated methods, classes, configuration fields, and validation logic are deleted or simplified, and references in documentation and test files are eliminated.

Changes

Cohort / File(s) Change Summary
Documentation and Config Cleanup
.runpod/README.md, .runpod/src/config/config.yaml, examples/archived/stablelm-2/1.6b/fft.yml, examples/llama-2/fft_optimized.yml, examples/llama-2/lisa.yml
Removed the flash_attn_fuse_qkv configuration option and its documentation from config files and example YAMLs.
Schema and Validation Refactor
src/axolotl/utils/schemas/config.py, src/axolotl/utils/schemas/validation.py
Deleted the flash_attn_fuse_qkv field from the config schema and updated validation logic to only consider flash_attn_fuse_mlp for fused module checks.
Llama Flash Attention Patch Simplification
src/axolotl/loaders/patch_manager.py, src/axolotl/monkeypatch/llama_attn_hijack_flash.py
Removed all fused QKV and packed sequence logic from llama flash attention patching. Deleted related classes, functions, and method parameters.
Mistral Flash Attention Patch Removal
src/axolotl/monkeypatch/mistral_attn_hijack_flash.py
Entirely removed flash attention monkey patching for Mistral, including all related functions, classes, and helpers.
Test Update
tests/e2e/patched/test_fused_llama.py
Removed the flash_attn_fuse_qkv key from the test configuration dictionary.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Suggested labels

ready to merge

Suggested reviewers

  • djsaunde
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch transformers-4530-drop-patches

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 generate unit tests to generate unit tests for 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: 0

🧹 Nitpick comments (2)
src/axolotl/utils/schemas/validation.py (2)

594-595: Update error message to reflect single module check

Since the validation now only checks for flash_attn_fuse_mlp, consider updating the error message to be more specific:

-            raise ValueError("Fused modules are not supported with LoRA/QLoRA")
+            raise ValueError("Fused MLP module is not supported with LoRA/QLoRA")

1183-1184: Update error message for consistency

Similar to the previous comment, update this error message to be more specific:

-                raise ValueError("Fused modules are not supported with ReLoRA")
+                raise ValueError("Fused MLP module is not supported with ReLoRA")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5639552 and 2cd6874.

📒 Files selected for processing (11)
  • .runpod/README.md (0 hunks)
  • .runpod/src/config/config.yaml (0 hunks)
  • examples/archived/stablelm-2/1.6b/fft.yml (0 hunks)
  • examples/llama-2/fft_optimized.yml (0 hunks)
  • examples/llama-2/lisa.yml (0 hunks)
  • src/axolotl/loaders/patch_manager.py (2 hunks)
  • src/axolotl/monkeypatch/llama_attn_hijack_flash.py (1 hunks)
  • src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (0 hunks)
  • src/axolotl/utils/schemas/config.py (0 hunks)
  • src/axolotl/utils/schemas/validation.py (2 hunks)
  • tests/e2e/patched/test_fused_llama.py (0 hunks)
💤 Files with no reviewable changes (8)
  • examples/archived/stablelm-2/1.6b/fft.yml
  • examples/llama-2/lisa.yml
  • examples/llama-2/fft_optimized.yml
  • .runpod/README.md
  • tests/e2e/patched/test_fused_llama.py
  • .runpod/src/config/config.yaml
  • src/axolotl/utils/schemas/config.py
  • src/axolotl/monkeypatch/mistral_attn_hijack_flash.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). (9)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: pre-commit
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: pre-commit
  • GitHub Check: preview
🔇 Additional comments (3)
src/axolotl/loaders/patch_manager.py (2)

333-350: LGTM!

The simplification of _patch_llama_flash_attention method correctly removes the packed parameter and related logic while preserving the shifted-sparse attention and standard flash attention paths.


403-405: Fix reference to removed configuration option

The condition on line 403 still references self.cfg.flash_attn_fuse_qkv which has been removed from the configuration schema. This should be updated to only check flash_attn_fuse_mlp:

-            if self.cfg.flash_attn_fuse_mlp and is_xformers_swiglu_available():
+            if self.cfg.flash_attn_fuse_mlp and is_xformers_swiglu_available():

Wait, I notice the condition already checks flash_attn_fuse_mlp. However, based on the AI summary mentioning that "code that conditionally patched with fused QKV attention was removed entirely", this entire conditional block for MLP fusion should have been preserved. Let me verify if this is the intended behavior.

src/axolotl/monkeypatch/llama_attn_hijack_flash.py (1)

118-138: Clean simplification of flash attention patching

The removal of packed sequence handling and fused QKV support has resulted in a much cleaner implementation that focuses on the core flash attention functionality with optional shifted-sparse attention, cross entropy, and RMS norm optimizations.

@github-actions

github-actions Bot commented Aug 2, 2025

Copy link
Copy Markdown
Contributor

📖 Documentation Preview: https://688e286b3a184849f54b0791--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit 2cd6874

@codecov

codecov Bot commented Aug 2, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@NanoCode012 NanoCode012 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changes look fine. CI fail from train loss being high which is not related to this.

@winglian winglian merged commit 97e86c6 into main Aug 6, 2025
16 of 17 checks passed
@winglian winglian deleted the transformers-4530-drop-patches branch August 6, 2025 12:02
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