Skip to content

checkpoint model on first step callback#2906

Merged
djsaunde merged 7 commits into
mainfrom
checkpoint-on-step-1
Jul 15, 2025
Merged

checkpoint model on first step callback#2906
djsaunde merged 7 commits into
mainfrom
checkpoint-on-step-1

Conversation

@djsaunde
Copy link
Copy Markdown
Collaborator

@djsaunde djsaunde commented Jul 11, 2025

Description

Title. This is a good sanity check and ensures users don't waste a long time training, only for their model checkpoint to fail at the end of their run.

Note that we default the value for the config save_first_step to True. It's up for debate as to whether this is a good default.

  • Pros: Strong sanity check, large time savings in the end for broken config combos
  • Cons: Wastes a bit of time at the start of training

Motivation and Context

As reported on our discord, some user runs end with errors on the final model checkpoint. This should limit the amount of frustration in these cases by failing faster.

How has this been tested?

Manually with a few configs.

Screenshots (if appropriate)

Types of changes

Social Handles (Optional)

Summary by CodeRabbit

  • New Features

    • Added an optional configuration to control saving a model checkpoint after the first training step.
    • Introduced a callback to enable saving the model at the first step when configured.
    • Updated example configurations with commented hints for enabling first-step checkpoint saving.
  • Tests

    • Added end-to-end tests verifying the "save first step" checkpoint behavior.
    • Updated numerous existing tests to include the new configuration parameter.

@djsaunde djsaunde requested review from NanoCode012 and winglian July 11, 2025 20:23
@djsaunde djsaunde self-assigned this Jul 11, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 11, 2025

Walkthrough

A new configuration option, save_first_step, was added to control whether a model checkpoint is saved after the first training step. This involved introducing a new callback, updating configuration schemas, modifying the callback builder logic, and adding or updating tests to validate the correct behavior of this feature.

Changes

File(s) Change Summary
src/axolotl/core/builders/base.py Added logic to include SaveModelOnFirstStepCallback in callbacks if save_first_step is true.
src/axolotl/utils/callbacks/init.py Added SaveModelOnFirstStepCallback; updated type annotations; minor cleanup in existing callbacks.
src/axolotl/utils/schemas/config.py Added save_first_step boolean field (default None, treated as False) to the configuration schema.
tests/e2e/test_save_first_step.py New test module: adds tests for the save_first_step callback feature.
tests/e2e/integrations/test_.py
tests/e2e/multigpu/**/
.py
tests/e2e/patched//*.py
tests/e2e/solo/
/.py
tests/e2e/test_
.py
Added "save_first_step": False to test configurations to explicitly control checkpointing behavior.
examples/**/*.yml Added commented-out save_first_step: true lines in many example YAML configs as optional hints for enabling checkpoint saving on first step.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Config
    participant TrainerBuilder
    participant Callback
    participant Trainer

    User->>Config: Set save_first_step (True/False)
    Config->>TrainerBuilder: Pass configuration
    TrainerBuilder->>Callback: Add SaveModelOnFirstStepCallback if save_first_step is True
    TrainerBuilder->>Trainer: Build with callbacks
    Trainer->>Callback: on_step_end (after step 1)
    Callback->>Trainer: If step==1, set control.should_save=True
    Trainer->>Trainer: Save checkpoint if should_save
Loading

Possibly related PRs

Suggested reviewers

  • SalmanMohammadi
  • winglian

Poem

🐇 A hop and a skip, a checkpoint to keep,
Now models can save after their first leap!
With a flag in the config, the logic is neat—
Callback in place, the feature’s complete.
Tests all around, the code’s in good shape,
A bunny’s delight—no checkpoint escape!
✨🐰


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f3703ea and 8e78f3b.

