Skip to content

make the initial call to tokenizer.pad not spam the console#2946

Merged
winglian merged 4 commits into
mainfrom
tokenizer-pad-quiet
Jul 19, 2025
Merged

make the initial call to tokenizer.pad not spam the console#2946
winglian merged 4 commits into
mainfrom
tokenizer-pad-quiet

Conversation

@winglian

@winglian winglian commented Jul 19, 2025

Copy link
Copy Markdown
Collaborator

Description

When training starts, we pad but the tokenizer usually gets called in fork/multiprocess so it spams the console with

Please note that with a fast tokenizer, using the `__call__` method is faster than using a method to encode the text followed by a call to the `pad` method to get a padded encoding.

This PR sets a variable so the check doesn't emit the mesage

Motivation and Context

How has this been tested?

Screenshots (if appropriate)

Types of changes

Social Handles (Optional)

Summary by CodeRabbit

  • Bug Fixes
    • Suppressed deprecation warnings related to padding on fast tokenizers, reducing unnecessary warning messages for users.
  • New Features
    • Added validation to prevent incompatible configuration options from being enabled simultaneously.
  • Improvements
    • Enhanced logging to provide clearer informational messages while limiting output to the main process in distributed environments.

@coderabbitai

coderabbitai Bot commented Jul 19, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A conditional block was added at the end of the _load_mistral_common_tokenizer function within load_tokenizer in src/axolotl/loaders/tokenizer.py. It sets the deprecation_warnings["Asking-to-pad-a-fast-tokenizer"] flag to True on the tokenizer object after logging when no chat template is selected. No other logic or error handling was changed. Additionally, a Pydantic validator was added to LigerArgs to prevent conflicting options, logging was introduced in the tiled MLP monkeypatch, and logging imports and calls were updated in the validation schema module.

Changes

File(s) Change Summary
src/axolotl/loaders/tokenizer.py Added setting of tokenizer.deprecation_warnings["Asking-to-pad-a-fast-tokenizer"] = True in _load_mistral_common_tokenizer within load_tokenizer.
src/axolotl/integrations/liger/args.py Added Pydantic classmethod validator check_tiled_mlp_conflict in LigerArgs to prevent simultaneous enabling of liger_glu_activation and tiled_mlp.
src/axolotl/monkeypatch/tiled_mlp.py Added module-level logger and info log message after monkey-patching TiledMLP.forward indicating successful patch for model_type.
src/axolotl/utils/schemas/validation.py Replaced logging import with custom get_logger from axolotl.utils.logging; updated logger instance creation and added main_process_only=True to a log call.

Possibly related PRs


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1e78cc0 and 089682d.

📒 Files selected for processing (3)
  • src/axolotl/integrations/liger/args.py (1 hunks)
  • src/axolotl/monkeypatch/tiled_mlp.py (2 hunks)
  • src/axolotl/utils/schemas/validation.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/axolotl/monkeypatch/tiled_mlp.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.0)
  • 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 (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
  • GitHub Check: pre-commit
🔇 Additional comments (3)
src/axolotl/utils/schemas/validation.py (2)

15-15: LGTM: Improved logging for distributed environments.

The migration from standard logging to the custom get_logger function standardizes logging behavior across the codebase and enables distributed-specific features like main_process_only.

Also applies to: 20-20


118-120: LGTM: Proper distributed logging implementation.

The addition of main_process_only=True ensures this log message only appears once in distributed training scenarios, preventing console spam. This addresses the previous reviewer's concern about logger support by using the custom get_logger function.

src/axolotl/integrations/liger/args.py (1)

57-64: LGTM: Essential validation for conflicting configurations.

This validator properly prevents incompatible options from being enabled simultaneously. The implementation follows Pydantic best practices and provides a clear error message to guide users.

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

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.

@winglian winglian requested review from NanoCode012 and djsaunde July 19, 2025 02:32

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 170322a and 017d57c.

📒 Files selected for processing (1)
  • src/axolotl/loaders/tokenizer.py (1 hunks)
⏰ 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). (8)
  • GitHub Check: pre-commit
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: pre-commit

Comment thread src/axolotl/loaders/tokenizer.py
@codecov

codecov Bot commented Jul 19, 2025

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/axolotl/monkeypatch/tiled_mlp.py 0.00% 3 Missing ⚠️
src/axolotl/integrations/liger/args.py 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Jul 19, 2025

Copy link
Copy Markdown
Contributor

📖 Documentation Preview: https://687b28c1dadc55a8d59befed--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit 089682d

Comment thread src/axolotl/utils/schemas/validation.py
@winglian winglian merged commit 109d9c7 into main Jul 19, 2025
17 checks passed
@winglian winglian deleted the tokenizer-pad-quiet branch July 19, 2025 17:53
@coderabbitai coderabbitai Bot mentioned this pull request Mar 9, 2026
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