Skip to content

Fix: adding magistral fsdp config, fixing not eval with test_datasets, handle mllama attention#2789

Merged
NanoCode012 merged 4 commits into
mainfrom
fix/prerelease-fix
Jun 14, 2025
Merged

Fix: adding magistral fsdp config, fixing not eval with test_datasets, handle mllama attention#2789
NanoCode012 merged 4 commits into
mainfrom
fix/prerelease-fix

Conversation

@NanoCode012

@NanoCode012 NanoCode012 commented Jun 13, 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

  • New Features

    • Added a new configuration file for fine-tuning the Magistral-Small model with QLoRA and FSDP, including detailed training and optimization settings.
  • Bug Fixes

    • Improved evaluation logic to ensure evaluation is only disabled when both the evaluation dataset is missing and the validation set size is zero.
  • Refactor

    • Enhanced model compatibility by adding support for the "mllama" model type in attention class selection.
  • Documentation

    • Updated cut_cross_entropy integration README with guidance for Vision-Language Model training using a specific older version of Axolotl.

@coderabbitai

coderabbitai Bot commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A new YAML configuration was added for QLoRA fine-tuning with FSDP on the Magistral-Small model. The logic for disabling evaluation in training arguments was changed to require both no evaluation dataset and zero validation set size. The LoRA attention kernel monkeypatch now supports the "mllama" model type. A usage note was added for cut_cross_entropy integration regarding VLM training compatibility.

Changes