📒 Files selected for processing (92)
  • examples/cloud/modal.yaml (1 hunks)
  • examples/cohere/command-r-7b-qlora.yml (1 hunks)
  • examples/deepcogito/cogito-v1-preview-llama-3B-lora.yml (1 hunks)
  • examples/deepcogito/cogito-v1-preview-qwen-14B-lora.yml (1 hunks)
  • examples/deepseek-v2/fft-fsdp-16b.yaml (1 hunks)
  • examples/deepseek-v2/qlora-fsdp-2_5.yaml (1 hunks)
  • examples/devstral/devstral-small-qlora.yml (1 hunks)
  • examples/falcon-h1/falcon-h1-1b-deep-qlora.yaml (1 hunks)
  • examples/falcon-h1/falcon-h1-1b-qlora.yaml (1 hunks)
  • examples/falcon-h1/falcon-h1-34b-qlora.yaml (1 hunks)
  • examples/falcon-h1/falcon-h1-3b-qlora.yaml (1 hunks)
  • examples/falcon-h1/falcon-h1-500m-qlora.yaml (1 hunks)
  • examples/falcon-h1/falcon-h1-7b-qlora.yaml (1 hunks)
  • examples/gemma2/qlora.yml (1 hunks)
  • examples/gemma2/reward-model.yaml (1 hunks)
  • examples/gemma3/gemma-3-1b-qlora.yml (1 hunks)
  • examples/gemma3/gemma-3-4b-qlora.yml (1 hunks)
  • examples/gemma3/gemma-3-4b-vision-qlora.yml (1 hunks)
  • examples/glm4/qlora-32b.yaml (1 hunks)
  • examples/jamba/qlora.yaml (1 hunks)
  • examples/jamba/qlora_deepspeed.yaml (1 hunks)
  • examples/jamba/qlora_fsdp_large.yaml (1 hunks)
  • examples/lfm2/lfm2-350m-fft.yaml (1 hunks)
  • examples/llama-2/fft_optimized.yml (1 hunks)
  • examples/llama-2/gptq-lora.yml (1 hunks)
  • examples/llama-2/lisa.yml (1 hunks)
  • examples/llama-2/loftq.yml (1 hunks)
  • examples/llama-2/lora.yml (1 hunks)
  • examples/llama-2/qlora-fsdp.yml (1 hunks)
  • examples/llama-2/qlora.yml (1 hunks)
  • examples/llama-2/relora.yml (1 hunks)
  • examples/llama-3-vision/lora-11b.yaml (1 hunks)
  • examples/llama-3/3b-qat-fsdp2.yaml (1 hunks)
  • examples/llama-3/fft-8b-liger-fsdp.yaml (1 hunks)
  • examples/llama-3/fft-8b.yaml (1 hunks)
  • examples/llama-3/instruct-dpo-lora-8b.yml (1 hunks)
  • examples/llama-3/instruct-lora-8b.yml (1 hunks)
  • examples/llama-3/lora-1b-deduplicate-dpo.yml (1 hunks)
  • examples/llama-3/lora-1b-deduplicate-sft.yml (1 hunks)
  • examples/llama-3/lora-1b-kernels.yml (1 hunks)
  • examples/llama-3/lora-1b-ray.yml (1 hunks)
  • examples/llama-3/lora-1b-sample-packing-sequentially.yml (1 hunks)
  • examples/llama-3/lora-1b.yml (1 hunks)
  • examples/llama-3/lora-8b.yml (1 hunks)
  • examples/llama-3/qlora-1b-kto.yaml (1 hunks)
  • examples/llama-3/qlora-1b.yml (1 hunks)
  • examples/llama-3/qlora-fsdp-405b.yaml (1 hunks)
  • examples/llama-3/qlora-fsdp-70b.yaml (1 hunks)
  • examples/llama-3/qlora.yml (1 hunks)
  • examples/llama-3/sparse-finetuning.yaml (1 hunks)
  • examples/llama-4/do-no-use-fa2/maverick-qlora-fsdp1.yaml (1 hunks)
  • examples/llama-4/do-no-use-fa2/scout-qlora-fsdp1.yaml (1 hunks)
  • examples/llama-4/do-no-use-fa2/scout-qlora-single-h100.yaml (1 hunks)
  • examples/llama-4/do-no-use-fa2/scout-vision-qlora-fsdp.yaml (1 hunks)
  • examples/llama-4/scout-qlora-flexattn-fsdp2.yaml (1 hunks)
  • examples/llama-4/scout-qlora-single-h100-flex.yaml (1 hunks)
  • examples/llama-4/scout-vision-qlora-fsdp2-flex.yaml (1 hunks)
  • examples/llava/lora-7b.yaml (1 hunks)
  • examples/magistral/magistral-small-fsdp-qlora.yaml (1 hunks)
  • examples/magistral/magistral-small-qlora.yaml (1 hunks)
  • examples/mamba/config.yml (1 hunks)
  • examples/mistral/bigstral-ds-zero3.yaml (1 hunks)
  • examples/mistral/config.yml (1 hunks)
  • examples/mistral/lora-mps.yml (1 hunks)
  • examples/mistral/lora.yml (1 hunks)
  • examples/mistral/mistral-dpo-qlora.yml (1 hunks)
  • examples/mistral/mistral-qlora-fsdp.yml (1 hunks)
  • examples/mistral/mistral-qlora-orpo.yml (1 hunks)
  • examples/mistral/mistral-small-3.1-24B-lora.yml (1 hunks)
  • examples/mistral/mixtral-8x22b-qlora-fsdp.yml (1 hunks)
  • examples/mistral/mixtral-qlora-fsdp.yml (1 hunks)
  • examples/mistral/mixtral.yml (1 hunks)
  • examples/mistral/mixtral_22.yml (1 hunks)
  • examples/mistral/qlora.yml (1 hunks)
  • examples/orpheus/finetune.yml (1 hunks)
  • examples/phi/lora-3.5.yaml (1 hunks)
  • examples/phi/phi-ft.yml (1 hunks)
  • examples/phi/phi-qlora.yml (1 hunks)
  • examples/phi/phi2-ft.yml (1 hunks)
  • examples/phi/phi3-ft-fsdp.yml (1 hunks)
  • examples/phi/phi3-ft.yml (1 hunks)
  • examples/pixtral/lora-12b.yml (1 hunks)
  • examples/qwen2-vl/lora-7b.yaml (1 hunks)
  • examples/qwen2/dpo.yaml (1 hunks)
  • examples/qwen2/prm.yaml (1 hunks)
  • examples/qwen2/qlora-fsdp.yaml (1 hunks)
  • examples/qwen2/reward-model.yaml (1 hunks)
  • examples/qwen2_5-vl/lora-7b.yaml (1 hunks)
  • examples/qwen3/32b-qlora.yaml (1 hunks)
  • examples/qwen3/8b-qat-fsdp2.yml (1 hunks)
  • examples/qwen3/qlora-fsdp.yaml (1 hunks)
  • src/axolotl/utils/schemas/config.py (2 hunks)
