Skip to content

update loss value for flakey e2e test#2786

Merged
winglian merged 3 commits into
mainfrom
flaky-pretrain-test
Jun 12, 2025
Merged

update loss value for flakey e2e test#2786
winglian merged 3 commits into
mainfrom
flaky-pretrain-test

Conversation

@winglian

@winglian winglian commented Jun 12, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Tests
    • Updated the Llama pretraining test to allow a slightly higher baseline loss threshold, improving flexibility in test validation.

@coderabbitai

coderabbitai Bot commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The test for Llama pretraining was updated by increasing the baseline loss threshold from 3.5 to 3.6. The logic for adjusting the threshold under certain conditions remains unchanged. No modifications were made to public or exported entities.

Changes

File(s) Change Summary
tests/e2e/test_llama_pretrain.py Increased baseline loss threshold from 3.5 to 3.6.

Poem

A hop, a skip, a loss anew,
The threshold's raised, just by a few.
Llama trains with numbers bright,
Chasing metrics through the night.
With every tweak, we leap ahead—
Testing dreams where code is led!
🐇✨

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

@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

🔭 Outside diff range comments (1)
tests/e2e/test_llama_pretrain.py (1)

25-26: 🛠️ Refactor suggestion

Use pytest.skip() instead of a bare return

A bare return silently terminates the test without recording the reason. pytest.skip() makes the intention explicit in the test report and avoids confusion when analysing CI results.

-        if not sample_packing and pretrain_multipack_attn:
-            return
+        if not sample_packing and pretrain_multipack_attn:
+            pytest.skip("Combination not supported (multipack attention without sample packing)")
🧹 Nitpick comments (1)
tests/e2e/test_llama_pretrain.py (1)

68-70: Bumping the loss threshold is a band-aid; stabilise the run instead

Raising the threshold from 3.5 → 3.6 will let more noisy runs pass but also allows genuine regressions to slip through.
Two quick wins to reduce flakiness without loosening assertions:

  1. Fix the random seed (Python, NumPy, PyTorch) so training is deterministic.
  2. Pass the seed into the Axolotl config to propagate it downstream.
@@
     def test_pretrain(self, temp_dir, sample_packing, pretrain_multipack_attn):
+        # Make the training deterministic to curb loss variance
+        import random, numpy as np, torch
+        _seed = 42
+        random.seed(_seed)
+        np.random.seed(_seed)
+        torch.manual_seed(_seed)
+        torch.cuda.manual_seed_all(_seed)
+
@@
                 "bf16": "auto",
                 "use_tensorboard": True,
+                "seed": _seed,
             }

If determinism still doesn’t eliminate the occasional > 3.5 loss, consider asserting on the trend (e.g. last step < first step) or average of last n steps instead of a single absolute value.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f5fbc82 and 81a916b.

📒 Files selected for processing (1)
  • tests/e2e/test_llama_pretrain.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • 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: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.5.1)
  • GitHub Check: pre-commit
  • GitHub Check: pre-commit
🔇 Additional comments (1)
tests/e2e/test_llama_pretrain.py (1)

68-76: Large gap between 3.6 and 6.5 thresholds may hide regressions

When sample_packing is True and pretrain_multipack_attn is False, the acceptable loss jumps to 6.5 – almost double the default. Verify that this gap is genuinely necessary; otherwise shrink it or apply a relative delta (e.g. base * 1.8) to keep the guardrail meaningful.

@codecov

codecov Bot commented Jun 12, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Comment thread tests/e2e/test_llama_pretrain.py Outdated
@winglian winglian merged commit ace9287 into main Jun 12, 2025
20 of 27 checks passed
@winglian winglian deleted the flaky-pretrain-test branch June 12, 2025 22:06
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