File(s) Change Summary
examples/magistral/magistral-small-fsdp-qlora.yaml Added new YAML config for QLoRA fine-tuning Magistral-Small with FSDP and detailed training setup
src/axolotl/core/builders/base.py Changed logic for disabling evaluation: now requires both no eval dataset and zero val set size
src/axolotl/monkeypatch/lora_kernels.py Added support for "mllama" model type in attention class monkeypatch function
src/axolotl/integrations/cut_cross_entropy/README.md Added note advising use of older Axolotl version for VLM training due to upstream refactor

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Config
    participant Trainer
    participant Model

    User->>Config: Provide magistral-small-fsdp-qlora.yaml
    Config->>Trainer: Load training, LoRA, FSDP, and eval params
    Trainer->>Model: Initialize with QLoRA, FSDP, and tokenizer
    Trainer->>Trainer: Check eval dataset and val set size
    Trainer->>Model: Train and evaluate as configured
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure validation loss is calculated and logged when using test_datasets (Issue #2781)
Fix evaluation disabling logic to consider both eval dataset presence and val set size (Issue #2781)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Added new YAML config for Magistral-Small QLoRA fine-tuning (examples/magistral/magistral-small-fsdp-qlora.yaml) Not related to validation loss or evaluation logic from issue #2781
Added support for "mllama" model type in LoRA attention kernel monkeypatch (src/axolotl/monkeypatch/lora_kernels.py) Not related to evaluation or validation loss handling
Added usage note for cut_cross_entropy integration regarding VLM training (src/axolotl/integrations/cut_cross_entropy/README.md) Documentation update unrelated to evaluation loss or validation

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • winglian

Poem

A YAML arrives, so crisp and neat,
For Magistral-Small, a QLoRA treat!
FSDP sharding, configs galore,
Evaluation logic—now less of a chore.
"mllama" joins the LoRA fun,
More models, more joy for everyone!
🐇✨


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 (1)
examples/magistral/magistral-small-fsdp-qlora.yaml (1)

17-18: Floating fraction for val_set_size relies on downstream support

val_set_size: 0.1 is convenient, but not every Axolotl code-path treats floats and ints identically (see change in base.py).
Make sure the dataset-splitting utility you use converts this fraction into an absolute size; otherwise evaluation will be silently skipped.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a3c82e8 and 7a21195.

📒 Files selected for processing (3)
  • examples/magistral/magistral-small-fsdp-qlora.yaml (1 hunks)
  • src/axolotl/core/builders/base.py (1 hunks)
  • src/axolotl/monkeypatch/lora_kernels.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: PyTest (3.11, 2.5.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.5.1)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.1)
🔇 Additional comments (1)
src/axolotl/monkeypatch/lora_kernels.py (1)

148-152:

Details

❓ Verification inconclusive

Verify the new ‘mllama’ special-case import

transformers mainline currently exposes MllamaAttention, not MllamaTextSelfAttention.
If the class name or module path is wrong the patch will raise at import time and break all LoRA kernel initialisation.

Please run a quick check (or pin a compatible transformers commit) before merge.


🏁 Script executed:

#!/bin/bash
# Attempt to import the proposed class – will exit non-zero on failure.
python - <<'PY'
import importlib, sys, traceback
try:
    mod = importlib.import_module("transformers.models.mllama.modeling_mllama")
    getattr(mod, "MllamaTextSelfAttention")
    print("✅  Import succeeded")
except Exception:
    traceback.print_exc()
    sys.exit(1)
PY

Length of output: 1431


Verify the new ‘mllama’ special-case import

The automated import check couldn’t run because the transformers library isn’t installed in this environment. Please confirm in your local setup that:

  • transformers.models.mllama.modeling_mllama.MllamaTextSelfAttention is present in the version(s) you support
  • You’ve pinned or documented a compatible transformers release to avoid breakage at import time

Comment on lines +383 to 385
if not self.eval_dataset and self.cfg.val_set_size == 0:
# do not eval if no eval_dataset and val_set_size=0
training_args_kwargs["eval_strategy"] = "no"

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.

🛠️ Refactor suggestion

⚠️ Potential issue

Condition should use truth-value rather than strict equality

val_set_size can be supplied as None, 0, or 0.0.
Using the strict comparison == 0 means that the “no-eval” shortcut will be skipped when the field is None, even though that represents no validation split just as well.

-        if not self.eval_dataset and self.cfg.val_set_size == 0:
+        # disable evaluation only when BOTH no explicit eval dataset
+        # and the user provided an equivalent “no-split” value
+        if self.eval_dataset is None and not self.cfg.val_set_size:

This guards against None and negative / falsy values in one shot, while still allowing fractions such as 0.1.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if not self.eval_dataset and self.cfg.val_set_size == 0:
# do not eval if no eval_dataset and val_set_size=0
training_args_kwargs["eval_strategy"] = "no"
# disable evaluation only when BOTH no explicit eval dataset
# and the user provided an equivalent “no-split” value
if self.eval_dataset is None and not self.cfg.val_set_size:
# do not eval if no eval_dataset and val_set_size=0
training_args_kwargs["eval_strategy"] = "no"
🤖 Prompt for AI Agents
In src/axolotl/core/builders/base.py around lines 383 to 385, replace the strict
equality check 'self.cfg.val_set_size == 0' with a truth-value check like 'not
self.cfg.val_set_size' to correctly handle cases where val_set_size is None, 0,
or 0.0. This change ensures the "no-eval" shortcut triggers appropriately for
all falsy values representing no validation split, while still allowing
fractional values such as 0.1.

@codecov

codecov Bot commented Jun 13, 2025

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/axolotl/monkeypatch/lora_kernels.py 33.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@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/integrations/cut_cross_entropy/README.md (2)

27-27: Grammar: add missing article "an" for clarity
The sentence reads:

NOTE: If you are training a VLM model, please use older version of Axolotl...
It would be clearer as:
NOTE: If you are training a VLM model, please use an older version of Axolotl...

🧰 Tools
🪛 LanguageTool

[uncategorized] ~27-~27: Possible missing article found.
Context: ...ou are training a VLM model, please use older version of Axolotl as upstream has appl...

(AI_HYDRA_LEO_MISSING_AN)


29-33: Clarify context for repository commands
The git checkout and pip3 install steps assume the user is in the Axolotl repo root. Consider adding a note, for example:

+Run these commands from the root of the Axolotl repository:
 ```bash
 git checkout 787880215b3ab32ccaf81c1b2e9588c6f3e6e764
 pip3 install --no-build-isolation -e .

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 7a21195f455b31d5d3e29515a1c929940fc159d3 and 5df2688355b2a7d076b0caf308082b760dad32b9.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `src/axolotl/integrations/cut_cross_entropy/README.md` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>src/axolotl/integrations/cut_cross_entropy/README.md</summary>

[uncategorized] ~27-~27: Possible missing article found.
Context: ...ou are training a VLM model, please use older version of Axolotl as upstream has appl...

(AI_HYDRA_LEO_MISSING_AN)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (9)</summary>

* GitHub Check: PyTest (3.11, 2.6.0)
* GitHub Check: pre-commit
* GitHub Check: PyTest (3.11, 2.7.1)
* GitHub Check: PyTest from Source Dist (3.11, 2.5.1)
* GitHub Check: PyTest (3.11, 2.5.1)
* GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
* GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
* GitHub Check: pre-commit
* GitHub Check: preview

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot temporarily deployed to preview June 13, 2025 20:11 Inactive
@NanoCode012 NanoCode012 requested a review from winglian June 13, 2025 22:56
@NanoCode012 NanoCode012 merged commit 80d5b06 into main Jun 14, 2025
18 of 19 checks passed
@NanoCode012 NanoCode012 deleted the fix/prerelease-fix branch June 14, 2025 18:53
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.

No validation loss is calculated when using test_datasets

2 participants