✅ Files skipped from review due to trivial changes (91)
  • examples/llama-3/sparse-finetuning.yaml
  • examples/gemma3/gemma-3-4b-vision-qlora.yml
  • examples/llama-3/fft-8b-liger-fsdp.yaml
  • examples/llama-3/lora-1b-ray.yml
  • examples/llama-3/fft-8b.yaml
  • examples/llama-3/qlora-1b.yml
  • examples/llama-3/lora-1b.yml
  • examples/llama-2/relora.yml
  • examples/llama-4/scout-vision-qlora-fsdp2-flex.yaml
  • examples/mistral/mistral-small-3.1-24B-lora.yml
  • examples/qwen3/32b-qlora.yaml
  • examples/llama-4/do-no-use-fa2/scout-qlora-single-h100.yaml
  • examples/llama-2/lora.yml
  • examples/llama-3/qlora-1b-kto.yaml
  • examples/llama-4/do-no-use-fa2/scout-vision-qlora-fsdp.yaml
  • examples/falcon-h1/falcon-h1-500m-qlora.yaml
  • examples/qwen2/prm.yaml
  • examples/cloud/modal.yaml
  • examples/gemma3/gemma-3-1b-qlora.yml
  • examples/llama-4/do-no-use-fa2/maverick-qlora-fsdp1.yaml
  • examples/qwen3/8b-qat-fsdp2.yml
  • examples/gemma3/gemma-3-4b-qlora.yml
  • examples/mistral/mistral-qlora-orpo.yml
  • examples/phi/lora-3.5.yaml
  • examples/llama-3/instruct-lora-8b.yml
  • examples/magistral/magistral-small-fsdp-qlora.yaml
  • examples/llama-3/qlora-fsdp-405b.yaml
  • examples/qwen2_5-vl/lora-7b.yaml
  • examples/deepseek-v2/fft-fsdp-16b.yaml
  • examples/falcon-h1/falcon-h1-7b-qlora.yaml
  • examples/qwen2/dpo.yaml
  • examples/phi/phi3-ft.yml
  • examples/devstral/devstral-small-qlora.yml
  • examples/llama-3/qlora-fsdp-70b.yaml
  • examples/qwen3/qlora-fsdp.yaml
  • examples/magistral/magistral-small-qlora.yaml
  • examples/llama-3/lora-1b-sample-packing-sequentially.yml
  • examples/falcon-h1/falcon-h1-3b-qlora.yaml
  • examples/llama-4/do-no-use-fa2/scout-qlora-fsdp1.yaml
  • examples/glm4/qlora-32b.yaml
  • examples/phi/phi-ft.yml
  • examples/llama-4/scout-qlora-single-h100-flex.yaml
  • examples/pixtral/lora-12b.yml
  • examples/mistral/mixtral-qlora-fsdp.yml
  • examples/mistral/mixtral.yml
  • examples/falcon-h1/falcon-h1-1b-deep-qlora.yaml
  • examples/llama-2/fft_optimized.yml
  • examples/llama-2/lisa.yml
  • examples/mistral/lora.yml
  • examples/mistral/config.yml
  • examples/llama-3/lora-1b-deduplicate-dpo.yml
  • examples/llama-3/lora-1b-kernels.yml
  • examples/gemma2/qlora.yml
  • examples/deepcogito/cogito-v1-preview-qwen-14B-lora.yml
  • examples/qwen2/qlora-fsdp.yaml
  • examples/llama-2/loftq.yml
  • examples/llama-3/lora-1b-deduplicate-sft.yml
  • examples/llama-3/lora-8b.yml
  • examples/gemma2/reward-model.yaml
  • examples/llama-2/qlora.yml
  • examples/llava/lora-7b.yaml
  • examples/llama-2/gptq-lora.yml
  • examples/deepcogito/cogito-v1-preview-llama-3B-lora.yml
  • examples/phi/phi3-ft-fsdp.yml
  • examples/llama-2/qlora-fsdp.yml
  • examples/mistral/qlora.yml
  • examples/llama-3/instruct-dpo-lora-8b.yml
  • examples/orpheus/finetune.yml
  • examples/mamba/config.yml
  • examples/jamba/qlora.yaml
  • examples/phi/phi2-ft.yml
  • examples/phi/phi-qlora.yml
  • examples/cohere/command-r-7b-qlora.yml
  • examples/jamba/qlora_fsdp_large.yaml
  • examples/falcon-h1/falcon-h1-1b-qlora.yaml
  • examples/lfm2/lfm2-350m-fft.yaml
  • examples/qwen2-vl/lora-7b.yaml
  • examples/llama-3-vision/lora-11b.yaml
  • examples/jamba/qlora_deepspeed.yaml
  • examples/falcon-h1/falcon-h1-34b-qlora.yaml
  • examples/mistral/mixtral_22.yml
  • examples/mistral/lora-mps.yml
  • examples/mistral/mistral-qlora-fsdp.yml
  • examples/deepseek-v2/qlora-fsdp-2_5.yaml
  • examples/llama-4/scout-qlora-flexattn-fsdp2.yaml
  • examples/llama-3/qlora.yml
  • examples/mistral/mistral-dpo-qlora.yml
  • examples/qwen2/reward-model.yaml
  • examples/mistral/mixtral-8x22b-qlora-fsdp.yml
  • examples/llama-3/3b-qat-fsdp2.yaml
  • examples/mistral/bigstral-ds-zero3.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/axolotl/utils/schemas/config.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). (7)
  • 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.7.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.1, 2, true)
