Skip to content

Conversation

@winglian
Copy link
Collaborator

@winglian winglian commented Jul 7, 2025

Description

Adds fixtures to the multi-gpu smoke tests w/ packing so avoid redundant tokenization during CI

Motivation and Context

dataset processing and tokenization is one of the slower steps in the CI. For some test modules, there are shared parameters for the dataset & model that the tokenization should be the same and we really only care about whether the training is functional.

How has this been tested?

ran tests, went from ~14 min -> ~12 min runtime for the modified test class.

when forcing the tests to fail with assert False, I see the following in the stdout logs indicating it successfully pulled preprocessed data

stdout: [2025-07-06 23:22:54,773] [INFO] [axolotl.utils.data.shared.load_preprocessed_dataset:461] [PID:457304] [RANK:1] Loading prepared dataset from disk at /tmp/tmp5cdyvbfm/last_run_prepa
red/1ebb24a74f570ae7bce0d63949bd8808...

Screenshots (if appropriate)

Types of changes

Social Handles (Optional)

Summary by CodeRabbit

  • Refactor

    • Simplified and centralized test configuration for multigpu LoRA TinyLlama tests by introducing shared fixtures for base and dataset preparation.
    • Reduced duplication in test setups by merging shared configurations with test-specific overrides.
    • Updated test parameter thresholds and improved code clarity in test files.
  • Tests

    • Added new pytest fixtures to manage temporary directories and shared configurations.
    • Improved maintainability and consistency of test cases for multigpu scenarios.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

Walkthrough

This update refactors test fixtures and configuration management for multi-GPU LoRA TinyLlama model tests. It replaces a function-scoped, autouse fixture for Triton cache with a module-scoped temporary directory fixture, and centralizes test configuration and dataset preparation into reusable pytest fixtures, streamlining test setup and reducing duplication.

Changes

File(s) Change Summary
tests/conftest.py Removed unique_triton_cache_dir fixture; added module_temp_dir fixture for module-scoped temp dirs.
tests/e2e/multigpu/test_llama.py Introduced shared config/dataset fixtures; refactored tests to use them and updated test thresholds.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Method
    participant Fixtures as Pytest Fixtures
    participant Preprocess as Preprocessing Subprocess

    Test->>Fixtures: Request sft_prepared_dataset_alpaca_cfg
    Fixtures->>Fixtures: Setup module_temp_dir
    Fixtures->>Preprocess: Run dataset preprocessing
    Preprocess-->>Fixtures: Return prepared dataset config
    Fixtures-->>Test: Provide merged config
    Test->>Test: Merge with test-specific overrides
    Test->>Test: Run training/evaluation with config
Loading

Possibly related PRs

  • axolotl-ai-cloud/axolotl#2843: Introduced the now-removed unique_triton_cache_dir fixture, directly related to the fixture changes in tests/conftest.py.

Poem

In a warren of tests, fixtures hop anew,
Old cache tricks retired, fresh temp dirs in view.
Configs now gather, with less to repeat,
Dataset prep streamlined—oh, testing’s a treat!
🐇✨
With each run, the code feels lighter and bright,
As rabbits rejoice in the moon’s silver light.

Warning

Review ran into problems

🔥 Problems

Check-run timed out after 90 seconds. Some checks/pipelines were still in progress when the timeout was reached. Consider increasing the reviews.tools.github-checks.timeout_ms value in your CodeRabbit configuration to allow more time for checks to complete.


📜 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 a5946ff and b79996b.

📒 Files selected for processing (2)
  • tests/conftest.py (2 hunks)
  • tests/e2e/multigpu/test_llama.py (16 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/e2e/multigpu/test_llama.py (4)
src/axolotl/utils/dict.py (1)
  • DictDefault (6-38)
tests/conftest.py (2)
  • module_temp_dir (427-432)
  • temp_dir (418-423)
tests/e2e/multigpu/test_gemma3.py (1)
  • test_lora_ddp_packed (31-96)
tests/e2e/multigpu/test_ray.py (1)
  • test_ds_zero2_packed (87-139)
⏰ 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). (11)
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.5.1)
  • GitHub Check: PyTest (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 from Source Dist (3.11, 2.6.0)
  • GitHub Check: pre-commit
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.6.0, 2, true)
  • GitHub Check: test-axolotl-multigpu (124, 12.4.1, 3.11, 2.5.1, 2, true)
  • GitHub Check: pre-commit
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.1, 2, true)
🔇 Additional comments (11)
tests/conftest.py (2)

13-13: LGTM! Clean import optimization.

Removing the unused PosixPath import improves code cleanliness.


426-432: Well-designed module-scoped fixture for shared preprocessing.

The module_temp_dir fixture correctly implements module-scoped temporary directory management, which is essential for the shared dataset preprocessing approach. The implementation follows the same pattern as the existing temp_dir fixture but with appropriate scope for reuse across tests.

tests/e2e/multigpu/test_llama.py (9)

5-5: Good practice for fixture usage.

Adding the pylint disable for redefined-outer-name is appropriate when using pytest fixtures extensively.


30-57: Well-structured base configuration fixture.

The sft_base_cfg fixture centralizes common configuration parameters, reducing duplication across tests. The configuration includes sensible defaults for the test environment.


60-81: Excellent dataset preprocessing fixture design.

The sft_prepared_dataset_alpaca_cfg fixture implements the core optimization by:

  • Running preprocessing once per module using the module_temp_dir fixture
  • Merging base config with preprocessing-specific settings
  • Unsetting flash_attention for flexibility in attention backend testing
  • Properly depending on the base configuration fixture

This should significantly reduce CI time by eliminating redundant tokenization.


156-186: Consistent implementation of shared fixture pattern.

The test_lora_ddp_packed method correctly adopts the new pattern by:

  • Accepting the sft_prepared_dataset_alpaca_cfg fixture
  • Using the | operator to merge test-specific overrides
  • Maintaining the same test logic while reducing duplication

442-479: Proper fixture integration with parametrized tests.

The test_fsdp_packed method successfully integrates the shared fixture while maintaining parametrization functionality. The configuration merging preserves test-specific parameters like fsdp_state_dict_type.


511-549: Good handling of attention backend configuration.

The test_fsdp2_packed method properly handles the attention backend logic by setting the appropriate attention type after merging the base configuration. This works well with the fixture's decision to unset flash_attention for flexibility.


576-625: Appropriate base model override for prequant testing.

The test_fsdp_qlora_prequant_packed method correctly overrides the base_model to use a prequantized model while still benefiting from the shared preprocessing for the dataset configuration.


664-703: Clean adapter configuration handling.

The test_ds_zero3_packed method maintains the dynamic adapter configuration logic while successfully integrating with the shared fixture pattern.


434-436: Verify the train loss threshold adjustments.

Several test methods have had their train loss thresholds increased (e.g., from 2.3 to 2.5). This could indicate that the shared preprocessing affects loss convergence patterns.

Please confirm that these threshold adjustments are based on actual CI test results and ensure the new thresholds still provide meaningful validation.

Also applies to: 499-500, 723-724, 792-793, 861-862

✨ 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.

@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

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