✨ 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.

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.

Copy link
Copy Markdown
Collaborator

@winglian winglian left a comment

Choose a reason for hiding this comment

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

Good to go once prints from testing are removed.

Comment thread src/axolotl/utils/callbacks/__init__.py Outdated
Comment thread src/axolotl/utils/callbacks/__init__.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 03b2a11 and ec41d87.

📒 Files selected for processing (3)
  • src/axolotl/core/builders/base.py (2 hunks)
  • src/axolotl/utils/callbacks/__init__.py (4 hunks)
  • src/axolotl/utils/schemas/config.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/axolotl/core/builders/base.py (1)
src/axolotl/utils/callbacks/__init__.py (1)
  • SaveModelOnFirstStepCallback (143-158)
⏰ 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.6.0)
  • GitHub Check: pre-commit
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • 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 (7)
src/axolotl/utils/schemas/config.py (1)

697-702: LGTM! Configuration field properly implemented.

The new save_first_step field is well-positioned among other checkpoint-related options and includes appropriate documentation. The default value of True aligns with the PR objective to enable early failure detection by default.

src/axolotl/core/builders/base.py (2)

39-39: LGTM! Proper import addition.

The import is correctly added to the existing callback imports.


145-146: LGTM! Callback integration follows established patterns.

The conditional logic properly checks the configuration flag and appends the callback when enabled, following the same pattern as other optional callbacks in the method.

src/axolotl/utils/callbacks/__init__.py (4)

67-67: LGTM! Type annotation improvement.

Adding the return type annotation improves code clarity and type safety.


103-103: LGTM! Type annotation and pylint directive improvement.

The return type annotation and unused argument directive improve code quality.


125-125: LGTM! Type annotation and pylint directive improvement.

The return type annotation and unused argument directive improve code quality.


129-129: LGTM! Type annotation improvement.

Adding the return type annotation improves code clarity and type safety.

Comment thread src/axolotl/utils/callbacks/__init__.py
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 11, 2025

📖 Documentation Preview: https://6876a30c4b8cc53b5b9d7ab3--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit 60428fc

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 11, 2025

Codecov Report

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

Files with missing lines Patch % Lines
src/axolotl/utils/callbacks/__init__.py 40.00% 3 Missing ⚠️
src/axolotl/core/builders/base.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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)
tests/e2e/solo/test_save_first_step.py (2)

1-3: Fix docstring inconsistency.

The docstring mentions "relora llama" but this file is specifically for testing the save_first_step callback feature.

-"""
-E2E tests for relora llama
-"""
+"""
+E2E tests for save_first_step callback
+"""

22-53: Consider reducing code duplication.

Both test methods have nearly identical configurations. Consider extracting the common configuration into a helper method to reduce duplication and improve maintainability.

+    def _get_base_config(self, temp_dir, save_first_step):
+        return DictDefault(
+            {
+                "base_model": "HuggingFaceTB/SmolLM2-135M",
+                "tokenizer_type": "AutoTokenizer",
+                "sequence_len": 512,
+                "val_set_size": 0.02,
+                "special_tokens": {
+                    "pad_token": "<|endoftext|>",
+                },
+                "datasets": [
+                    {
+                        "path": "mhenrichsen/alpaca_2k_test",
+                        "type": "alpaca",
+                    },
+                ],
+                "num_epochs": 1,
+                "max_steps": 3,
+                "micro_batch_size": 2,
+                "gradient_accumulation_steps": 1,
+                "output_dir": temp_dir,
+                "learning_rate": 0.00001,
+                "optimizer": "adamw_bnb_8bit",
+                "lr_scheduler": "cosine",
+                "flash_attention": True,
+                "sample_packing": True,
+                "bf16": True,
+                "save_safetensors": True,
+                "save_first_step": save_first_step,
+            }
+        )

Also applies to: 62-94

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 62a6eb8 and dce2148.

📒 Files selected for processing (53)
  • tests/e2e/integrations/test_cut_cross_entropy.py (2 hunks)
  • tests/e2e/integrations/test_hooks.py (1 hunks)
  • tests/e2e/integrations/test_kd.py (1 hunks)
  • tests/e2e/integrations/test_liger.py (2 hunks)
  • tests/e2e/integrations/test_llm_compressor.py (1 hunks)
  • tests/e2e/multigpu/patched/test_sp.py (1 hunks)
  • tests/e2e/multigpu/solo/test_flex.py (1 hunks)
  • tests/e2e/multigpu/solo/test_grpo.py (3 hunks)
  • tests/e2e/multigpu/test_eval.py (2 hunks)
  • tests/e2e/multigpu/test_gemma3.py (1 hunks)
  • tests/e2e/multigpu/test_llama.py (12 hunks)
  • tests/e2e/multigpu/test_qwen2.py (1 hunks)
  • tests/e2e/multigpu/test_ray.py (2 hunks)
  • tests/e2e/patched/test_4d_multipack_llama.py (2 hunks)
  • tests/e2e/patched/test_activation_checkpointing.py (1 hunks)
  • tests/e2e/patched/test_fa_xentropy.py (1 hunks)
  • tests/e2e/patched/test_falcon_samplepack.py (2 hunks)
  • tests/e2e/patched/test_flattening.py (1 hunks)
  • tests/e2e/patched/test_fused_llama.py (1 hunks)
  • tests/e2e/patched/test_llama_s2_attention.py (2 hunks)
  • tests/e2e/patched/test_lora_llama_multipack.py (2 hunks)
  • tests/e2e/patched/test_mistral_samplepack.py (2 hunks)
  • tests/e2e/patched/test_mixtral_samplepack.py (2 hunks)
  • tests/e2e/patched/test_model_patches.py (2 hunks)
  • tests/e2e/patched/test_peft_embeddings.py (1 hunks)
  • tests/e2e/patched/test_phi_multipack.py (2 hunks)
  • tests/e2e/patched/test_resume.py (1 hunks)
  • tests/e2e/patched/test_sp.py (1 hunks)
  • tests/e2e/patched/test_unsloth_qlora.py (3 hunks)
  • tests/e2e/solo/test_flex.py (1 hunks)
  • tests/e2e/solo/test_relora_llama.py (1 hunks)
  • tests/e2e/solo/test_save_first_step.py (1 hunks)
  • tests/e2e/test_deepseekv3.py (2 hunks)
  • tests/e2e/test_dpo.py (7 hunks)
  • tests/e2e/test_embeddings_lr.py (2 hunks)
  • tests/e2e/test_evaluate.py (1 hunks)
  • tests/e2e/test_falcon.py (3 hunks)
  • tests/e2e/test_gemma3_text.py (2 hunks)
  • tests/e2e/test_llama.py (4 hunks)
  • tests/e2e/test_llama_pretrain.py (1 hunks)
  • tests/e2e/test_llama_vision.py (2 hunks)
  • tests/e2e/test_lora_llama.py (1 hunks)
  • tests/e2e/test_mamba.py (1 hunks)
  • tests/e2e/test_mistral.py (2 hunks)
  • tests/e2e/test_mixtral.py (5 hunks)
  • tests/e2e/test_optimizers.py (5 hunks)
  • tests/e2e/test_packing_loss.py (1 hunks)
  • tests/e2e/test_phi.py (2 hunks)
  • tests/e2e/test_process_reward_model_smollm2.py (1 hunks)
  • tests/e2e/test_qat.py (2 hunks)
  • tests/e2e/test_qwen.py (1 hunks)
  • tests/e2e/test_reward_model_smollm2.py (1 hunks)
  • tests/e2e/test_schedulers.py (1 hunks)
✅ Files skipped from review due to trivial changes (26)
  • tests/e2e/multigpu/solo/test_flex.py
  • tests/e2e/multigpu/test_ray.py
  • tests/e2e/patched/test_phi_multipack.py
  • tests/e2e/patched/test_lora_llama_multipack.py
  • tests/e2e/test_mistral.py
  • tests/e2e/patched/test_sp.py
  • tests/e2e/patched/test_model_patches.py
  • tests/e2e/patched/test_4d_multipack_llama.py
  • tests/e2e/test_schedulers.py
  • tests/e2e/test_qat.py
  • tests/e2e/integrations/test_kd.py
  • tests/e2e/integrations/test_cut_cross_entropy.py
  • tests/e2e/test_falcon.py
  • tests/e2e/test_deepseekv3.py
  • tests/e2e/patched/test_unsloth_qlora.py
  • tests/e2e/test_llama_vision.py
  • tests/e2e/test_dpo.py
  • tests/e2e/multigpu/solo/test_grpo.py
  • tests/e2e/patched/test_llama_s2_attention.py
  • tests/e2e/test_phi.py
  • tests/e2e/test_embeddings_lr.py
  • tests/e2e/test_mixtral.py
  • tests/e2e/test_llama.py
  • tests/e2e/integrations/test_liger.py
  • tests/e2e/test_optimizers.py
  • tests/e2e/multigpu/test_llama.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 (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.1, 2, true)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.6.0, 2, true)
  • GitHub Check: preview
🔇 Additional comments (30)
tests/e2e/test_lora_llama.py (1)

52-52: Configuration addition looks good.

The explicit setting of save_first_step: False appropriately disables the new checkpoint callback during testing, avoiding unnecessary overhead in this short-running test.

tests/e2e/multigpu/test_qwen2.py (1)

75-75: Appropriate configuration for multi-GPU testing.

Setting save_first_step: False is particularly sensible in this multi-GPU FSDP test context, avoiding potential complications with early checkpointing during distributed training.

tests/e2e/patched/test_peft_embeddings.py (1)

52-52: Good integration with PEFT testing.

Disabling save_first_step appropriately prevents interference with the test's focus on embedding upcast behavior and avoids potential early checkpointing issues with quantized models.

tests/e2e/patched/test_activation_checkpointing.py (1)

72-72: Maintains test focus on activation checkpointing.

Setting save_first_step: False appropriately prevents potential confusion between gradient checkpointing (the test's focus) and model checkpointing (the new callback feature).

tests/e2e/test_qwen.py (1)

62-62: Appropriate for DPO testing context.

Disabling save_first_step is sensible for this DPO test, preventing potential interference with preference optimization training while maintaining test focus.

tests/e2e/test_packing_loss.py (1)

51-51: LGTM - Consistent implementation of new configuration option.

The addition of "save_first_step": False is consistent with the PR objectives to introduce early checkpointing capability. Setting it to False in tests maintains existing behavior while allowing the feature to be tested elsewhere.

tests/e2e/test_reward_model_smollm2.py (1)

61-61: LGTM - Consistent implementation of new configuration option.

The addition of "save_first_step": False maintains consistency with the broader PR changes and appropriately disables the new checkpointing feature for this test to preserve existing behavior.

tests/e2e/patched/test_flattening.py (1)

64-64: LGTM - Consistent implementation of new configuration option.

The addition of "save_first_step": False is properly placed within the configuration dictionary and aligns with the PR's systematic approach to introducing the new checkpointing feature while maintaining existing test behavior.

tests/e2e/patched/test_resume.py (1)

61-61: LGTM - Appropriate for resume testing context.

The addition of "save_first_step": False is well-placed and particularly suitable for a resume test, where the focus is on resumption behavior rather than initial checkpointing functionality.

tests/e2e/solo/test_flex.py (1)

52-52: LGTM - Appropriate for focused feature testing.

The addition of "save_first_step": False is correctly implemented and appropriate for this flex attention test, allowing it to focus on the core functionality without interference from the new checkpointing feature.

tests/e2e/patched/test_fa_xentropy.py (1)

65-65: LGTM: Appropriate test configuration update.

Setting save_first_step to False in tests is the correct approach to avoid unnecessary checkpointing overhead while maintaining focus on the test's specific functionality.

tests/e2e/solo/test_relora_llama.py (1)

68-68: LGTM: Prevents interference with ReLoRA checkpoint validation.

Disabling first-step checkpointing is appropriate here since this test has specific checkpoint validation logic for ReLoRA functionality, and the additional checkpoint would complicate the test assertions.

tests/e2e/test_evaluate.py (1)

39-39: LGTM: Appropriate for evaluation-focused test.

Disabling first-step checkpointing is correct for an evaluation test since checkpointing behavior is not relevant to validating the evaluate CLI functionality.

tests/e2e/test_process_reward_model_smollm2.py (1)

52-52: LGTM: Maintains focus on process reward model functionality.

Disabling first-step checkpointing is appropriate for this specialized test, allowing it to focus on validating the process reward model's token classification capabilities without checkpointing overhead.

tests/e2e/patched/test_mixtral_samplepack.py (1)

55-55: LGTM: Consistent configuration across both test methods.

Both test methods appropriately disable first-step checkpointing, maintaining focus on their respective testing objectives (QLoRA and full fine-tuning) without unnecessary checkpointing overhead.

Also applies to: 94-94

tests/e2e/integrations/test_hooks.py (1)

156-156: Good addition for test stability.

Adding save_first_step: False to this existing test configuration is appropriate to prevent the new checkpointing behavior from interfering with the plugin hooks testing logic.

tests/e2e/multigpu/test_gemma3.py (1)

74-74: Consistent test configuration update.

Properly disabling the new save_first_step feature in this multi-GPU test maintains focus on the core DDP functionality being tested.

tests/e2e/patched/test_fused_llama.py (1)

56-56: Good practice for future test enablement.

Adding the save_first_step: False configuration even to this skipped test ensures consistency and prevents issues when the test is re-enabled.

tests/e2e/test_mamba.py (1)

54-54: Consistent configuration management.

Properly including the save_first_step: False option maintains test configuration consistency across the test suite.

tests/e2e/multigpu/test_eval.py (1)

70-70: Well-maintained test configuration consistency.

Both evaluation test methods properly include the save_first_step: False configuration, ensuring the new checkpointing feature doesn't interfere with evaluation-focused testing.

Also applies to: 142-142

tests/e2e/patched/test_mistral_samplepack.py (2)

59-59: LGTM! Consistent configuration for integration testing.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this integration test, allowing it to focus on the core LoRA packing functionality.


101-101: LGTM! Consistent configuration for integration testing.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this integration test, allowing it to focus on the core fine-tuning packing functionality.

tests/e2e/test_llama_pretrain.py (1)

56-56: LGTM! Consistent configuration for pretraining integration test.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this pretraining integration test, allowing it to focus on the core pretraining functionality across different packing configurations.

tests/e2e/multigpu/patched/test_sp.py (1)

72-72: LGTM! Consistent configuration for sequence parallelism integration test.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this multi-GPU sequence parallelism integration test, allowing it to focus on the core parallelism functionality.

tests/e2e/patched/test_falcon_samplepack.py (2)

61-61: LGTM! Consistent configuration for integration testing.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this integration test, allowing it to focus on the core QLoRA functionality when the test becomes active.


103-103: LGTM! Consistent configuration for integration testing.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this integration test, allowing it to focus on the core fine-tuning functionality when the test becomes active.

tests/e2e/test_gemma3_text.py (2)

66-66: LGTM! Consistent configuration for integration testing.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this integration test, allowing it to focus on the core LoRA functionality with Gemma3 models across different packing configurations.


117-117: LGTM! Consistent configuration for integration testing.

The addition of "save_first_step": False appropriately disables the new first-step checkpointing feature for this integration test, allowing it to focus on the core full fine-tuning functionality with Gemma3 models across different packing configurations.

tests/e2e/integrations/test_llm_compressor.py (1)

84-84: LGTM! Appropriate configuration for existing test.

Adding save_first_step: False ensures this existing test maintains its original behavior without the overhead of saving a first-step checkpoint, which is appropriate since this test focuses on LLMCompressor integration rather than the save_first_step feature.

tests/e2e/solo/test_save_first_step.py (1)

59-60: Excellent test coverage for the save_first_step feature.

The test logic is well-designed:

  • Positive test verifies checkpoint-1 exists when save_first_step=True
  • Negative test uses pytest.raises(AssertionError) to verify checkpoint-1 doesn't exist when save_first_step=False

This provides comprehensive coverage for the new callback functionality and aligns perfectly with the PR objectives of enabling early checkpoint validation.

Also applies to: 100-102

Copy link
Copy Markdown
Collaborator

@NanoCode012 NanoCode012 left a comment

Choose a reason for hiding this comment

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

I like this idea, but we may now get people complaining the training takes a bit longer to start (depending on model size).

I however would prefer this in as it would save people doing large runs time+resources.

Comment thread tests/e2e/solo/test_save_first_step.py
@salmanmohammadi
Copy link
Copy Markdown
Contributor

I would suggest we add # save_first_step: False to all of our example configs to increase visibility - or even # save_first_step: True # uncomment this to validate a test run with your config as an alternative to auto-enabling.

@djsaunde
Copy link
Copy Markdown
Collaborator Author

I would suggest we add # save_first_step: False to all of our example configs to increase visibility - or even # save_first_step: True # uncomment this to validate a test run with your config as an alternative to auto-enabling.

I think the latter is good alternative.

Or, we could raise a warning when it's not explicitly set? I'd prefer not to add warnings when possible, though, since we already have a lot of logs clutter.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/e2e/test_save_first_step.py (1)

1-3: Update docstring to reflect the actual test scope.

The docstring mentions "relora llama" but these tests are actually for the general save_first_step callback feature and aren't specific to relora configurations.

-"""
-E2E tests for relora llama
-"""
+"""
+E2E tests for save_first_step callback feature
+"""
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dce2148 and 2d6b619.

📒 Files selected for processing (1)
  • tests/e2e/test_save_first_step.py (1 hunks)
🔇 Additional comments (1)
tests/e2e/test_save_first_step.py (1)

21-61: LGTM! Test correctly validates save_first_step=True behavior.

The test properly sets up a minimal training configuration with save_first_step=True and verifies that the checkpoint is created after training.

Comment thread tests/e2e/test_save_first_step.py
Comment thread tests/e2e/test_save_first_step.py
@winglian winglian force-pushed the checkpoint-on-step-1 branch from 2d6b619 to f3703ea Compare July 15, 2025 00:31
@winglian
Copy link
Copy Markdown
Collaborator

I rebased and pushed as there were some merge conflicts from merging other PRs.

@djsaunde djsaunde merged commit 10ba162 into main Jul 15, 2025
12 of 17 checks passed
@djsaunde djsaunde deleted the checkpoint-on-step-1 branch July 15, 2025 19:00
djsaunde added a commit that referenced this pull request Jul 15, 2025
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.

4 participants