Skip to content

Rank 0-only logging #2608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
May 28, 2025
Merged

Rank 0-only logging #2608

merged 36 commits into from
May 28, 2025

Conversation

SalmanMohammadi
Copy link
Contributor

@SalmanMohammadi SalmanMohammadi commented May 1, 2025

Just a start on removing unnecessary duplicate logging across multiple ranks. Will update as I find more cases - @maintainers feel free to add to this branch.

root@eebe878229e8:/workspace/axolotl# axolotl train examples/llama-3/lora-1b.yml 
[2025-05-19 17:03:05,194] [INFO] [real_accelerator.py:219:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2025-05-19 17:03:05,283] [INFO] [root.spawn:77] [PID:98907] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -c /tmp/tmpnwaw2628/test.c -o /tmp/tmpnwaw2628/test.o
[2025-05-19 17:03:05,310] [INFO] [root.spawn:77] [PID:98907] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat /tmp/tmpnwaw2628/test.o -laio -o /tmp/tmpnwaw2628/a.out
[2025-05-19 17:03:05,350] [INFO] [root.spawn:77] [PID:98907] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -c /tmp/tmpc82bup43/test.c -o /tmp/tmpc82bup43/test.o
[2025-05-19 17:03:05,376] [INFO] [root.spawn:77] [PID:98907] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat /tmp/tmpc82bup43/test.o -L/usr/local/cuda -L/usr/local/cuda/lib64 -lcufile -o /tmp/tmpc82bup43/a.out
The following values were not passed to `accelerate launch` and had defaults used instead:
        `--num_processes` was set to a value of `2`
                More than one GPU was found, enabling multi-GPU training.
                If this was unintended please pass in `--num_processes=1`.
        `--num_machines` was set to a value of `1`
        `--mixed_precision` was set to a value of `'no'`
        `--dynamo_backend` was set to a value of `'no'`
To avoid this warning pass in values for each of the problematic parameters or run `accelerate config`.
[2025-05-19 17:03:16,329] [INFO] [real_accelerator.py:219:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2025-05-19 17:03:16,349] [INFO] [real_accelerator.py:219:get_accelerator] Setting ds_accelerator to cuda (auto detect)
[2025-05-19 17:03:16,418] [INFO] [root.spawn:77] [PID:99566] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -c /tmp/tmpf4ysnh66/test.c -o /tmp/tmpf4ysnh66/test.o
[2025-05-19 17:03:16,436] [INFO] [root.spawn:77] [PID:99567] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -c /tmp/tmp8bn2f8bx/test.c -o /tmp/tmp8bn2f8bx/test.o
[2025-05-19 17:03:16,438] [INFO] [root.spawn:77] [PID:99566] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat /tmp/tmpf4ysnh66/test.o -laio -o /tmp/tmpf4ysnh66/a.out
[2025-05-19 17:03:16,463] [INFO] [root.spawn:77] [PID:99567] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat /tmp/tmp8bn2f8bx/test.o -laio -o /tmp/tmp8bn2f8bx/a.out
[2025-05-19 17:03:16,468] [INFO] [root.spawn:77] [PID:99566] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -c /tmp/tmp8imc24xx/test.c -o /tmp/tmp8imc24xx/test.o
[2025-05-19 17:03:16,489] [INFO] [root.spawn:77] [PID:99566] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat /tmp/tmp8imc24xx/test.o -L/usr/local/cuda -L/usr/local/cuda/lib64 -lcufile -o /tmp/tmp8imc24xx/a.out
[2025-05-19 17:03:16,497] [INFO] [root.spawn:77] [PID:99567] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -O2 -isystem /root/miniconda3/envs/py3.11/include -fPIC -c /tmp/tmp5i3wtr1z/test.c -o /tmp/tmp5i3wtr1z/test.o
[2025-05-19 17:03:16,522] [INFO] [root.spawn:77] [PID:99567] gcc -pthread -B /root/miniconda3/envs/py3.11/compiler_compat /tmp/tmp5i3wtr1z/test.o -L/usr/local/cuda -L/usr/local/cuda/lib64 -lcufile -o /tmp/tmp5i3wtr1z/a.out
[2025-05-19 17:03:17,418] [INFO] [datasets.<module>:54] [PID:99566] PyTorch version 2.6.0+cu124 available.
[2025-05-19 17:03:17,448] [INFO] [datasets.<module>:54] [PID:99567] PyTorch version 2.6.0+cu124 available.
INFO 05-19 17:03:19 [importing.py:53] Triton module has been replaced with a placeholder.
INFO 05-19 17:03:19 [importing.py:53] Triton module has been replaced with a placeholder.
INFO 05-19 17:03:19 [__init__.py:239] Automatically detected platform cuda.
INFO 05-19 17:03:19 [__init__.py:239] Automatically detected platform cuda.
[2025-05-19 17:03:21,472] [WARNING] [axolotl.utils.schemas.config.hint_lora_8bit:846] [PID:99566] [RANK:0] We recommend setting `load_in_8bit: true` for LORA finetuning
[2025-05-19 17:03:21,556] [DEBUG] [axolotl.utils.config.resolve_dtype:65] [PID:99566] [RANK:0] bf16 support detected, enabling for this configuration.
[2025-05-19 17:03:21,794] [INFO] [axolotl.utils.config.log_gpu_memory_usage:107] [PID:99566] [RANK:0] cuda memory usage baseline: 0.000GB (+0.395GB misc)

     #@@ #@@      @@# @@#
    @@  @@          @@  @@           =@@#                               @@                 #@    =@@#.
    @@    #@@@@@@@@@    @@           #@#@=                              @@                 #@     .=@@
      #@@@@@@@@@@@@@@@@@            =@# @#     ##=     ##    =####=+    @@      =#####+  =#@@###.   @@
    @@@@@@@@@@/  +@@/  +@@          #@  =@=     #@=   @@   =@#+  +#@#   @@    =@#+  +#@#   #@.      @@
    @@@@@@@@@@  ##@@  ##@@         =@#   @#      =@# @#    @@      @@   @@    @@      #@   #@       @@
     @@@@@@@@@@@@@@@@@@@@          #@=+++#@=      =@@#     @@      @@   @@    @@      #@   #@       @@
                                  =@#=====@@     =@# @#    @@      @@   @@    @@      #@   #@       @@
    @@@@@@@@@@@@@@@@  @@@@        #@      #@=   #@=  +@@   #@#    =@#   @@.   =@#    =@#   #@.      @@
                                 =@#       @#  #@=     #@   =#@@@@#=    +#@@=  +#@@@@#=    .##@@+   @@
    @@@@  @@@@@@@@@@@@@@@@

[rank1]:[W519 17:03:22.928749665 ProcessGroupNCCL.cpp:4561] [PG ID 0 PG GUID 0 Rank 1]  using GPU 1 to perform barrier as devices used by this process are currently unknown. This can potentially cause a hang if this rank to GPU mapping is incorrect. Specify device_ids in barrier() to force use of a particular device, or call init_process_group() with a device_id.
[2025-05-19 17:03:24,947] [DEBUG] [axolotl.utils.models.load_tokenizer:461] [PID:99566] [RANK:0] EOS: 128001 / <|end_of_text|>
[2025-05-19 17:03:24,948] [DEBUG] [axolotl.utils.models.load_tokenizer:464] [PID:99566] [RANK:0] PAD: 128001 / <|end_of_text|>
[2025-05-19 17:03:24,948] [DEBUG] [axolotl.utils.models.load_tokenizer:467] [PID:99566] [RANK:0] UNK: None / None
[2025-05-19 17:03:24,948] [INFO] [axolotl.utils.models.load_tokenizer:483] [PID:99566] [RANK:0] No Chat template selected. Consider adding a chat template for easier inference.
[2025-05-19 17:03:24,948] [INFO] [axolotl.utils.data.sft.load_tokenized_prepared_datasets:280] [PID:99566] [RANK:0] Unable to find prepared dataset in last_run_prepared/87233e1e917def7122b2b113697f5e3d
[2025-05-19 17:03:24,948] [INFO] [axolotl.utils.data.sft.load_tokenized_prepared_datasets:283] [PID:99566] [RANK:0] Loading raw datasets...
[2025-05-19 17:03:24,948] [WARNING] [axolotl.utils.data.sft.load_tokenized_prepared_datasets:287] [PID:99566] [RANK:0] Processing datasets during training can lead to VRAM instability. Please pre-process your dataset.
[2025-05-19 17:03:24,948] [INFO] [axolotl.utils.data.sft.load_tokenized_prepared_datasets:294] [PID:99566] [RANK:0] No seed provided, using default seed of 42
Repo card metadata block was not found. Setting CardData to empty.
[2025-05-19 17:03:26,095] [WARNING] [huggingface_hub.repocard.content:108] [PID:99566] Repo card metadata block was not found. Setting CardData to empty.
[2025-05-19 17:03:29,931] [INFO] [axolotl.utils.data.sft.get_dataset_wrapper:509] [PID:99566] [RANK:0] Loading dataset with base_type: alpaca and prompt_style: None
[2025-05-19 17:03:31,005] [INFO] [axolotl.utils.data.utils.drop_long_seq_in_dataset:177] [PID:99566] [RANK:0] min_input_len: 33
[2025-05-19 17:03:31,005] [INFO] [axolotl.utils.data.utils.drop_long_seq_in_dataset:181] [PID:99566] [RANK:0] max_input_len: 638
[2025-05-19 17:03:33,640] [INFO] [axolotl.utils.data.sft.load_tokenized_prepared_datasets:372] [PID:99566] [RANK:0] Saving merged prepared dataset to disk... last_run_prepared/87233e1e917def7122b2b113697f5e3d
Saving the dataset (1/1 shards): 100%|████████████████████████████████████████████████████████████████████████████████████████████| 54568/54568 [00:02<00:00, 21675.57 examples/s]
[rank0]:[W519 17:03:36.010026010 ProcessGroupNCCL.cpp:4561] [PG ID 0 PG GUID 0 Rank 0]  using GPU 0 to perform barrier as devices used by this process are currently unknown. This can potentially cause a hang if this rank to GPU mapping is incorrect. Specify device_ids in barrier() to force use of a particular device, or call init_process_group() with a device_id.
[2025-05-19 17:03:37,221] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:405] [PID:99566] [RANK:0] total_num_tokens: 818_917
[2025-05-19 17:03:37,287] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:425] [PID:99566] [RANK:0] `total_supervised_tokens: 168_730`
Repo card metadata block was not found. Setting CardData to empty.
[2025-05-19 17:03:38,097] [WARNING] [huggingface_hub.repocard.content:108] [PID:99567] Repo card metadata block was not found. Setting CardData to empty.
[2025-05-19 17:03:44,063] [INFO] [axolotl.utils.samplers.multipack.calc_min_len:412] [PID:99566] [RANK:0] gather_len_batches: [201, 201]
[2025-05-19 17:03:44,065] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:481] [PID:99566] [RANK:0] data_loader_len: 50
[2025-05-19 17:03:44,078] [INFO] [axolotl.utils.trainer.calc_sample_packing_eff_est:493] [PID:99566] [RANK:0] sample_packing_eff_est across ranks: [0.9946811199188232, 0.9946811199188232]
[2025-05-19 17:03:44,079] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:505] [PID:99566] [RANK:0] sample_packing_eff_est: None
[2025-05-19 17:03:44,079] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:517] [PID:99566] [RANK:0] total_num_steps: 50
[2025-05-19 17:03:44,160] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:405] [PID:99566] [RANK:0] total_num_tokens: 8_606_215
[2025-05-19 17:03:44,528] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:425] [PID:99566] [RANK:0] `total_supervised_tokens: 6_008_433`
[2025-05-19 17:03:46,210] [INFO] [axolotl.utils.samplers.multipack.calc_min_len:412] [PID:99566] [RANK:0] gather_len_batches: [2103, 2103]
[2025-05-19 17:03:46,211] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:481] [PID:99566] [RANK:0] data_loader_len: 525
[2025-05-19 17:03:46,212] [INFO] [axolotl.utils.trainer.calc_sample_packing_eff_est:493] [PID:99566] [RANK:0] sample_packing_eff_est across ranks: [0.9991092085838318, 0.9991092085838318]
[2025-05-19 17:03:46,212] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:505] [PID:99566] [RANK:0] sample_packing_eff_est: 1.0
[2025-05-19 17:03:46,212] [DEBUG] [axolotl.utils.trainer.calculate_total_num_steps:517] [PID:99566] [RANK:0] total_num_steps: 525
[2025-05-19 17:03:46,215] [INFO] [axolotl.utils.data.sft.prepare_dataset:189] [PID:99566] [RANK:0] Maximum number of steps set at 2
[2025-05-19 17:03:46,240] [DEBUG] [axolotl.train.setup_model_and_tokenizer:63] [PID:99566] [RANK:0] loading tokenizer... NousResearch/Llama-3.2-1B
[2025-05-19 17:03:47,027] [DEBUG] [axolotl.utils.models.load_tokenizer:461] [PID:99566] [RANK:0] EOS: 128001 / <|end_of_text|>
[2025-05-19 17:03:47,027] [DEBUG] [axolotl.utils.models.load_tokenizer:464] [PID:99566] [RANK:0] PAD: 128001 / <|end_of_text|>
[2025-05-19 17:03:47,028] [DEBUG] [axolotl.utils.models.load_tokenizer:467] [PID:99566] [RANK:0] UNK: None / None
[2025-05-19 17:03:47,028] [INFO] [axolotl.utils.models.load_tokenizer:483] [PID:99566] [RANK:0] No Chat template selected. Consider adding a chat template for easier inference.
[2025-05-19 17:03:47,028] [DEBUG] [axolotl.train.setup_model_and_tokenizer:77] [PID:99566] [RANK:0] loading model and peft_config...
[2025-05-19 17:03:58,372] [INFO] [axolotl.utils.models.log_gpu_memory_usage:107] [PID:99566] [RANK:0] cuda memory usage after model load: 2.313GB (+0.014GB cache, +0.794GB misc)
[2025-05-19 17:03:58,385] [INFO] [axolotl.utils.models.load_model:1382] [PID:99566] [RANK:0] Converting modules to torch.bfloat16
trainable params: 11,272,192 || all params: 1,247,086,592 || trainable%: 0.9039
[2025-05-19 17:03:58,698] [INFO] [axolotl.utils.models.log_gpu_memory_usage:107] [PID:99566] [RANK:0] cuda memory usage after adapters: 2.355GB (+1.009GB cache, +0.794GB misc)
/workspace/axolotl/src/axolotl/core/trainers/base.py:64: FutureWarning: `tokenizer` is deprecated and will be removed in version 5.0.0 for `AxolotlTrainer.__init__`. Use `processing_class` instead.
  super().__init__(*_args, **kwargs)
No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
/workspace/axolotl/src/axolotl/core/trainers/base.py:64: FutureWarning: `tokenizer` is deprecated and will be removed in version 5.0.0 for `AxolotlTrainer.__init__`. Use `processing_class` instead.
  super().__init__(*_args, **kwargs)
No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
[2025-05-19 17:03:59,750] [INFO] [axolotl.train.save_initial_configs:377] [PID:99566] [RANK:0] Pre-saving adapter config to ./outputs/lora-out...
[2025-05-19 17:03:59,760] [INFO] [axolotl.train.save_initial_configs:381] [PID:99566] [RANK:0] Pre-saving tokenizer to ./outputs/lora-out...
[2025-05-19 17:04:00,011] [INFO] [axolotl.train.save_initial_configs:384] [PID:99566] [RANK:0] Pre-saving model config to ./outputs/lora-out...
[2025-05-19 17:04:00,031] [INFO] [axolotl.train.execute_training:215] [PID:99566] [RANK:0] Starting trainer...
[2025-05-19 17:04:02,007] [INFO] [axolotl.utils.samplers.multipack.calc_min_len:412] [PID:99566] [RANK:0] gather_len_batches: [2103, 2103]
  0%|                                                                                                                                                       | 0/2 [00:00<?, ?it/s]You're using a PreTrainedTokenizerFast tokenizer. 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.
You're using a PreTrainedTokenizerFast tokenizer. 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.
{'loss': 1.1739, 'grad_norm': 0.2724481523036957, 'learning_rate': 0.0, 'epoch': 0.0}                                                                                             
 50%|███████████████████████████████████████████████████████████████████████▌                                                                       | 1/2 [00:02<00:02,  2.43s/it][2025-05-19 17:04:06,550] [INFO] [axolotl.utils.samplers.multipack.calc_min_len:412] [PID:99566] [RANK:0] gather_len_batches: [201, 201]
{'eval_loss': 1.5100458860397339, 'eval_runtime': 38.9219, 'eval_samples_per_second': 140.204, 'eval_steps_per_second': 35.07, 'epoch': 0.0}                                      
 50%|███████████████████████████████████████████████████████████████████████▌                                                                       | 1/2 [00:41<00:02,  2.43s/it[2025-05-19 17:04:45,804] [INFO] [axolotl.utils.callbacks.log_gpu_memory_usage:107] [PID:99566] [RANK:0] cuda memory usage while training: 2.436GB (+7.439GB cache, +0.816GB misc) 
{'loss': 0.9655, 'grad_norm': 0.2586127519607544, 'learning_rate': 2e-05, 'epoch': 0.0}                                                                                           
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:43<00:00, 25.22s/it][2025-05-19 17:04:47,704] [INFO] [axolotl.utils.samplers.multipack.calc_min_len:412] [PID:99566] [RANK:0] gather_len_batches: [201, 201]
{'eval_loss': 1.5089274644851685, 'eval_runtime': 38.8681, 'eval_samples_per_second': 140.398, 'eval_steps_per_second': 35.119, 'epoch': 0.0}                                     
{'train_runtime': 84.1981, 'train_samples_per_second': 0.19, 'train_steps_per_second': 0.024, 'train_loss': 1.0697062611579895, 'epoch': 0.0}                                     
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [01:24<00:00, 42.06s/it]
[2025-05-19 17:05:26,322] [INFO] [axolotl.train.save_trained_model:234] [PID:99566] [RANK:0] Training completed! Saving pre-trained model to ./outputs/lora-out.

Summary by CodeRabbit

  • New Features

    • Introduced a custom logging utility that ensures logs are emitted only from the main process in distributed environments and supports one-time warning messages.
  • Refactor

    • Replaced standard logging throughout the application and tests with the new custom logging utility for consistent and centralized log management.
    • Improved log message formatting and readability in various modules.
  • Chores

    • Updated configuration files to specify optimizer and learning rate scheduler parameters more explicitly.
    • Minor formatting and whitespace adjustments in code and configuration files.

@winglian winglian added this to the Axolotl v0.10.0 milestone May 7, 2025
djsaunde added a commit that referenced this pull request May 9, 2025
djsaunde added a commit that referenced this pull request May 10, 2025
djsaunde added a commit that referenced this pull request May 12, 2025
djsaunde added a commit that referenced this pull request May 12, 2025
djsaunde added a commit that referenced this pull request May 12, 2025
* ctx manager for SP

* updates

* update

* further simplifying

* simplifying

* simplifying

* reorg

* batch api HF adapter for ring-flash-attn; cleanup and improvements

* update

* adding all batch ring-flash-attn methods via single adapter

* fix

* fixes for batch API funcs, simplify

* fix

* grpo sp support

* progress

* stronger subclassing of TRL GRPO trainer; custom distributed sampler

* subclassing constructor

* progress

* finalizing SP + GRPO trainer

* minimize diffs to GRPO trainer

* remove (most of) the custom GRPO trainer logic

* debug

* debug

* update

* update

* update

* progress

* cleanup

* cleanup

* minor changes

* update

* update

* update

* small changes

* updates

* cleanup; torch.compile ring_flash_attn functions to prevent numerical instability; lint

* spacing

* cleanup; log in pydantic model config only on main process

* remove comment

* fix sp sampler, update to latest upstream code, doc

* add docs

* update quartodoc autodoc contents

* fix, simplifications

* fixes + simplifications

* review comments

* lint

* removing main process only logs in favor of #2608

* fixes, additional smoke test

* updatse

* more tests

* update

* fix grad accum bug (sort of)

* lint, tests

* todo
Copy link

coderabbitai bot commented May 15, 2025

Walkthrough

This update replaces all uses of the standard Python logging module across the codebase with a custom logging utility defined in axolotl.utils.logging. The new utility ensures logging occurs only on the main process in distributed environments and provides features such as warning suppression. Logger initialization and usage are standardized throughout, with minor formatting and readability improvements in some log messages. Additionally, the example configuration for llama-3 LoRA training was updated to remove an obsolete path and explicitly specify optimizer and learning rate scheduler parameters.

Changes

Files/Groups Change Summary
src/axolotl/utils/logging.py Introduced a custom logging utility with main-process-only and warning-once features.
src/axolotl/, src/axolotl/cli/, src/axolotl/core/, src/axolotl/loaders/, src/axolotl/monkeypatch/, src/axolotl/prompt_strategies/, src/axolotl/utils/**, src/axolotl/processing_strategies.py Replaced standard logging with custom get_logger import and initialization; updated log calls.
src/axolotl/utils/quantization.py, src/axolotl/cli/train.py Removed unused logging imports and logger initializations.
src/axolotl/utils/data/sft.py, src/axolotl/utils/data/rl.py Minor log message formatting and seed handling improvements.
src/axolotl/prompt_strategies/chat_template.py, src/axolotl/prompt_strategies/bradley_terry/chat_template.py Updated log level setting to use string names; minor code formatting for readability.
examples/llama-3/lora-1b.yml Removed dataset_prepared_path; added explicit optimizer and lr_scheduler fields.
tests/** Replaced standard logging with custom logger in all test modules; updated logger initialization.

Sequence Diagram(s)

sequenceDiagram
    participant Module
    participant axolotl.utils.logging
    participant MainProcess

    Module->>axolotl.utils.logging: get_logger(__name__)
    axolotl.utils.logging-->>Module: MultiProcessAdapter instance

    Module->>MultiProcessAdapter: LOG.info("message")
    MultiProcessAdapter->>MainProcess: Check if main process
    alt Is main process
        MultiProcessAdapter-->>Module: Emit log
    else Not main process
        MultiProcessAdapter-->>Module: Suppress log
    end

    Module->>MultiProcessAdapter: LOG.warning_once("message")
    MultiProcessAdapter->>MultiProcessAdapter: Check cache
    alt Not warned before
        MultiProcessAdapter-->>Module: Emit warning
    else Already warned
        MultiProcessAdapter-->>Module: Suppress duplicate warning
    end
Loading

Suggested reviewers

  • winglian

Poem

In the warren, logs once scattered wide,
Now gather in a custom guide.
Only the main rabbit will shout,
While others quietly hop about.
Warnings echo just once, not twice—
This logging patch is rather nice!
🐇✨


📜 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 fb5e1d1 and cef31bc.

📒 Files selected for processing (1)
  • src/axolotl/utils/schemas/config.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/axolotl/utils/schemas/config.py
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: PyTest (3.11, 2.5.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: pre-commit
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.5.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: test-axolotl-multigpu (124, 12.4.1, 3.11, 2.6.0, vllm, 2, true)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.0, 2, true)
  • GitHub Check: test-axolotl-multigpu (124, 12.4.1, 3.11, 2.5.1, 2, true)
  • GitHub Check: pre-commit
✨ Finishing Touches
  • 📝 Generate Docstrings

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

@SalmanMohammadi SalmanMohammadi marked this pull request as ready for review May 19, 2025 17:38
@SalmanMohammadi SalmanMohammadi requested a review from winglian May 19, 2025 17:39
Copy link

@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: 11

🔭 Outside diff range comments (2)
src/axolotl/monkeypatch/transformers_fa_utils.py (1)

47-53: ⚠️ Potential issue

Fix linter error for warning_once.
Static analysis reports that MultiProcessAdapter lacks a warning_once member. To resolve, either annotate the call for lint or provide a fallback:

-        logger.warning_once(
+        # pylint: disable=no-member
+        logger.warning_once(
             f"The input hidden states seems to be silently casted in float32, this might be related to"
             f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
             f" {target_dtype}."
         )

Alternatively, wrap in a runtime check and fallback to logger.warning(...) if warning_once is unavailable.

🧰 Tools
🪛 GitHub Actions: lint

[error] 50-50: pylint E1101: Instance of 'MultiProcessAdapter' has no 'warning_once' member.

src/axolotl/monkeypatch/lora_kernels.py (1)

378-380: ⚠️ Potential issue

Remove unsupported warning_once calls
MultiProcessAdapter does not expose warning_once, causing lint errors. Replace these calls with standard LOG.warning(...) or implement a one-time warning helper.

Proposed diff:

-                    LOG.warning_once(
-                        "Cannot patch some attention QKV projections - requires LoRA adapters with no bias"
-                    )
+                    LOG.warning(
+                        "Cannot patch some attention QKV projections - requires LoRA adapters with no bias"
+                    )
...
-                    LOG.warning_once(
-                        "Cannot patch some attention output projection - requires LoRA adapters with no bias"
-                    )
+                    LOG.warning(
+                        "Cannot patch some attention output projection - requires LoRA adapters with no bias"
+                    )
...
-                    LOG.warning_once(
-                        "Cannot patch some MLP layers - requires LoRA adapters with no bias"
-                    )
+                    LOG.warning(
+                        "Cannot patch some MLP layers - requires LoRA adapters with no bias"
+                    )

Also applies to: 396-398, 413-415

🧰 Tools
🪛 GitHub Actions: lint

[error] 378-413: pylint E1101: Instance of 'MultiProcessAdapter' has no 'warning_once' member at lines 378, 396, and 413.

🧹 Nitpick comments (47)
src/axolotl/utils/schemas/training.py (1)

1-1: Fix import sorting
A pre-commit isort hook flagged import ordering issues. Please run isort (or your project’s formatter) to restore correct grouping: standard library, third-party, then local imports.

🧰 Tools
🪛 GitHub Actions: lint

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/schemas/deprecated.py (1)

1-1: Restore import ordering
isort reported unsorted imports. Please apply the project’s import formatting rules to pass CI.

🧰 Tools
🪛 GitHub Actions: lint

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/schemas/integrations.py (1)

1-1: Correct import grouping
CI lint indicates import sorting issues. Run isort to align imports with the project’s style guide.

🧰 Tools
🪛 GitHub Actions: lint

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/inference.py (1)

1-1: Run import sorter
isort flagged import ordering; please apply the project’s import formatting to satisfy CI.

🧰 Tools
🪛 GitHub Actions: lint

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/metharme.py (1)

3-3: Ensure imports are correctly sorted.
The isort hook indicated import-order changes in this file. Please run isort to group and alphabetize imports (standard library, third-party, local) to satisfy lint rules.

src/axolotl/monkeypatch/accelerate/fsdp2.py (1)

5-5: Sort imports to satisfy lint rules.
Pre-commit isort fixed import sorting; please re-run isort so imports are grouped (stdlib first, then third-party, then local).

src/axolotl/cli/checks.py (1)

3-3: Ensure imports are correctly sorted.
The isort hook reordered imports here; please re-run isort to maintain consistent grouping and ordering.

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

15-19: Remove unused logging import and LOG declaration.
The test module imports get_logger and defines LOG but never uses it. Cleaning up dead code will improve readability:

- from axolotl.utils.logging import get_logger
- LOG = get_logger("axolotl.tests.e2e")
src/axolotl/monkeypatch/transformers_fa_utils.py (1)

5-5: Ensure imports are correctly sorted.
isort fixed import ordering; please re-run it so that the standard library imports precede third-party and local imports.

src/axolotl/utils/comet_.py (1)

3-6: Fix import ordering to satisfy isort
The custom logger import appears before the standard library and other first-party imports. Reorder to match isort’s grouping (stdlib → first-party → local).

-from axolotl.utils.logging import get_logger
 import os
-from axolotl.utils.dict import DictDefault
+from axolotl.utils.dict import DictDefault
+from axolotl.utils.logging import get_logger
src/axolotl/integrations/cut_cross_entropy/args.py (1)

18-22: Fix import order to satisfy isort
The get_logger import should follow third-party imports (typing, pydantic). Apply isort or use this diff to reorder:

-from axolotl.utils.logging import get_logger
-from typing import Optional
-
-from pydantic import BaseModel, model_validator
+from typing import Optional
+from pydantic import BaseModel, model_validator
+from axolotl.utils.logging import get_logger
src/axolotl/cli/merge_lora.py (1)

3-15: Fix import sorting to satisfy isort
Reorder imports into standard library, third-party, then local. Move the get_logger import into the local imports block. Example diff:

-from axolotl.utils.logging import get_logger
 from pathlib import Path
 from typing import Union

 import fire
 import transformers
 from dotenv import load_dotenv

-from axolotl.cli.args import TrainerCliArgs
-from axolotl.cli.art import print_axolotl_text_art
-from axolotl.cli.config import load_cfg
-from axolotl.cli.utils import load_model_and_tokenizer
-from axolotl.utils.dict import DictDefault
+from axolotl.utils.logging import get_logger
+from axolotl.cli.args import TrainerCliArgs
+from axolotl.cli.art import print_axolotl_text_art
+from axolotl.cli.config import load_cfg
+from axolotl.cli.utils import load_model_and_tokenizer
+from axolotl.utils.dict import DictDefault
src/axolotl/train.py (1)

34-34: Import grouping and sorting
The new get_logger import should be grouped with other axolotl.utils imports and run through isort to resolve the pipeline lint failure.

src/axolotl/prompt_strategies/bradley_terry/__init__.py (1)

5-5: Import grouping
Please run isort to maintain consistent import order and group the get_logger import with other local and third-party imports, satisfying the pre-commit hook.

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

18-24: Fix import sorting (isort failure)
The new import of get_logger should be reordered to satisfy the project’s import grouping rules. For example, place the standard‐library and third‐party imports first, then local imports. Applying isort (or manually reordering) will resolve the lint error.

Example diff:

-from axolotl.utils.logging import get_logger
-from typing import Optional
+from typing import Optional
+from pydantic import BaseModel, model_validator
+from axolotl.utils.logging import get_logger
src/axolotl/integrations/cut_cross_entropy/__init__.py (1)

22-33: Fix import sorting (isort failure)
The added import of get_logger and the placement of LOG = get_logger(__name__) need to be reordered to match the project’s import grouping conventions. Running isort or adjusting the order—standard library first, then third‐party (torch), then local (axolotl.* and relative)—will clear the lint error.

src/axolotl/integrations/grokfast/__init__.py (1)

5-14: Verify import ordering and logger setup

The new import get_logger and LOG = get_logger(__name__) are correct for centralized logging, but the import order conflicts with isort. Please sort imports according to PEP8: standard libs, third-party, then local package imports to satisfy pre-commit hooks.

src/axolotl/cli/merge_sharded_fsdp_weights.py (1)

4-31: Centralize logger and adjust import grouping

Switching to get_logger improves distributed log control via MultiProcessAdapter. Ensure imports are sorted (standard → third-party → local) to satisfy isort and keep consistency across CLI modules.

src/axolotl/prompt_strategies/base.py (1)

6-9: Fix import grouping to satisfy lint rules.

The new from axolotl.utils.logging import get_logger import and LOG = get_logger(__name__) should be placed after standard-library and third-party imports, per the project’s isort configuration. Running isort will resolve the current lint failure.

src/axolotl/utils/tokenization.py (1)

3-7: Resolve import sorting to clear pipeline errors.

Move the from axolotl.utils.logging import get_logger import and the subsequent LOG = get_logger(__name__) initialization into the correct section—after built-in and third-party imports—and re-run isort.

src/axolotl/prompt_strategies/llama2_chat.py (2)

32-35: Adjust import placement per isort.

The from axolotl.utils.logging import get_logger and LOG = get_logger(__name__) lines must follow other imports in the proper grouping (standard library → third-party → local). Apply isort to auto-fix ordering.


134-138: Simplify warning message text.

Since LOG.warning already denotes a warning, the prefix WARNING: is redundant. Consider changing to:

LOG.warning(f"Tokenization mismatch: {cur_len} vs. {total_len} (ignored)")

for conciseness.

src/axolotl/prompt_strategies/bradley_terry/chat_template.py (1)

12-17: Use get_logger’s log_level parameter & fix import order.

Rather than calling LOG.setLevel("INFO") after initialization, you can pass the level directly:

- from axolotl.utils.logging import get_logger
- LOG = get_logger(__name__)
- LOG.setLevel("INFO")
+ from axolotl.utils.logging import get_logger
+ LOG = get_logger(__name__, "INFO")

Also, ensure these lines are placed after standard- and third-party imports—run isort to clear the lint error.

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

13-17: Reorder logging import & initialization per project style.

Move the from axolotl.utils.logging import get_logger import and LOG = get_logger(__name__) into the correct section of imports (after third-party, before local) and re-run isort to satisfy the lint hook.

src/axolotl/core/trainers/grpo/__init__.py (1)

27-27: Remove unused import
SchedulerType from transformers.trainer_utils is never used in this module. Please remove this import to satisfy linting and reduce clutter.

src/axolotl/integrations/base.py (1)

27-27: Remove unused import
SchedulerType from transformers.trainer_utils is imported but not utilized. Please remove this line to satisfy lint checks.

🧰 Tools
🪛 Ruff (0.11.9)

27-27: transformers.trainer_utils.SchedulerType imported but unused

Remove unused import: transformers.trainer_utils.SchedulerType

(F401)

🪛 GitHub Actions: lint

[warning] 27-27: pylint W0611: Unused import 'SchedulerType' from transformers.trainer_utils.

tests/integrations/test_liger.py (1)

12-16: Unused logger definition
LOG = get_logger("axolotl.integrations.test_liger") is never used in this test file. Consider removing it to avoid confusion.

src/axolotl/core/trainer_builder.py (1)

860-862: Consider using 'not in' operator for membership test

The condition not (trainer_cls in [AxolotlRewardTrainer, AxolotlPRMTrainer]) can be more idiomatically expressed using the not in operator.

-        if (
-            not (trainer_cls in [AxolotlRewardTrainer, AxolotlPRMTrainer]) and
-            self.cfg.datasets is not None
-        ):
+        if (
+            trainer_cls not in [AxolotlRewardTrainer, AxolotlPRMTrainer] and
+            self.cfg.datasets is not None
+        ):
🧰 Tools
🪛 Ruff (0.11.9)

860-860: Test for membership should be not in

Convert to not in

(E713)

src/axolotl/monkeypatch/trainer_fsdp_optim.py (2)

5-10: Fix import ordering to satisfy isort.
The imports should be grouped as standard library (inspect), third-party (transformers), then local application (axolotl.utils.logging, axolotl.monkeypatch.utils). Please reorder or run isort to correct the import blocks.


72-74: Simplify dynamic import string construction.
The concatenation works, but you can improve readability by using an f‐string or implicit concatenation, for example:

-exec(
-    "from transformers.trainer import (" +
-    ", ".join(items_to_import) +
-    ")",
+exec(
+    f"from transformers.trainer import ({', '.join(items_to_import)})",
    globals(),
)
src/axolotl/utils/chat_templates.py (1)

6-7: Fix import ordering to satisfy isort.
Reorder imports as standard library (typing), then local (axolotl.utils.logging) to match the project’s import sorting rules. Running isort will align this automatically.

tests/patched/test_validation.py (1)

4-18: Fix import ordering to satisfy isort.
Group the imports as standard library (os, warnings, typing), then third-party (pytest, pydantic), followed by local (axolotl.utils.*). Please reorder or run isort.

src/axolotl/monkeypatch/trainer_eval_guard.py (2)

5-11: Fix import ordering to satisfy isort.
Imports should be ordered as standard library (inspect), then third-party (transformers), then local (axolotl.utils.logging, axolotl.monkeypatch.utils). Use isort to auto-correct.


69-71: Simplify dynamic import in exec.
Consider using an f‐string in the exec call for clarity:

-exec(
-    "from transformers.trainer import (" +
-    ", ".join(items_to_import) +
-    ")",
+exec(
+    f"from transformers.trainer import ({', '.join(items_to_import)})",
     globals(),
)
src/axolotl/core/trainers/mixins/scheduler.py (1)

3-6: Fix import ordering to satisfy isort.
Reorder the new get_logger import after the standard libraries and third-party imports. Running isort will automatically adjust this.

src/axolotl/prompt_strategies/chat_template.py (1)

546-549: Fix line break positioning in conditional

The line break after the binary operator triggers a W504 warning. According to PEP 8, line breaks should come before binary operators, not after them.

-                or
-                # gemma3 uses gemma tokenizer
-                "gemma" in self.tokenizer.name_or_path.lower()
+                # gemma3 uses gemma tokenizer
+                or "gemma" in self.tokenizer.name_or_path.lower()
🧰 Tools
🪛 GitHub Actions: lint

[warning] 546-546: flake8: line break after binary operator (W504)

tests/prompt_strategies/test_jinja_template_analyzer.py (1)

3-3: Remove unused import.

The os module is imported but not used anywhere in this file.

-import os
🧰 Tools
🪛 Ruff (0.11.9)

3-3: os imported but unused

Remove unused import: os

(F401)

src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (1)

168-168: Remove unnecessary getattr call.

Using getattr with a constant attribute name provides no additional safety compared to direct attribute access.

-        getattr(self.config, "sliding_window") is not None and
+        self.config.sliding_window is not None and
🧰 Tools
🪛 Ruff (0.11.9)

168-168: Do not call getattr with a constant attribute value. It is not any safer than normal property access.

Replace getattr with attribute access

(B009)

update_logging.py (3)

9-9: Remove unused import.

The Path import from pathlib is not used in the script.

-import os
-import re
-import sys
-from pathlib import Path
+import os
+import re
+import sys
🧰 Tools
🪛 Ruff (0.11.9)

9-9: pathlib.Path imported but unused

Remove unused import: pathlib.Path

(F401)

🪛 GitHub Actions: lint

[warning] 9-56: pylint warnings: multiple redefined-outer-name warnings for variables 'dry_run', 'base_dir', 'updated_files', 'skipped_files', 'file'; too many nested blocks (6/5); invalid constant name 'base_dir'; unused import 'Path'; and duplicate code detected with tests.prompt_strategies.messages.test_chat and tests.prompt_strategies.test_chat_templates.


86-89: Simplify with ternary operator.

Replace the if-else block with a more concise ternary expression.

-    if len(sys.argv) > 1:
-        base_dir = sys.argv[1]
-    else:
-        base_dir = "tests"
+    base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests"
🧰 Tools
🪛 Ruff (0.11.9)

86-89: Use ternary operator base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests" instead of if-else-block

Replace if-else-block with base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests"

(SIM108)


12-48: Consider function parameter naming.

The lint warnings about "redefined-outer-name" suggest that function parameters (dry_run, base_dir, etc.) are shadowing variables from outer scopes. While this works, it's generally better practice to use distinct names to avoid confusion.

Also applies to: 50-79

src/axolotl/utils/logging.py (1)

28-32: Simplify nested if statements.

The nested if statements could be combined into a single condition for better readability.

-        if self.isEnabledFor(level):
-            if self._should_log(main_process_only):
-                msg, kwargs = self.process(msg, kwargs)
-                self.logger.log(level, msg, *args, **kwargs)
+        if self.isEnabledFor(level) and self._should_log(main_process_only):
+            msg, kwargs = self.process(msg, kwargs)
+            self.logger.log(level, msg, *args, **kwargs)
🧰 Tools
🪛 Ruff (0.11.9)

28-29: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

src/axolotl/utils/models.py (1)

1383-1387: Fixed line break after binary operator (W504) issue.

The line continuation style was flagged by the linter.

-        should_convert = (
-            # LlamaRMSNorm layers are in fp32 after kbit_training or full finetune, so we need to
-            # convert them back to fp16/bf16 for flash-attn compatibility.
-            (
-                (needs_fa2_dtype or self.cfg.flash_attention or self.cfg.flex_attention)
-                and not qlora_fsdp
-            )
-            or
-            # Cut cross entropy requires embedding layers to be in fp16/bf16 for backward pass
-            self.cfg.cut_cross_entropy
-        )
+        should_convert = (
+            # LlamaRMSNorm layers are in fp32 after kbit_training or full finetune, so we need to
+            # convert them back to fp16/bf16 for flash-attn compatibility.
+            ((needs_fa2_dtype or self.cfg.flash_attention or self.cfg.flex_attention)
+             and not qlora_fsdp) or
+            # Cut cross entropy requires embedding layers to be in fp16/bf16 for backward pass
+            self.cfg.cut_cross_entropy
+        )
🧰 Tools
🪛 GitHub Actions: lint

[warning] 1384-1384: flake8: line break after binary operator (W504)

src/axolotl/monkeypatch/llama_attn_hijack_flash.py (2)

44-45: Consider delegating log-level via env var instead of hard-coding

get_logger() already honours AXOLOTL_LOG_LEVEL. Creating the logger is enough—no need to call setLevel() here (and you don’t in other modules). Dropping explicit level-setting keeps the behaviour uniform across the codebase.


615-633: Replace inline lambda pad helpers with named functions for consistency

Elsewhere in the PR (e.g. mistral_attn_hijack_flash.py) the anonymous lambda helpers were promoted to small def functions to improve tracebacks and avoid the # noqa: E731 override. Doing the same here keeps the codebase consistent and removes the pylint/flake8 suppression.

-        def output_pad_fn(output_unpad): return pad_input(  # noqa: E731
-            output_unpad, indices_q, batch_size, seqlen_q
-        )
+        def output_pad_fn(output_unpad):
+            """
+            Re-insert the packed QKV outputs into their original padded layout.
+            """
+            return pad_input(output_unpad, indices_q, batch_size, seqlen_q)

Apply the same pattern to the else branch a few lines below.

src/axolotl/utils/samplers/multipack.py (2)

9-10: Remove unused get_context import to satisfy lint and avoid confusion

multiprocessing.get_context is imported but never referenced (flake8 F401).
Simply delete the import to fix the pipeline failure.

-from multiprocessing import cpu_count, get_context
+from multiprocessing import cpu_count
🧰 Tools
🪛 Ruff (0.11.9)

9-9: multiprocessing.get_context imported but unused

Remove unused import: multiprocessing.get_context

(F401)

🪛 GitHub Actions: lint

[warning] 9-9: flake8 F401: Unused import 'multiprocessing.get_context'.


20-21: Hard-coding log level here overrides global settings

LOG.setLevel(logging.INFO) will silence DEBUG messages even if a user sets AXOLOTL_LOG_LEVEL=DEBUG. Removing this line lets the central get_logger() utility handle log levels consistently.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between a27b909 and e930ba7.

📒 Files selected for processing (128)
  • examples/llama-3/lora-1b.yml (2 hunks)
  • examples/llama-3/qlora-1b-kto.yaml (1 hunks)
  • src/axolotl/cli/checks.py (1 hunks)
  • src/axolotl/cli/config.py (2 hunks)
  • src/axolotl/cli/evaluate.py (2 hunks)
  • src/axolotl/cli/inference.py (2 hunks)
  • src/axolotl/cli/main.py (2 hunks)
  • src/axolotl/cli/merge_lora.py (2 hunks)
  • src/axolotl/cli/merge_sharded_fsdp_weights.py (2 hunks)
  • src/axolotl/cli/preprocess.py (4 hunks)
  • src/axolotl/cli/train.py (0 hunks)
  • src/axolotl/cli/utils.py (2 hunks)
  • src/axolotl/common/datasets.py (4 hunks)
  • src/axolotl/core/chat/messages.py (2 hunks)
  • src/axolotl/core/trainer_builder.py (8 hunks)
  • src/axolotl/core/trainers/base.py (5 hunks)
  • src/axolotl/core/trainers/grpo/__init__.py (3 hunks)
  • src/axolotl/core/trainers/mixins/optimizer.py (3 hunks)
  • src/axolotl/core/trainers/mixins/rng_state_loader.py (2 hunks)
  • src/axolotl/core/trainers/mixins/scheduler.py (5 hunks)
  • src/axolotl/datasets.py (3 hunks)
  • src/axolotl/integrations/base.py (2 hunks)
  • src/axolotl/integrations/cut_cross_entropy/__init__.py (2 hunks)
  • src/axolotl/integrations/cut_cross_entropy/args.py (1 hunks)
  • src/axolotl/integrations/grokfast/__init__.py (1 hunks)
  • src/axolotl/integrations/liger/__init__.py (3 hunks)
  • src/axolotl/integrations/liger/args.py (1 hunks)
  • src/axolotl/integrations/llm_compressor/plugin.py (2 hunks)
  • src/axolotl/integrations/spectrum/__init__.py (2 hunks)
  • src/axolotl/monkeypatch/accelerate/fsdp2.py (1 hunks)
  • src/axolotl/monkeypatch/btlm_attn_hijack_flash.py (1 hunks)
  • src/axolotl/monkeypatch/llama_attn_hijack_flash.py (6 hunks)
  • src/axolotl/monkeypatch/llama_attn_hijack_xformers.py (1 hunks)
  • src/axolotl/monkeypatch/lora_kernels.py (2 hunks)
  • src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (8 hunks)
  • src/axolotl/monkeypatch/peft/utils.py (1 hunks)
  • src/axolotl/monkeypatch/relora.py (5 hunks)
  • src/axolotl/monkeypatch/stablelm_attn_hijack_flash.py (1 hunks)
  • src/axolotl/monkeypatch/trainer/lr.py (1 hunks)
  • src/axolotl/monkeypatch/trainer_accelerator_args.py (2 hunks)
  • src/axolotl/monkeypatch/trainer_eval_guard.py (2 hunks)
  • src/axolotl/monkeypatch/trainer_fsdp_optim.py (2 hunks)
  • src/axolotl/monkeypatch/transformers_fa_utils.py (1 hunks)
  • src/axolotl/monkeypatch/unsloth_.py (3 hunks)
  • src/axolotl/prompt_strategies/__init__.py (1 hunks)
  • src/axolotl/prompt_strategies/base.py (1 hunks)
  • src/axolotl/prompt_strategies/bradley_terry/__init__.py (1 hunks)
  • src/axolotl/prompt_strategies/bradley_terry/chat_template.py (1 hunks)
  • src/axolotl/prompt_strategies/chat_template.py (3 hunks)
  • src/axolotl/prompt_strategies/llama2_chat.py (2 hunks)
  • src/axolotl/prompt_strategies/messages/__init__.py (1 hunks)
  • src/axolotl/prompt_strategies/metharme.py (1 hunks)
  • src/axolotl/prompt_strategies/pygmalion.py (3 hunks)
  • src/axolotl/prompt_tokenizers.py (4 hunks)
  • src/axolotl/prompters.py (2 hunks)
  • src/axolotl/train.py (2 hunks)
  • src/axolotl/utils/callbacks/__init__.py (9 hunks)
  • src/axolotl/utils/callbacks/comet_.py (2 hunks)
  • src/axolotl/utils/callbacks/lisa.py (2 hunks)
  • src/axolotl/utils/callbacks/mlflow_.py (2 hunks)
  • src/axolotl/utils/chat_templates.py (2 hunks)
  • src/axolotl/utils/comet_.py (1 hunks)
  • src/axolotl/utils/config/__init__.py (6 hunks)
  • src/axolotl/utils/data/pretraining.py (2 hunks)
  • src/axolotl/utils/data/rl.py (4 hunks)
  • src/axolotl/utils/data/sft.py (10 hunks)
  • src/axolotl/utils/data/utils.py (4 hunks)
  • src/axolotl/utils/distributed.py (1 hunks)
  • src/axolotl/utils/gradient_checkpointing/offload_disk.py (1 hunks)
  • src/axolotl/utils/logging.py (1 hunks)
  • src/axolotl/utils/models.py (19 hunks)
  • src/axolotl/utils/samplers/multipack.py (4 hunks)
  • src/axolotl/utils/schemas/config.py (34 hunks)
  • src/axolotl/utils/schemas/deprecated.py (1 hunks)
  • src/axolotl/utils/schemas/integrations.py (1 hunks)
  • src/axolotl/utils/schemas/model.py (1 hunks)
  • src/axolotl/utils/schemas/training.py (2 hunks)
  • src/axolotl/utils/schemas/utils.py (3 hunks)
  • src/axolotl/utils/tokenization.py (1 hunks)
  • src/axolotl/utils/trainer.py (4 hunks)
  • tests/e2e/multigpu/solo/test_flex.py (1 hunks)
  • tests/e2e/multigpu/test_eval.py (1 hunks)
  • tests/e2e/multigpu/test_gemma3.py (1 hunks)
  • tests/e2e/multigpu/test_llama.py (1 hunks)
  • tests/e2e/multigpu/test_qwen2.py (1 hunks)
  • tests/e2e/multigpu/test_ray.py (1 hunks)
  • tests/e2e/patched/test_4d_multipack_llama.py (1 hunks)
  • tests/e2e/patched/test_fa_xentropy.py (1 hunks)
  • tests/e2e/patched/test_falcon_samplepack.py (1 hunks)
  • tests/e2e/patched/test_fused_llama.py (1 hunks)
  • tests/e2e/patched/test_llama_s2_attention.py (1 hunks)
  • tests/e2e/patched/test_lora_llama_multipack.py (1 hunks)
  • tests/e2e/patched/test_mistral_samplepack.py (1 hunks)
  • tests/e2e/patched/test_mixtral_samplepack.py (1 hunks)
  • tests/e2e/patched/test_phi_multipack.py (1 hunks)
  • tests/e2e/patched/test_resume.py (1 hunks)
  • tests/e2e/patched/test_unsloth_qlora.py (1 hunks)
  • tests/e2e/solo/test_flex.py (1 hunks)
  • tests/e2e/solo/test_relora_llama.py (1 hunks)
  • tests/e2e/test_deepseekv3.py (1 hunks)
  • tests/e2e/test_dpo.py (1 hunks)
  • tests/e2e/test_embeddings_lr.py (1 hunks)
  • tests/e2e/test_falcon.py (1 hunks)
  • tests/e2e/test_gemma2.py (1 hunks)
  • tests/e2e/test_gemma3_text.py (1 hunks)
  • tests/e2e/test_llama.py (1 hunks)
  • tests/e2e/test_llama_pretrain.py (1 hunks)
  • tests/e2e/test_llama_vision.py (1 hunks)
  • tests/e2e/test_lora_llama.py (1 hunks)
  • tests/e2e/test_mamba.py (1 hunks)
  • tests/e2e/test_mistral.py (1 hunks)
  • tests/e2e/test_mixtral.py (1 hunks)
  • tests/e2e/test_optimizers.py (1 hunks)
  • tests/e2e/test_packing_loss.py (1 hunks)
  • tests/e2e/test_phi.py (1 hunks)
  • tests/e2e/test_process_reward_model_smollm2.py (1 hunks)
  • tests/e2e/test_qwen.py (1 hunks)
  • tests/e2e/test_reward_model_smollm2.py (1 hunks)
  • tests/e2e/test_schedulers.py (1 hunks)
  • tests/integrations/test_liger.py (3 hunks)
  • tests/patched/test_validation.py (15 hunks)
  • tests/prompt_strategies/messages/test_chat.py (1 hunks)
  • tests/prompt_strategies/test_chat_templates.py (1 hunks)
  • tests/prompt_strategies/test_chat_templates_advanced.py (1 hunks)
  • tests/prompt_strategies/test_chat_templates_thinking.py (1 hunks)
  • tests/prompt_strategies/test_jinja_template_analyzer.py (5 hunks)
  • tests/test_prompt_tokenizers.py (6 hunks)
  • update_logging.py (1 hunks)
💤 Files with no reviewable changes (1)
  • src/axolotl/cli/train.py
🧰 Additional context used
🧬 Code Graph Analysis (101)
src/axolotl/monkeypatch/peft/utils.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/stablelm_attn_hijack_flash.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/accelerate/fsdp2.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/patched/test_unsloth_qlora.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • check_tensorboard (135-149)
src/axolotl/cli/inference.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/core/chat/messages.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/trainer_accelerator_args.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/utils.py (1)
  • detab_code (232-238)
src/axolotl/integrations/cut_cross_entropy/__init__.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_embeddings_lr.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (3)
  • check_model_output_exists (152-173)
  • check_tensorboard (135-149)
  • with_temp_dir (21-33)
src/axolotl/core/trainers/mixins/rng_state_loader.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/cli/merge_sharded_fsdp_weights.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/cli/evaluate.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_falcon.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/utils/schemas/model.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/cli/utils.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/schemas/deprecated.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/cli/config.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/solo/test_flex.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (3)
  • check_tensorboard (135-149)
  • require_torch_2_6_0 (70-79)
  • with_temp_dir (21-33)
tests/e2e/test_optimizers.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (3)
  • check_model_output_exists (152-173)
  • require_torch_2_5_1 (58-67)
  • with_temp_dir (21-33)
src/axolotl/integrations/cut_cross_entropy/args.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/callbacks/lisa.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/cli/checks.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/unsloth_.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_schedulers.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/e2e/patched/test_resume.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (3)
  • check_model_output_exists (152-173)
  • most_recent_subdir (36-43)
  • require_torch_2_6_0 (70-79)
tests/e2e/multigpu/solo/test_flex.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_tensorboard (135-149)
  • require_torch_2_6_0 (70-79)
src/axolotl/monkeypatch/llama_attn_hijack_xformers.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/integrations/llm_compressor/plugin.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/multigpu/test_qwen2.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_reward_model_smollm2.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (3)
  • check_model_output_exists (152-173)
  • check_tensorboard (135-149)
  • with_temp_dir (21-33)
tests/e2e/patched/test_phi_multipack.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/e2e/test_process_reward_model_smollm2.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (3)
  • check_model_output_exists (152-173)
  • check_tensorboard (135-149)
  • with_temp_dir (21-33)
tests/e2e/test_llama_vision.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/cli/merge_lora.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/schemas/training.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/patched/test_fused_llama.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/e2e/test_lora_llama.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/e2e/test_qwen.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/patched/test_mixtral_samplepack.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/prompt_strategies/__init__.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/schemas/integrations.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_llama_pretrain.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • check_tensorboard (135-149)
tests/e2e/patched/test_mistral_samplepack.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/e2e/test_dpo.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/utils/callbacks/comet_.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/callbacks/mlflow_.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/comet_.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/dict.py (1)
  • DictDefault (6-38)
tests/e2e/patched/test_fa_xentropy.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • check_tensorboard (135-149)
tests/e2e/patched/test_4d_multipack_llama.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/e2e/test_gemma3_text.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/transformers_fa_utils.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/integrations/liger/args.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_mixtral.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/prompt_strategies/llama2_chat.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/patched/test_lora_llama_multipack.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/utils/data/pretraining.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/patched/test_llama_s2_attention.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/integrations/grokfast/__init__.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/integrations/base.py (1)
  • BasePlugin (35-246)
tests/e2e/multigpu/test_gemma3.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (1)
  • check_tensorboard (135-149)
src/axolotl/utils/tokenization.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_strategies/base.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/multigpu/test_llama.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_tensorboard (135-149)
  • require_torch_2_6_0 (70-79)
tests/e2e/patched/test_falcon_samplepack.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/utils/gradient_checkpointing/offload_disk.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_llama.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (1)
  • check_model_output_exists (152-173)
src/axolotl/datasets.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_strategies/bradley_terry/chat_template.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_strategies/messages/__init__.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_mamba.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/monkeypatch/trainer_fsdp_optim.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/utils.py (1)
  • detab_code (232-238)
src/axolotl/core/trainers/mixins/scheduler.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/integrations/spectrum/__init__.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/integrations/spectrum/args.py (1)
  • SpectrumArgs (23-46)
src/axolotl/utils/data/utils.py (3)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/samplers/utils.py (1)
  • get_dataset_lengths (8-21)
src/axolotl/utils/trainer.py (1)
  • drop_long_seq (208-235)
src/axolotl/monkeypatch/trainer/lr.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompters.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/integrations/base.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_mistral.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
src/axolotl/utils/trainer.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_gemma2.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/test_phi.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/e2e/utils.py (2)
  • check_model_output_exists (152-173)
  • with_temp_dir (21-33)
tests/prompt_strategies/test_chat_templates.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/integrations/test_liger.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_strategies/bradley_terry/__init__.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/lora_kernels.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/relora.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_tokenizers.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompters.py (1)
  • Prompter (25-28)
src/axolotl/core/trainers/grpo/__init__.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/trainer_eval_guard.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/utils.py (1)
  • detab_code (232-238)
tests/prompt_strategies/test_chat_templates_thinking.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/schemas/utils.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
tests/prompt_strategies/test_jinja_template_analyzer.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/common/datasets.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/core/trainers/base.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_strategies/chat_template.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/prompt_strategies/orpo/chat_template.py (1)
  • build_prompt (214-241)
src/axolotl/utils/logging.py (2)
src/axolotl/utils/distributed.py (1)
  • is_main_process (72-88)
src/axolotl/datasets.py (1)
  • process (47-73)
src/axolotl/monkeypatch/llama_attn_hijack_flash.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (2)
  • output_pad_fn (362-364)
  • output_pad_fn (377-379)
src/axolotl/utils/callbacks/__init__.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (2)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/monkeypatch/llama_attn_hijack_flash.py (2)
  • output_pad_fn (615-617)
  • output_pad_fn (630-632)
src/axolotl/train.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/samplers/multipack.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
src/axolotl/utils/chat_templates.py (1)
src/axolotl/utils/logging.py (1)
  • get_logger (34-41)
🪛 GitHub Actions: lint
src/axolotl/monkeypatch/accelerate/fsdp2.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/inference.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/trainer_accelerator_args.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/integrations/cut_cross_entropy/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/core/trainers/mixins/rng_state_loader.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/merge_sharded_fsdp_weights.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/evaluate.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/schemas/model.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/metharme.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/utils.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/schemas/deprecated.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/config.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/btlm_attn_hijack_flash.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/integrations/cut_cross_entropy/args.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/callbacks/lisa.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/checks.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/integrations/llm_compressor/plugin.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/merge_lora.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/schemas/training.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/schemas/integrations.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/callbacks/comet_.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/callbacks/mlflow_.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/comet_.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/transformers_fa_utils.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.


[error] 50-50: pylint E1101: Instance of 'MultiProcessAdapter' has no 'warning_once' member.

src/axolotl/integrations/liger/args.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/data/pretraining.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/integrations/grokfast/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/tokenization.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/base.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/cli/preprocess.py

[error] 1-1: Pre-commit hook 'black' reformatted this file to fix code style issues.

src/axolotl/datasets.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/messages/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/trainer_fsdp_optim.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/core/trainers/mixins/scheduler.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/trainer/lr.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompters.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/integrations/base.py

[warning] 27-27: pylint W0611: Unused import 'SchedulerType' from transformers.trainer_utils.

tests/prompt_strategies/test_chat_templates.py

[warning] 25-39: pylint duplicate code detected with tests.prompt_strategies.messages.test_chat.


[warning] 159-167: pylint duplicate code detected with tests.prompt_strategies.messages.test_chat.


[warning] 55-74: pylint duplicate code detected with tests.prompt_strategies.messages.test_chat.

src/axolotl/prompt_strategies/bradley_terry/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/lora_kernels.py

[error] 378-413: pylint E1101: Instance of 'MultiProcessAdapter' has no 'warning_once' member at lines 378, 396, and 413.

src/axolotl/monkeypatch/relora.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/core/trainers/mixins/optimizer.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_tokenizers.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/pygmalion.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/core/trainers/grpo/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.


[error] 48-50: mypy error: 'TRLConfig' has no attribute 'vllm'.

src/axolotl/monkeypatch/trainer_eval_guard.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

tests/prompt_strategies/test_chat_templates_thinking.py

[error] 10-10: mypy errors: Module 'axolotl.prompt_strategies.jinja_template_analyzer' has no attribute 'PromptComponentStatus' and 'PromptTemplateAnalyzer'.

tests/prompt_strategies/messages/test_chat.py

[error] 3-8: flake8 F401: Multiple unused imports including 'os', 'transformers.AutoTokenizer', and several unused imports from axolotl.core.chat.messages.


[warning] 49-68: pylint duplicate code detected with tests.prompt_strategies.test_chat_templates.


[warning] 28-42: pylint duplicate code detected with tests.prompt_strategies.test_chat_templates.

src/axolotl/utils/schemas/utils.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

tests/test_prompt_tokenizers.py

[error] 3-221: flake8 and pylint errors: multiple unused imports (e.g., 'unittest', 'transformers.AutoTokenizer'), undefined names (e.g., 'NoSystemPrompter', 'SystemDataPrompter', 'InstructionWSystemPromptTokenizingStrategy', 'Path', 'json', 'Llama2ChatPrompter', 'LLama2ChatTokenizingStrategy', 'load', 'DictDefault'), and E0611 import errors for missing attributes in modules 'axolotl.prompt_tokenizers' and 'axolotl.prompters'.


[error] 9-15: mypy errors: Module 'axolotl.prompt_tokenizers' has no attribute 'ShareGPTPromptTokenizingStrategy'; Module 'axolotl.prompters' has no attribute 'AlpacaInstructionPrompter' and 'ShareGPTPrompter'.

src/axolotl/utils/data/sft.py

[error] 1-1: Pre-commit hook 'trailing-whitespace' failed and fixed trailing whitespace issues in this file.

tests/prompt_strategies/test_jinja_template_analyzer.py

[error] 7-7: flake8 E0611: No name 'PromptComponentStatus' and 'PromptTemplateAnalyzer' in module 'axolotl.prompt_strategies.jinja_template_analyzer'.

src/axolotl/common/datasets.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/data/rl.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/core/trainers/base.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/prompt_strategies/chat_template.py

[warning] 546-546: flake8: line break after binary operator (W504)

src/axolotl/monkeypatch/llama_attn_hijack_flash.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

update_logging.py

[warning] 9-56: pylint warnings: multiple redefined-outer-name warnings for variables 'dry_run', 'base_dir', 'updated_files', 'skipped_files', 'file'; too many nested blocks (6/5); invalid constant name 'base_dir'; unused import 'Path'; and duplicate code detected with tests.prompt_strategies.messages.test_chat and tests.prompt_strategies.test_chat_templates.

src/axolotl/utils/callbacks/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/monkeypatch/mistral_attn_hijack_flash.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/models.py

[warning] 1384-1384: flake8: line break after binary operator (W504)

src/axolotl/utils/config/__init__.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/core/trainer_builder.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

src/axolotl/utils/samplers/multipack.py

[warning] 9-9: flake8 F401: Unused import 'multiprocessing.get_context'.

src/axolotl/utils/schemas/config.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.


[error] 130-130: mypy error: Value of type variable 'SupportsRichComparisonT' of 'min' cannot be 'int | None'.

src/axolotl/utils/chat_templates.py

[error] 1-1: Pre-commit hook 'isort' fixed import sorting issues in this file.

🪛 Ruff (0.11.9)
src/axolotl/integrations/base.py

27-27: transformers.trainer_utils.SchedulerType imported but unused

Remove unused import: transformers.trainer_utils.SchedulerType

(F401)

tests/prompt_strategies/messages/test_chat.py

3-3: os imported but unused

Remove unused import: os

(F401)


6-6: transformers.AutoTokenizer imported but unused

Remove unused import: transformers.AutoTokenizer

(F401)


9-9: axolotl.core.chat.messages.ChatFormattedChats imported but unused

Remove unused import

(F401)


10-10: axolotl.core.chat.messages.Chats imported but unused

Remove unused import

(F401)


11-11: axolotl.core.chat.messages.MessageContents imported but unused

Remove unused import

(F401)


12-12: axolotl.core.chat.messages.MessageContentTypes imported but unused

Remove unused import

(F401)


13-13: axolotl.core.chat.messages.MessageRoles imported but unused

Remove unused import

(F401)


14-14: axolotl.core.chat.messages.Messages imported but unused

Remove unused import

(F401)

tests/test_prompt_tokenizers.py

3-3: unittest imported but unused

Remove unused import: unittest

(F401)


6-6: transformers.AutoTokenizer imported but unused

Remove unused import: transformers.AutoTokenizer

(F401)


11-11: axolotl.prompt_tokenizers.InstructionPromptTokenizingStrategy imported but unused

Remove unused import

(F401)


12-12: axolotl.prompt_tokenizers.PromptTokenizingStrategy imported but unused

Remove unused import

(F401)


13-13: axolotl.prompt_tokenizers.ShareGPTPromptTokenizingStrategy imported but unused

Remove unused import

(F401)


15-15: axolotl.prompters.AlpacaInstructionPrompter imported but unused

Remove unused import

(F401)


15-15: axolotl.prompters.ShareGPTPrompter imported but unused

Remove unused import

(F401)

tests/prompt_strategies/test_jinja_template_analyzer.py

3-3: os imported but unused

Remove unused import: os

(F401)


8-8: axolotl.prompt_strategies.jinja_template_analyzer.PromptComponentStatus imported but unused

Remove unused import: axolotl.prompt_strategies.jinja_template_analyzer.PromptComponentStatus

(F401)

src/axolotl/utils/logging.py

28-29: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

update_logging.py

9-9: pathlib.Path imported but unused

Remove unused import: pathlib.Path

(F401)


86-89: Use ternary operator base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests" instead of if-else-block

Replace if-else-block with base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests"

(SIM108)

src/axolotl/monkeypatch/mistral_attn_hijack_flash.py

168-168: Do not call getattr with a constant attribute value. It is not any safer than normal property access.

Replace getattr with attribute access

(B009)

src/axolotl/core/trainer_builder.py

860-860: Test for membership should be not in

Convert to not in

(E713)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
🔇 Additional comments (243)
src/axolotl/monkeypatch/stablelm_attn_hijack_flash.py (1)

37-39: Standardized logging implementation with rank filtering.

The change replaces standard logging with the custom get_logger from axolotl's logging utility, which wraps loggers with a MultiProcessAdapter to control log emission in distributed environments.

src/axolotl/cli/config.py (1)

4-4: Updated to rank-aware logging implementation.

Replacing standard logging with get_logger ensures consistent logging behavior across the codebase, particularly in distributed training environments where limiting log output to rank 0 is beneficial.

Also applies to: 29-29

src/axolotl/cli/utils.py (1)

7-7: Standardized logging implementation for multi-rank environments.

This change aligns with the PR objective of reducing redundant logging output in distributed training by using the custom logging utility that manages log emission based on process rank.

Also applies to: 26-26

src/axolotl/utils/schemas/model.py (1)

3-3: Standardized logging implementation with rank-aware control.

The change follows the consistent pattern of replacing standard logging with the custom logging utility, ensuring the warning in hint_trust_remote_code will be properly managed in distributed environments.

Also applies to: 7-7

src/axolotl/utils/schemas/training.py (2)

3-3: Adopt custom logging utility
Replacing the standard logging import with get_logger aligns with the PR’s goal of centralized, multiprocess-aware logging.


12-12: Initialize module logger via get_logger
Using get_logger(__name__) ensures logs flow through the MultiProcessAdapter. Please verify that this adapter is configured to emit messages only on rank 0 in distributed training.

src/axolotl/utils/schemas/deprecated.py (2)

3-3: Switch to custom logger import
Importing get_logger replaces the standard logging import to standardize behavior across processes.


8-8: Instantiate module logger
LOG = get_logger(__name__) wraps the logger in MultiProcessAdapter. Confirm it suppresses non-rank-0 logs as intended for distributed runs.

src/axolotl/utils/schemas/integrations.py (2)

3-3: Use custom logging utility
Replacing standard logging with get_logger is consistent with the PR’s strategy for rank-aware logging.


8-8: Initialize logger via get_logger
Ensure that the returned MultiProcessAdapter filters logs to rank 0 by default in distributed scenarios.

src/axolotl/cli/inference.py (2)

4-4: Adopt centralized logger import
Switching to get_logger ensures CLI logs go through the multiprocess adapter for rank-0 filtering.


26-26: Instantiate CLI logger appropriately
LOG = get_logger(__name__) is correct; please verify MultiProcessAdapter suppresses non-rank-0 output during distributed inference.

src/axolotl/monkeypatch/peft/utils.py (2)

11-11: Replace standard logging import
Importing get_logger from axolotl.utils.logging follows the PR’s pattern for unified, multiprocess-aware logging.


13-13: Initialize patch utility logger
LOG = get_logger(__name__) correctly wraps the logger. Confirm that this adapter only emits on rank 0 when applying the PEFT patch in multi-GPU runs.

src/axolotl/prompt_strategies/metharme.py (1)

9-9: LOG initialization updated correctly.
Switching from logging.getLogger("axolotl") to get_logger(__name__) properly adopts the custom multiprocess-aware logger.

src/axolotl/monkeypatch/accelerate/fsdp2.py (2)

10-10: LOG initialization updated correctly.
Using get_logger(__name__) aligns this patch with the centralized logging configuration for distributed environments.


26-26: LOG usage for broadcasting message.
The informational message "Broadcasting full state dict to all ranks..." now goes through the custom logger. Assuming MultiProcessAdapter filters to rank 0, this meets the PR’s goal of reducing duplicate logs.

src/axolotl/cli/checks.py (1)

11-11: LOG initialization updated correctly.
Replacing logging.getLogger(__name__) with get_logger(__name__) ensures CLI-level logs are processed by the multiprocess-aware adapter.

src/axolotl/monkeypatch/transformers_fa_utils.py (1)

11-11: Logger initialization updated correctly.
Switching to get_logger(__name__) aligns this module with the project’s centralized logging strategy.

src/axolotl/monkeypatch/btlm_attn_hijack_flash.py (2)

6-6: Updated logging import to support rank-aware logging.

The change to import get_logger from the custom logging utility aligns with the PR's goal of reducing redundant logs in distributed training environments.


14-14: Logger initialization now uses module name for better context.

Changed from hardcoded logger name to using __name__, which provides better context about which module generated the log message.

src/axolotl/cli/evaluate.py (2)

3-3: Updated logging import to support rank-aware logging.

The change to import get_logger from the custom logging utility aligns with the PR's goal of reducing redundant logs in distributed training environments.


21-21: Logger initialization uses centralized logging utility.

Using the custom get_logger function ensures logs will now respect distributed training context, reducing duplicate logs from multiple ranks.

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

13-13: Updated logging import to support rank-aware logging.

The change to import get_logger from the custom logging utility aligns with the PR's goal of reducing redundant logs in distributed training environments.


17-17: Logger initialization uses centralized logging utility.

Using the custom get_logger function ensures logs will now respect distributed training context, reducing duplicate logs from multiple ranks.

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

13-13: Updated logging import to support rank-aware logging.

The change to import get_logger from the custom logging utility aligns with the PR's goal of reducing redundant logs in distributed training environments.


17-17: Logger initialization uses centralized logging utility.

Using the custom get_logger function ensures logs will now respect distributed training context, reducing duplicate logs from multiple ranks. This is particularly important in this multi-GPU test file where duplicate logs would otherwise occur.

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

16-16: Standardize logging import
Replaced the standard logging import with the centralized get_logger utility from axolotl.utils.logging to unify log configuration across processes.


20-20: Initialize distributed-aware logger
Instantiating LOG = get_logger("axolotl.tests.e2e") ensures only rank 0 emits these test logs in a multi-process run.

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

14-14: Standardize logging import
Good replacement of the standard logging import with get_logger for consistent, multi-process logging.


16-16: Initialize distributed-aware logger
Using LOG = get_logger("axolotl.tests.e2e.multigpu") aligns this test with the rank 0-only logging strategy.

src/axolotl/utils/comet_.py (1)

8-8: Use get_logger(__name__) for module logging
Switching to get_logger(__name__) ensures this module’s logs respect the global log level and the multi-process adapter.

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

14-14: Standardize logging import
Consistently replaced logging.getLogger with get_logger for improved distributed logging control.


18-18: Initialize distributed-aware logger
LOG = get_logger("axolotl.tests.e2e") ensures only the main process outputs these logs during test execution.

tests/e2e/test_packing_loss.py (2)

15-15: Standardize logging import
Good update to import get_logger instead of the standard logging module for uniform main-process logging.


19-19: Initialize distributed-aware logger
Using LOG = get_logger("axolotl.tests.e2e") aligns this test with the global rank 0 logging approach.

tests/e2e/test_schedulers.py (2)

13-13: Standardize logging import
Replaced the direct import of the logging module with get_logger from axolotl.utils.logging, aligning test files with the new custom logger API.


17-17: Initialize distributed-aware logger
Logger LOG is now created via get_logger("axolotl.tests.e2e"), ensuring multiprocess support and enabling future rank‐0-only filtering.

src/axolotl/monkeypatch/trainer/lr.py (1)

9-9: Switch to custom logger
Replaced logging.getLogger with get_logger(__name__) to leverage the MultiProcessAdapter and centralized log-level control.

tests/e2e/test_falcon.py (2)

15-15: Standardize logging import
Updated to import get_logger from axolotl.utils.logging instead of the standard logging module.


19-19: Initialize distributed-aware logger
Logger LOG now uses get_logger("axolotl.tests.e2e"), preparing for rank‐0-only log emission.

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

15-15: Standardize logging import
Replaced the standard logging import with get_logger from axolotl.utils.logging for uniform logging.


19-19: Initialize distributed-aware logger
Initialized LOG via get_logger("axolotl.tests.e2e") to support multiprocess and rank filtering.

tests/e2e/test_reward_model_smollm2.py (2)

13-13: Standardize logging import
Switched to importing get_logger from axolotl.utils.logging in place of the standard module.


17-17: Initialize distributed-aware logger
Logger LOG now obtained via get_logger("axolotl.tests.e2e"), aligning with the new logging framework.

src/axolotl/core/trainers/mixins/rng_state_loader.py (1)

20-20: Instantiate custom logger for multiprocess contexts

Switching from logging.getLogger to get_logger(__name__) is correct—this will wrap the logger in MultiProcessAdapter and respect distributed rank-0 logging.

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

13-13: Standardize to custom logging utility

Replacing the standard logging import with get_logger from axolotl.utils.logging aligns this test with the project's distributed logging approach.


17-17: Initialize test logger via get_logger

Good use of get_logger("axolotl.tests.e2e") to ensure logging honors rank-0-only behavior.

tests/e2e/test_mamba.py (2)

15-15: Switch to custom logging import

Using get_logger instead of the standard logging module is correct and necessary for consistent rank-0 logging in tests.


19-19: Instantiate the E2E test logger

LOG = get_logger("axolotl.tests.e2e") properly initializes the custom logger.

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

13-13: Adopt custom logger import

Replacing the standard logging import with get_logger is consistent with other tests and ensures proper multiprocess logging.


17-17: Initialize logger for rank-0-only output

Good update: LOG = get_logger("axolotl.tests.e2e") sets up the logger correctly.

src/axolotl/integrations/llm_compressor/plugin.py (1)

23-23: Instantiate plugin logger

Using LOG = get_logger(__name__) here is correct and ensures the plugin’s messages respect the multiprocess adapter’s rank-0-only logic.

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

14-14: Use custom logging utility
Replaced the standard logging import with get_logger to align with the project-wide logging strategy for multiprocess environments.


18-18: Initialize logger with MultiProcessAdapter
The LOG instantiation now leverages get_logger, ensuring log messages are emitted primarily from rank 0 in distributed runs.

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

23-23: Adopt custom logger
Switched to get_logger(__name__), wrapping the logger in MultiProcessAdapter for controlled log emission across processes.

tests/e2e/test_llama_vision.py (2)

13-13: Use project logger in tests
Replaced the standard Python logging import with get_logger for consistency across the test suite.


17-17: Initialize test logger with MultiProcessAdapter
LOG now uses get_logger("axolotl.tests.e2e"), ensuring logs are centralized to rank 0 when running distributed tests.

src/axolotl/cli/merge_lora.py (1)

17-17: Adopt custom logger
LOG now leverages get_logger(__name__) with MultiProcessAdapter to centralize logging to the main process in distributed setups.

tests/e2e/test_gemma3_text.py (2)

15-15: Use unified logging import
Switched from the standard logging module to get_logger for consistent, rank-aware logging in end-to-end tests.


17-17: Initialize test logger with MultiProcessAdapter
LOG is now created via get_logger("axolotl.tests.e2e"), ensuring only the main process emits logs.

tests/e2e/test_embeddings_lr.py (1)

13-13: Standardize to rank-aware logging
Replaced the standard logging import with the custom get_logger utility and initialized LOG via a MultiProcessAdapter for "axolotl.tests.e2e". This ensures only the rank 0 process emits logs, reducing redundant output in distributed tests.

Also applies to: 17-17

tests/e2e/test_gemma2.py (1)

15-15: Apply custom MultiProcessAdapter logger
Switched from the built-in logging to get_logger and created a LOG instance for "axolotl.tests.e2e". This leverages the MultiProcessAdapter to suppress duplicate logs from non-zero ranks.

Also applies to: 17-17

tests/e2e/test_llama.py (1)

12-12: Enable rank-0-only logging in Llama E2E tests
Imported get_logger and set up LOG = get_logger("axolotl.tests.e2e"), ensuring test logs are filtered through the MultiProcessAdapter so only the main process outputs messages.

Also applies to: 16-16

tests/e2e/test_lora_llama.py (1)

13-13: Integrate centralized rank-aware logger
Replaced standard logging with get_logger and instantiated LOG for "axolotl.tests.e2e", guaranteeing that only rank 0 emits test logs via the MultiProcessAdapter.

Also applies to: 17-17

tests/e2e/test_phi.py (1)

13-13: Switch to MultiProcessAdapter logger
Imported get_logger and initialized LOG with get_logger("axolotl.tests.e2e"), leveraging the adapter to limit log output to the primary rank and avoid redundant messages in distributed runs.

Also applies to: 17-17

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

15-19: Adopt custom get_logger for test logging
Replacing the standard logging import with get_logger ensures the test harness uses the centralized multi-process adapter and respects rank-0–only emission in distributed runs.

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

16-20: Consistent custom logger usage
Swapping out logging.getLogger for get_logger aligns this test with the project-wide logging refactor and enables rank-0-only logging in multiprocess environments.

tests/e2e/test_llama_pretrain.py (1)

14-18: Use centralized get_logger for this test
Updating the import and initialization to get_logger ensures uniform log handling and prevents duplicate outputs across ranks during pretraining tests.

tests/e2e/test_deepseekv3.py (1)

15-19: Switch to custom get_logger for DeepseekV3 tests
Replacing the standard logger with get_logger maintains consistency and activates the multi-process adapter, reducing redundant rank logs.

tests/e2e/test_optimizers.py (1)

13-17: Standardize logging via get_logger
Migrating from logging.getLogger to the get_logger utility brings this optimizer test in line with the project’s distributed logging strategy.

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

15-15: Consistent logging import
Replacing the standard logging import with the centralized get_logger ensures uniform logging behavior across distributed tests.


19-19: Initialize custom logger for distributed tests
Using get_logger here scopes logging to the main process (rank 0) in multi-GPU runs, reducing redundant output.

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

15-15: Consistent logging import
Switching from the standard logging module to the project's get_logger utility aligns this test with the centralized logging strategy.


19-19: Initialize custom logger in E2E tests
Instantiating the logger via get_logger("axolotl.tests.e2e") ensures logs are emitted only from the main process in distributed scenarios.

src/axolotl/train.py (1)

44-44: Initialize module-level logger
Using get_logger(__name__) scopes logs per module and leverages MultiProcessAdapter for main-process-only log emission in distributed training.

tests/e2e/test_dpo.py (2)

16-16: Consistent logging import
Replacing import logging with from axolotl.utils.logging import get_logger brings this test in line with the project's logging refactor.


20-20: Initialize custom logger for E2E tests
Creating the LOG via get_logger("axolotl.tests.e2e") ensures logs are restricted to rank 0, reducing duplicate output across processes.

src/axolotl/prompt_strategies/bradley_terry/__init__.py (1)

9-9: Initialize module-level logger
Using get_logger(__name__) here ensures prompt strategies logging respects the main-process-only policy in distributed setups.

src/axolotl/utils/data/pretraining.py (1)

4-4: LGTM: Good logging implementation change

The changes to replace standard logging with the custom get_logger function align with the PR objective of restricting logs to rank 0 in distributed environments, reducing redundant logging output during multi-GPU training.

Also applies to: 17-17

src/axolotl/prompt_strategies/__init__.py (1)

5-5: LGTM: Consistent logging implementation

The replacement of standard logging with the custom get_logger function matches the pattern used throughout the codebase and effectively implements rank 0-only logging.

Also applies to: 9-9

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

16-16: LGTM: Consistent logging approach in test file

The changes properly extend the rank 0-only logging pattern to test files, ensuring consistent behavior throughout the codebase.

Also applies to: 20-20

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

13-13: LGTM: Properly implements rank 0-only logging in tests

The changes correctly implement the same logging pattern as other files, helping to reduce redundant logs during test execution in multi-rank environments.

Also applies to: 17-17

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

17-17: Implementation of rank 0-only logging utility.

This change replaces the standard Python logging module with the custom axolotl logging utility, which supports controlling log output in multi-rank distributed training environments.


21-21: Switched to the custom logger initialization.

Properly updates the logger initialization to use the new get_logger function which wraps the standard logger with a MultiProcessAdapter, enabling rank-specific log filtering.

tests/e2e/multigpu/solo/test_flex.py (2)

16-16: Implementation of rank 0-only logging utility.

This change replaces the standard Python logging module with the custom axolotl logging utility, which supports controlling log output in multi-rank distributed training environments.


20-20: Switched to the custom logger initialization.

Properly updates the logger initialization to use the new get_logger function which wraps the standard logger with a MultiProcessAdapter, enabling rank-specific log filtering.

tests/e2e/test_mistral.py (2)

15-15: Implementation of rank 0-only logging utility.

This change replaces the standard Python logging module with the custom axolotl logging utility, which supports controlling log output in multi-rank distributed training environments.


19-19: Switched to the custom logger initialization.

Properly updates the logger initialization to use the new get_logger function which wraps the standard logger with a MultiProcessAdapter, enabling rank-specific log filtering.

src/axolotl/utils/callbacks/mlflow_.py (2)

3-3: Implementation of rank 0-only logging utility.

This change replaces the standard Python logging module with the custom axolotl logging utility, which supports controlling log output in multi-rank distributed training environments.


17-17: Improved logger initialization with dynamic name.

Enhances the logger initialization by:

  1. Using the get_logger function which wraps the standard logger with a MultiProcessAdapter
  2. Using __name__ instead of a hardcoded string, which improves maintainability

Note: The linter has automatically fixed import sorting issues in this file during the CI run.

tests/e2e/test_process_reward_model_smollm2.py (1)

13-17: Consistent migration to custom logger
The import of get_logger and the instantiation of LOG align with the project-wide switch to axolotl.utils.logging. Although this test doesn’t emit log messages directly, having the logger available ensures any future log calls will respect the multiprocess adapter.

tests/e2e/test_qwen.py (1)

14-17: Consistent migration to custom logger
The update from the standard logging module to get_logger and the creation of LOG here mirror similar changes across the e2e test suite. This ensures uniform logging configuration in distributed runs.

src/axolotl/cli/main.py (2)

32-36: Custom logger integration looks correct
Switching from the standard logging module to get_logger and initializing LOG at the module level aligns with the pattern used across other CLI modules.


181-181: Error logging now uses the custom logger
Replacing logging.error with LOG.error ensures that rank-0 only and multiprocess behavior is applied consistently during subprocess failures.

examples/llama-3/qlora-1b-kto.yaml (1)

43-44: Confirm training duration control update

Switching from num_epochs to max_steps changes how training length is defined. Please ensure downstream training loops and tooling support max_steps and that documentation/examples reflect this shift. Also verify consistency with other example configs.

src/axolotl/core/chat/messages.py (2)

12-15: Standardize logger initialization

Importing and initializing LOG = get_logger(__name__) aligns this module with the centralized logging utility. This change is correct and enables rank-0-only logging via MultiProcessAdapter.


163-163: Replace commented logging call with module logger

The commented-out LOG.warning correctly updates the reference to use the new LOG instance instead of the standard logging module. This maintains consistency even in commented code.

src/axolotl/integrations/spectrum/__init__.py (2)

24-29: Use centralized logger for SpectrumPlugin

Replacing standard logging with LOG = get_logger(__name__) standardizes log output and leverages rank-aware filtering.


88-99: Update warning calls to use custom logger

All warnings now correctly use LOG.warning to integrate with the custom logging pipeline and filtering. This change maintains identical semantics with added rank-based filtering.

src/axolotl/monkeypatch/unsloth_.py (3)

14-14: Good switch to dynamic logger name using __name__.

Using __name__ ensures the logger name accurately reflects the module's position in the package hierarchy, which improves log organization and debugging.


136-138: Appropriate logging style.

The multi-line format for the log message is clean and ensures consistent rank-0-only logging through the MultiProcessAdapter wrapper.


158-160: Consistent logging style.

This change maintains the same multi-line logging format used elsewhere, ensuring consistent rank-0-only logging behavior.

tests/e2e/test_mixtral.py (2)

16-16: Good update to custom logger import.

Replacing the standard logging import with the custom get_logger function aligns with the goal of standardizing rank-0-only logging throughout the codebase.


20-20: Proper logger initialization with custom adapter.

Using get_logger ensures the logger is wrapped with MultiProcessAdapter, which will properly control log emission in distributed environments.

examples/llama-3/lora-1b.yml (2)

8-8: Removed unnecessary empty line.

This is a minor formatting improvement that doesn't affect functionality.


42-43: Good addition of explicit optimizer and scheduler settings.

Adding explicit configuration for optimizer and lr_scheduler improves clarity and transparency of the training settings.

src/axolotl/prompt_strategies/messages/__init__.py (2)

5-5: Good update to custom logger import.

Replacing the standard logging import with the custom get_logger function aligns with the goal of standardizing rank-0-only logging throughout the codebase.


7-7:

✅ Verification successful

Proper logger initialization with custom adapter.

Using get_logger(__name__) ensures the logger name accurately reflects the module's structure and will properly control log emission in distributed environments via the MultiProcessAdapter.


🏁 Script executed:

#!/bin/bash
# Verify that the MultiProcessAdapter checks process rank before logging

# Check the implementation of MultiProcessAdapter in logging.py
rg -A 15 "class MultiProcessAdapter" src/axolotl/utils/logging.py

Length of output: 594


Logger initialization verified

I’ve confirmed that MultiProcessAdapter’s log method properly checks is_main_process(use_environ=False) before emitting logs, so using get_logger(__name__) here correctly names the logger and enforces main‐process-only logging. No further changes needed.

src/axolotl/utils/callbacks/lisa.py (2)

9-9: Good standardization of logging imports.

This change helps unify the logging approach across the codebase, moving from standard Python logging to the custom axolotl logger.


19-19: Good implementation of the rank 0-only logging pattern.

Replacing the standard logger with the custom get_logger(__name__) ensures that logging is properly controlled in distributed training environments, reducing redundant outputs from multiple ranks.

src/axolotl/utils/gradient_checkpointing/offload_disk.py (2)

34-35: Good standardization of logging imports.

This change helps unify the logging approach across the codebase, moving from standard Python logging to the custom axolotl logger.


40-40: Good implementation of the rank 0-only logging pattern.

Switching to the custom get_logger(__name__) ensures that logging is properly controlled in distributed training environments, which is particularly important in this file as it handles disk operations that could generate redundant log messages across ranks.

src/axolotl/monkeypatch/llama_attn_hijack_xformers.py (2)

13-15: Good standardization of logging imports.

This change helps unify the logging approach across the codebase, moving from standard Python logging to the custom axolotl logger.


20-20: Good implementation of rank 0-only error reporting.

Using the custom logger for error reporting ensures that when xformers is not found, the error message will only be logged from rank 0 in a distributed environment, preventing duplicate error messages.

src/axolotl/utils/callbacks/comet_.py (2)

3-3: Good standardization of logging imports.

This change helps unify the logging approach across the codebase, moving from standard Python logging to the custom axolotl logger.


14-14: Good implementation of the rank 0-only logging pattern.

Replacing the standard logger with the custom get_logger(__name__) ensures that logging is properly controlled in distributed training environments, reducing redundant outputs from multiple ranks. This is especially important for Comet callbacks that might otherwise generate duplicate telemetry.

tests/prompt_strategies/test_chat_templates_advanced.py (1)

20-20: Standardize logging with custom logger
Replaces direct Python logging import and configuration with the centralized get_logger utility, ensuring consistent log handling (including rank-0 filtering) across test suites.

Also applies to: 24-24

src/axolotl/core/trainers/grpo/__init__.py (1)

6-6: Integrate custom logger for GRPO strategy
Imports get_logger and initializes LOG to unify logging behavior and support main-process-only emission in distributed training.

Also applies to: 18-18

tests/prompt_strategies/test_chat_templates_thinking.py (1)

15-15: Adopt centralized logging utility
Replaces built-in logging setup with get_logger from axolotl.utils.logging, aligning this test with the project-wide logging strategy.

Also applies to: 17-17

tests/prompt_strategies/test_chat_templates.py (1)

16-16: Switch to project logger
Imports get_logger and initializes LOG for consistent, rank-aware logging across the test module.

Also applies to: 18-18

src/axolotl/integrations/base.py (2)

30-33: Initialize module logger via get_logger
Adds get_logger import and creates LOG for unified, main-process logging in distributed setups.


351-357: Use LOG for plugin load messages
Replaces logging calls with LOG.info/LOG.error to centralize message emission. No changes to logic or error handling.

src/axolotl/cli/preprocess.py (4)

3-3: Consistent use of custom logger
Replacing the standard logging import with get_logger from axolotl.utils.logging is correct and aligns with the project-wide refactor.


25-25: Logger initialization updated
Initializing LOG with get_logger(__name__) is a good practice—using module names improves traceability.


42-46: String concatenation formatting is consistent
The multi-line concatenation for the warning message is clear and equivalent to the previous logic. Consider an f-string with embedded color codes for brevity, but this is acceptable.


76-79: Info message formatting is consistent
The consolidated log message with color codes is formatted correctly and unchanged in behavior.

src/axolotl/monkeypatch/lora_kernels.py (2)

21-23: Switched to custom logging utility
Importing get_logger from axolotl.utils.logging and initializing LOG = get_logger(__name__) aligns with the unified logging approach.


320-321: Log level set with string constant
Changing .setLevel(logging.INFO) to .setLevel("INFO") works with Python’s _checkLevel handling strings and matches the custom logger’s API.

src/axolotl/utils/trainer.py (5)

25-25: Logger now uses module name
Switching from a static logger name to get_logger(__name__) improves granularity.


405-407: Removed main_process_only—verify behavior
Omitting the main_process_only argument relies on the custom adapter to enforce rank-0 logging. Please confirm that duplicate debug messages from non-zero ranks are suppressed.


451-453: Removed main_process_only—verify behavior
Ensure the centralized logging adapter still filters out non-rank-0 logs for this debug statement.


481-483: Removed main_process_only—verify behavior
Double-check that debug output remains unique to rank 0 after removing the argument.


517-519: Removed main_process_only—verify behavior
Confirm this final debug log is emitted only once across all processes.

tests/integrations/test_liger.py (2)

47-49: Caplog level string is valid
Using "WARNING" for caplog.set_level is consistent with the custom logging API and pytest; no issues detected.


58-61: Caplog context-level string
Switching to "WARNING" in caplog.at_level is appropriate and aligns with the revised logging constants.

src/axolotl/utils/data/utils.py (5)

14-18: Custom logger import and init
Replacing standard imports with get_logger(__name__) correctly standardizes logging across data utilities.


163-165: Warning on missing column preserved
The LOG.warning call for missing input_ids is unchanged in logic and correctly informs the user.


176-179: Logging minimum input length
The multi-line LOG.info for min_input_len is clear and functionally equivalent to previous one-liner.


180-183: Logging maximum input length
The new formatting for max_input_len remains accurate and readable.


210-213: Warning on dropped samples
The warning message after filtering long sequences is correctly retained with consistent formatting.

src/axolotl/integrations/liger/__init__.py (4)

24-31: Appropriate change to support rank 0-only logging

The change from standard Python logging to the custom get_logger utility is appropriate for implementing rank 0-only logging. This modification will help reduce redundant log messages across different ranks in multi-GPU training.


127-127: Standardized logging implementation

Updated warning message to use the centralized logging approach, ensuring it will only be emitted from the main process in distributed training.


129-129: Standardized logging implementation

Updated warning message to use the centralized logging approach, ensuring it will only be emitted from the main process in distributed training.


179-181: Standardized logging implementation

Updated warning message to use the centralized logging approach, ensuring it will only be emitted from the main process in distributed training.

src/axolotl/prompt_strategies/pygmalion.py (3)

3-5: Appropriate change to support rank 0-only logging

The import of get_logger from the custom logging utility will help implement rank 0-only logging, reducing duplicate logs in multi-GPU environments.


14-14: Standardized logging implementation

Replaced standard logging with the custom logger that supports rank-aware logging.


67-67: Fixed style issue in slice notation

Removed unnecessary space in the slice notation [len(self.bot_prefix_token_ids):], improving code style consistency.

src/axolotl/prompters.py (4)

3-3: Appropriate change to support rank 0-only logging

The import of get_logger from the custom logging utility will help implement rank 0-only logging, reducing duplicate logs in multi-GPU environments.


9-9: Standardized logging implementation

Replaced standard logging with the custom logger that supports rank-aware logging.


196-198: Improved string concatenation style

String concatenation style has been adjusted for better readability, moving operators to the end of lines rather than beginning of the next line.


200-202: Improved string concatenation style

String concatenation style has been adjusted for better readability, moving operators to the end of lines rather than beginning of the next line.

src/axolotl/core/trainer_builder.py (5)

22-22: Appropriate change to support rank 0-only logging

The import of get_logger from the custom logging utility will help implement rank 0-only logging, reducing duplicate logs in multi-GPU environments.


97-97: Standardized logging implementation

Replaced standard logging with the custom logger that supports rank-aware logging.


249-251: Improved boolean expression formatting

Reformatted multi-line boolean expression to use inline conjunction with the and operator, improving readability while maintaining the same logic.


267-270: Improved boolean expression formatting

Reformatted multi-line boolean expression to use inline conjunction with the and operator, improving readability while maintaining the same logic.


530-539: Improved boolean expression formatting

Reformatted complex multi-line boolean expression to use inline conjunctions with the and operator, improving readability while maintaining the same logic.

src/axolotl/monkeypatch/trainer_fsdp_optim.py (1)

12-12: Use custom MultiProcessAdapter logger.
Initializing the module‐level logger with LOG = get_logger(__name__) ensures consistent log configuration and multi‐process safety.

src/axolotl/utils/chat_templates.py (2)

12-12: Initialize module logger correctly.
Using LOG = get_logger("axolotl.utils.chat_templates") aligns with the custom logging utility and ensures consistent log level handling across modules.


95-97: Remove extra whitespace in slice expression.
The updated slicing syntax tightens up the code by removing an unnecessary space before the colon. This is purely stylistic and improves readability.

tests/patched/test_validation.py (2)

22-22: Use custom MultiProcessAdapter logger.
Initializing LOG = get_logger(__name__) ensures tests leverage the same multi‐process logging adapter as the application code.


85-85: Use string literal for caplog level.
caplog.at_level("WARNING") is valid and consistent with the project’s use of string log levels.

src/axolotl/monkeypatch/trainer_eval_guard.py (1)

12-12: Initialize module logger for multi-process scenarios.
LOG = get_logger(__name__) correctly wraps the logger with MultiProcessAdapter.

src/axolotl/core/trainers/mixins/scheduler.py (7)

17-17: Consistent logger initialization.
Using LOG = get_logger(__name__) ensures the scheduler mixin logs through the centralized, multi-process-aware adapter.


39-40: Approve multi-line boolean expression formatting.
Breaking the cosine check into separate lines within parentheses enhances readability without changing logic.


44-45: Approve multi-line boolean expression formatting.
The cosine_min_lr condition split into two lines is clear and maintains original behavior.


83-84: Approve conditional min_lr assignment formatting.
The multi-line inline if expression is a concise way to handle min_lr and is clear in intent.


90-91: Approve structured warning message.
Using a parenthesized multi-line LOG.warning call improves readability; the message remains unchanged.


120-121: Approve structured warning message.
The warning in the else branch is correctly formatted and retains original semantics.


124-125: Approve structured warning message.
The third LOG.warning is properly parenthesized and maintains the previous logic path.

src/axolotl/utils/schemas/utils.py (3)

3-5: Great job standardizing the logging mechanism!

Switching to get_logger from axolotl.utils.logging aligns with the PR objective to reduce redundant logging in multi-rank environments. The custom logger will control log emission to only show messages from rank 0 in distributed training.


43-44: Clean code formatting improvement.

Good job consolidating the conditional expression from multiple lines into a single line. This improves readability while maintaining the same logic.


63-65: Clean code formatting improvement.

Well done consolidating this multi-line conditional into a single line, which improves readability while maintaining the same logic.

src/axolotl/monkeypatch/trainer_accelerator_args.py (2)

6-6: Great job standardizing the logging mechanism!

Switching to get_logger from axolotl.utils.logging aligns with the PR objective to reduce redundant logging in multi-rank environments. The custom logger will control log emission to only show messages from rank 0 in distributed training.

Also applies to: 12-12


73-75: Clean code formatting improvement.

Nice job consolidating the string concatenation into a single line. This improves readability while maintaining the same functionality.

src/axolotl/datasets.py (2)

3-3: Great job standardizing the logging mechanism!

Switching to get_logger from axolotl.utils.logging aligns with the PR objective to reduce redundant logging in multi-rank environments. The custom logger will control log emission to only show messages from rank 0 in distributed training.

Note that the logger name has changed from a hardcoded "axolotl" to __name__, which will provide more specific logger names based on the module. This is a good improvement for log filtering and debugging.

Also applies to: 18-18


57-59: Clean code formatting improvement.

Good job consolidating the conditional expression from multiple lines into a single line. This improves readability while maintaining the same logic.

src/axolotl/prompt_tokenizers.py (4)

4-4: Great job standardizing the logging mechanism!

Switching to get_logger from axolotl.utils.logging aligns with the PR objective to reduce redundant logging in multi-rank environments. The custom logger will control log emission to only show messages from rank 0 in distributed training.

Note that the logger name has changed from a hardcoded "axolotl" to __name__, which will provide more specific logger names based on the module. This is a good improvement for log filtering and debugging.

Also applies to: 11-11


82-85: Clean code formatting improvement.

Good job consolidating the conditional expression from multiple lines into a single line. This improves readability while maintaining the same logic.


303-306: Clean code formatting improvement.

Good job consolidating the conditional expression from multiple lines into a single line. This improves readability while maintaining the same logic.


356-360: Clean code formatting improvement.

Good job removing spaces around the colon in slice notation. This aligns with typical Python style conventions (PEP 8) and improves readability.

tests/prompt_strategies/messages/test_chat.py (2)

1-1: LGTM! The updated docstring is clearer and more general.

The updated docstring better describes the module's purpose of testing chat message internals more broadly.


18-20: LGTM! Updated to use the custom logger.

This change aligns with the standardization of logging throughout the codebase to support rank 0-only logging in distributed environments.

src/axolotl/prompt_strategies/chat_template.py (3)

15-15: LGTM! Updated import to use custom logger.

This change replaces the standard Python logging with the custom logger from axolotl.utils.logging.


19-20: LGTM! Updated logger initialization.

This change initializes the logger with the module name and sets the level using the string "INFO", which is consistent with the custom logging utility implementation.


381-383: LGTM! Improved code formatting.

The restructured multi-line function call improves readability without changing functionality.

src/axolotl/core/trainers/mixins/optimizer.py (4)

3-3: LGTM! Updated import to use custom logger.

This change replaces the standard Python logging with the custom logger from axolotl.utils.logging.


15-15: LGTM! Updated logger initialization.

This change initializes the logger with the module name, which is consistent with the custom logging utility implementation.


110-115: LGTM! Improved conditional formatting.

The reformatting of the conditional expression improves readability while maintaining the same logic.


121-124: LGTM! Improved conditional formatting.

The reformatting of the conditional expression improves readability while maintaining the same logic.

src/axolotl/utils/distributed.py (1)

83-87: LGTM! Improved control flow in is_main_process.

The updated control flow now first checks if distributed mode is initialized before checking the environment variable. This ensures that environment variable checks only occur in distributed mode, making the function more robust.

In non-distributed mode, the function now always returns True, regardless of the use_environ flag, which is the correct behavior since there's only one process.

tests/prompt_strategies/test_jinja_template_analyzer.py (1)

11-13: LGTM! Good logging approach.

The change to use the custom get_logger function instead of the standard logging module aligns with the PR's goal to standardize logging and support rank 0-only logging in distributed environments.

tests/test_prompt_tokenizers.py (2)

17-18: LGTM! Good logging approach.

The change to use the custom get_logger function is consistent with the PR's goal of standardizing logging across the codebase to support rank 0-only logging in distributed environments.


59-59: LGTM! Good test decorator update.

Replacing custom decorators with standard pytest markers improves code clarity and maintainability.

Also applies to: 81-81, 107-107, 137-137, 211-211

src/axolotl/common/datasets.py (3)

3-3: LGTM! Good logging approach.

The change to use the custom get_logger function aligns with the PR's goal of standardizing logging across the codebase to support rank 0-only logging in distributed environments.

Also applies to: 20-20


70-74: LGTM! Improved readability.

Breaking the complex boolean expression into multiple lines with explicit and operators improves code readability.


83-88: LGTM! Simplified conditional check.

Simplifying the debug logging conditional check to only check for cli_args and its debug-related attributes makes the code cleaner and clearer. This change aligns with the PR's goal to reduce logging in distributed environments.

src/axolotl/monkeypatch/relora.py (4)

5-5: LGTM! Good logging approach.

The change to use the custom get_logger function aligns with the PR's goal of standardizing logging across the codebase to support rank 0-only logging in distributed environments.

Also applies to: 31-31


197-199: LGTM! Improved readability.

Breaking the complex condition into multiple lines with explicit and operators improves code readability without changing the logic.


330-332: LGTM! Improved readability.

Moving the multiplication operator to a separate line improves code readability without changing the operation's logic.


444-446: LGTM! Improved readability.

Breaking the string concatenation across multiple lines improves code readability without changing the logic.

src/axolotl/utils/data/rl.py (4)

4-4: The logging import change improves log handling in distributed training.

This change replaces the standard Python logging module with Axolotl's custom logger, supporting the PR's goal of reducing redundant output from multiple ranks.


23-23: Updated logger initialization to use the custom logger.

The logger is now created using get_logger instead of logging.getLogger, consistent with the distributed logging strategy.


43-45: Improved code style by reformatting conditional expressions.

The previously multi-line conditional was reformatted to a more concise single-line style with and operators, maintaining the same logic while improving readability.


214-220: Improved string concatenation formatting.

String concatenation was reformatted to use line-ending + operators, improving readability while maintaining the same functionality.

Also applies to: 223-229

src/axolotl/utils/data/sft.py (3)

56-56: Standardized logging implementation.

Replaced standard logging with Axolotl's custom logging implementation, which will filter logs based on process rank in distributed environments.

Also applies to: 62-62


170-172: Improved log message formatting consistency.

Log messages have been reformatted to use a consistent multi-line style with trailing commas, improving code readability and maintainability.

Also applies to: 190-191, 264-265, 268-269, 273-274, 280-282, 284-285, 294-296, 350-351, 356-358, 361-363, 372-374


452-453: Simplified seed usage in fingerprint generation.

Directly using cfg.seed or 42 instead of a separate variable eliminates unnecessary variable assignment while maintaining the same behavior.

Also applies to: 461-462

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

7-7: Updated to use rank-aware logging.

Replaced standard logging with Axolotl's custom logger to support rank-filtered logging in distributed environments.

Also applies to: 53-53


89-92: Improved boolean expression formatting.

Multi-line boolean expressions were reformatted to use a single line with explicit and operators, improving code readability while maintaining the same logic.

Also applies to: 168-170, 180-182


511-512: Standardized slice notation.

Removed spaces in slice expressions from start : end to start:end format for consistent style throughout the codebase.

Also applies to: 683-684, 699-700, 727-728


756-758: Reformatted WandB logging call.

Multi-line WandB logging call with added type ignore comment to handle any type checking issues.

src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (4)

5-5: Updated to use rank-aware logging.

Replaced standard logging with Axolotl's custom logger to support rank-filtered logging in distributed environments.

Also applies to: 32-32


168-170: Improved boolean expression readability.

Multi-line boolean expressions were reformatted to use a single line with explicit and operators, improving code readability while maintaining the same logic.

Also applies to: 180-182

🧰 Tools
🪛 Ruff (0.11.9)

168-168: Do not call getattr with a constant attribute value. It is not any safer than normal property access.

Replace getattr with attribute access

(B009)


251-251: Standardized slice notation.

Removed spaces in slice expressions from start : end to start:end format for consistent style throughout the codebase.

Also applies to: 296-296


362-364: Reformatted lambda functions as regular function definitions.

Changed lambda functions to use the same formatting style as seen in other parts of the codebase while maintaining the same functionality.

Also applies to: 377-379

update_logging.py (1)

1-107: New utility script to automate logging standardization.

This script efficiently automates the migration of test files to use the standardized logging approach, supporting the PR's goal of consistent rank-aware logging throughout the codebase.

🧰 Tools
🪛 Ruff (0.11.9)

9-9: pathlib.Path imported but unused

Remove unused import: pathlib.Path

(F401)


86-89: Use ternary operator base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests" instead of if-else-block

Replace if-else-block with base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests"

(SIM108)

🪛 GitHub Actions: lint

[warning] 9-56: pylint warnings: multiple redefined-outer-name warnings for variables 'dry_run', 'base_dir', 'updated_files', 'skipped_files', 'file'; too many nested blocks (6/5); invalid constant name 'base_dir'; unused import 'Path'; and duplicate code detected with tests.prompt_strategies.messages.test_chat and tests.prompt_strategies.test_chat_templates.

src/axolotl/utils/logging.py (1)

1-42: Well-structured logging utility for distributed training environments.

This is a well-designed logging utility that addresses the issue of redundant logs in multi-rank distributed training. The MultiProcessAdapter class provides a clean way to restrict log messages to only rank 0 by default, with the flexibility to override this behavior when needed.

A few observations:

  • The implementation correctly uses is_main_process() to determine when to emit logs
  • The default main_process_only=True effectively reduces duplicate logs in distributed setups
  • The utility properly respects log levels and provides configuration through environment variables

This implementation will significantly clean up console output during multi-GPU training runs by preventing identical messages from being repeated across ranks.

🧰 Tools
🪛 Ruff (0.11.9)

28-29: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

src/axolotl/utils/models.py (10)

75-76: Replaced standard logging with rank-aware custom logger.

The custom logger will ensure this import is only logged from the main process, reducing redundant output in multi-GPU training environments.


141-143: Improved debug logging for image size configuration.

The debug message for image size loading from model config will now only be emitted from rank 0, eliminating duplicate messages across ranks.


461-469: Restricted tokenizer debug information to main process.

These tokenizer debug messages about token IDs will now only be logged from the main process, which is a significant improvement for readability in distributed environments. Previously, each process would log identical tokenizer information, creating cluttered output.


526-528: Reduced redundant logs for processor configuration.

Debug messages about loading image sizes from the processor are now controlled by the rank-aware logger, which will prevent duplicate logging across multiple processes.


769-772: Streamlined flash attention logging.

The info log about patching with flash attention for sample packing will now only appear once in multi-GPU environments, improving log readability.


778-780: Cleaned up shifted-sparse attention logging.

The info log about patching with flash-enabled, shifted-sparse attention is now restricted to the main process only, reducing console clutter in distributed training.


798-800: Controlled xformers attention logging.

The info log about patching with xformers attention will now only be emitted from rank 0, improving log clarity in multi-GPU scenarios.


807-809: Optimized multipack preparation logging.

The log message about patching the LLaMA attention mask for multipack processing will now only appear once in distributed environments.


1103-1105: Reduced duplicate logs for SwiGLU patching.

The debug message about patching with SwiGLU will now only be logged by the main process, eliminating redundant messages in distributed training.


1109-1111: Centralized fused QKV logging.

The log message about patching with fused QKV will now be limited to rank 0, reducing duplicate logs in multi-GPU environments.

src/axolotl/core/trainers/base.py (5)

7-7: Replaced standard logging with rank-aware custom logger.

This change integrates the new custom logger that will restrict log messages to rank 0 in distributed environments, improving log readability during multi-GPU training.


40-40: Initialized logger with the custom rank-aware implementation.

Using get_logger(__name__) instead of logging.getLogger(__name__) will ensure logs are properly filtered in distributed training environments.


234-236: Improved boolean expression readability.

The multi-line condition for sample packing has been reformatted with line breaks after operators, making it more readable while maintaining the same logic.


291-295: Reformatted conditional expression for clarity.

The boolean expression for checking if multipacking or sequence parallelism is enabled has been restructured with better line breaks and indentation, improving readability.


563-565: Improved boolean expression formatting.

The condition for checking limit_all_gathers in FSDP config has been reformatted with line breaks after operators for better readability.

🧰 Tools
🪛 Ruff (0.11.9)

561-565: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

src/axolotl/utils/config/__init__.py (9)

4-4: Replaced standard logging with rank-aware custom logger.

This change integrates the new custom logger that will restrict log messages to rank 0 in distributed environments.


23-23: Initialized logger with the custom rank-aware implementation.

Using get_logger(__name__) instead of logging.getLogger(__name__) will ensure logs are properly filtered in distributed training.


161-170: Improved boolean expression readability.

The multi-line condition for determining if a model is multimodal has been reformatted with better operator placement, improving readability while maintaining the same logic.


180-187: Enhanced boolean expression formatting for LLaMA model detection.

The condition for checking if a model is LLaMA-derived has been restructured with clearer operator placement and indentation.


190-203: Improved readability of Falcon model detection logic.

The boolean expression for checking if a model is Falcon-derived has been reformatted with better operator placement for improved clarity.


205-216: Enhanced Mistral model detection condition formatting.

The condition for identifying Mistral-derived models has been restructured with better operator placement and indentation.


218-224: Improved Qwen model detection logic formatting.

The boolean expression for identifying Qwen-derived models has been reformatted for better readability.


229-235: Consolidated multi-line condition into a single expression.

The condition for gradient checkpointing has been reformatted with all conditions on a single line using the and operator, making it more concise.


249-251: Improved chat template condition readability.

The multi-line condition for checking dataset type and chat template has been consolidated with a clearer operator placement.

src/axolotl/utils/samplers/multipack.py (1)

82-85: Numba advanced indexing may fall back to object mode

np.argsort(sequence_lengths)[::-1] with subsequent advanced indexing
(sequence_lengths[indices]) is not supported in Numba nopython mode for all dtypes and can silently drop to object mode, losing the performance benefit.

If you observe a compilation warning like NumbaWarning: Falling back to object mode, consider pre-sorting outside the @njit function or using in-place selection sort inside the JIT to keep nopython compliance.

Comment on lines 47 to 50
# type: ignore[attr-defined]
grpo_args_kwargs["vllm_server_host"] = trl.vllm_server_host or trl.vllm.host
# type: ignore[attr-defined]
grpo_args_kwargs["vllm_server_port"] = trl.vllm_server_port or trl.vllm.port
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Address missing vllm attributes in TRLConfig
The # type: ignore[attr-defined] comments hide the root cause: TRLConfig lacks a vllm field, leading to the mypy error TRLConfig has no attribute 'vllm'. To fix:

  • Update the TRLConfig schema to include a vllm object with host, port, etc., or
  • Add runtime guards before accessing trl.vllm_*.

This change is critical to restore type safety and prevent silent failures.

🧰 Tools
🪛 GitHub Actions: lint

[error] 48-50: mypy error: 'TRLConfig' has no attribute 'vllm'.

🤖 Prompt for AI Agents
In src/axolotl/core/trainers/grpo/__init__.py around lines 47 to 50, the code
accesses attributes on trl.vllm which are missing from the TRLConfig type
definition, causing mypy errors. To fix this, update the TRLConfig schema to
include a vllm object with the necessary fields like host and port, ensuring
type safety. Alternatively, add runtime checks to confirm these attributes exist
on trl before accessing them, preventing attribute errors and preserving type
correctness.

Comment on lines 7 to 10
from axolotl.prompt_strategies.jinja_template_analyzer import (
PromptComponentStatus,
PromptTemplateAnalyzer,
)
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Fix incorrect imports causing build failures.

The pipeline is failing because it can't find PromptComponentStatus and PromptTemplateAnalyzer in the specified module. Check if these classes exist or if their names have changed.


🏁 Script executed:

#!/bin/bash
# Verify if these classes exist in the module
rg -A 1 "class PromptComponentStatus|class PromptTemplateAnalyzer" src/axolotl/prompt_strategies/

Length of output: 99


🏁 Script executed:

#!/bin/bash
# Locate the jinja_template_analyzer file
fd jinja_template_analyzer.py

# List all class definitions in that file
rg -n "^class " src/axolotl/prompt_strategies/jinja_template_analyzer.py

# Search for the specific class names across the entire repo
rg -n "PromptComponentStatus" .
rg -n "PromptTemplateAnalyzer" .

Length of output: 988


Update test imports to match refactored class names

The tests are importing classes that no longer exist in jinja_template_analyzer.py. You need to update the imports and usages in tests/prompt_strategies/test_jinja_template_analyzer.py:

• At the top of the file (lines 7–10), replace:

-from axolotl.prompt_strategies.jinja_template_analyzer import (
-    PromptComponentStatus,
-    PromptTemplateAnalyzer,
-)
+from axolotl.prompt_strategies.jinja_template_analyzer import (
+    JinjaTemplateAnalysis,
+    JinjaTemplateAnalyzer,
+)

• Throughout the test, rename all occurrences of PromptComponentStatusJinjaTemplateAnalysis and PromptTemplateAnalyzerJinjaTemplateAnalyzer.

This will align the tests with the current class definitions in src/axolotl/prompt_strategies/jinja_template_analyzer.py.

📝 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
from axolotl.prompt_strategies.jinja_template_analyzer import (
PromptComponentStatus,
PromptTemplateAnalyzer,
)
from axolotl.prompt_strategies.jinja_template_analyzer import (
JinjaTemplateAnalysis,
JinjaTemplateAnalyzer,
)
🧰 Tools
🪛 Ruff (0.11.9)

8-8: axolotl.prompt_strategies.jinja_template_analyzer.PromptComponentStatus imported but unused

Remove unused import: axolotl.prompt_strategies.jinja_template_analyzer.PromptComponentStatus

(F401)

🪛 GitHub Actions: lint

[error] 7-7: flake8 E0611: No name 'PromptComponentStatus' and 'PromptTemplateAnalyzer' in module 'axolotl.prompt_strategies.jinja_template_analyzer'.

🤖 Prompt for AI Agents
In tests/prompt_strategies/test_jinja_template_analyzer.py around lines 7 to 10,
the imports for PromptComponentStatus and PromptTemplateAnalyzer are incorrect
due to refactoring. Replace these imports with JinjaTemplateAnalysis and
JinjaTemplateAnalyzer respectively, and update all occurrences of
PromptComponentStatus to JinjaTemplateAnalysis and PromptTemplateAnalyzer to
JinjaTemplateAnalyzer throughout the test file to match the current class names
in the source module.

Comment on lines 3 to 16
import unittest

from axolotl.prompt_strategies.alpaca_chat import NoSystemPrompter
from axolotl.prompt_strategies.alpaca_w_system import (
InstructionWSystemPromptTokenizingStrategy,
SystemDataPrompter,
)
from axolotl.prompt_strategies.llama2_chat import (
Llama2ChatPrompter,
LLama2ChatTokenizingStrategy,
)
from axolotl.prompt_strategies.orpo.chat_template import load
from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
from axolotl.prompters import AlpacaPrompter, PromptStyle
from axolotl.utils.dict import DictDefault
import pytest
from transformers import AutoTokenizer

from tests.hf_offline_utils import enable_hf_offline
from axolotl.prompt_strategies.alpaca import AlpacaPrompter
from axolotl.prompt_tokenizers import (
AlpacaPromptTokenizingStrategy,
InstructionPromptTokenizingStrategy,
PromptTokenizingStrategy,
ShareGPTPromptTokenizingStrategy,
)
from axolotl.prompters import AlpacaInstructionPrompter, PromptStyle, ShareGPTPrompter
from axolotl.utils.logging import get_logger
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Fix multiple unused imports.

Several imported modules are not being used in this file, causing linting errors:

  • unittest
  • transformers.AutoTokenizer
  • Multiple unused imports from axolotl.prompt_tokenizers and axolotl.prompters

Additionally, the pipeline failures indicate that some of these imports refer to undefined names, suggesting a mismatch between imports and the actual module contents.


🏁 Script executed:

#!/bin/bash
# Check for undefined names in imports
grep -r "class ShareGPTPromptTokenizingStrategy\|class AlpacaInstructionPrompter\|class ShareGPTPrompter" src/axolotl/

Length of output: 120


🏁 Script executed:

#!/bin/bash
# Display the content of the test file to verify which imports are actually used
sed -n '1,200p' tests/test_prompt_tokenizers.py

Length of output: 7225


🏁 Script executed:

#!/bin/bash
# List all PromptTokenizingStrategy classes in the prompt_tokenizers module
grep -R "class .*PromptTokenizingStrategy" src/axolotl/prompt_tokenizers

# Check for InstructionWSystemPromptTokenizingStrategy
grep -R "InstructionWSystemPromptTokenizingStrategy" -R src/axolotl

# Check for Llama2ChatTokenizingStrategy (case-insensitive for double L)
grep -R "Llama2ChatTokenizingStrategy" -R src/axolotl || true
grep -R "LLama2ChatTokenizingStrategy" -R src/axolotl || true

Length of output: 1311


🏁 Script executed:

#!/bin/bash
# Locate and inspect the prompt_tokenizers module
file=$(find src/axolotl -type f -name "prompt_tokenizers.py" -print)
echo "Module file: $file"
if [[ -n "$file" ]]; then
  echo "----- Begin prompt_tokenizers.py -----"
  sed -n '1,200p' "$file"
  echo "----- End prompt_tokenizers.py -----"
else
  echo "prompt_tokenizers.py not found"
fi

Length of output: 6487


Refactor imports in tests/test_prompt_tokenizers.py

Several imports at the top of tests/test_prompt_tokenizers.py are either unused or refer to classes that don’t exist in the modules you’re importing from. At the same time, some of the classes and modules actually used in the tests are never imported. Please update the import block as follows:

• Remove unused/undefined imports:

  • unittest
  • transformers.AutoTokenizer
  • InstructionPromptTokenizingStrategy, PromptTokenizingStrategy, ShareGPTPromptTokenizingStrategy (they’re not in axolotl.prompt_tokenizers)
  • AlpacaInstructionPrompter, ShareGPTPrompter (never referenced in tests)

• Keep these existing imports:

  • pytest
  • get_logger (for LOG = get_logger(…))
  • PromptStyle (used in TestInstructionWSystemPromptTokenizingStrategy)

• Add missing imports for classes actually used in the tests:

  • NoSystemPrompter
  • SystemDataPrompter, InstructionWSystemPromptTokenizingStrategy
  • Llama2ChatPrompter, LLama2ChatTokenizingStrategy
  • Built-in modules: json, Path

Here’s a suggested diff for the top of your test file:

- import unittest
- import pytest
- from transformers import AutoTokenizer

- from axolotl.prompt_strategies.alpaca import AlpacaPrompter
- from axolotl.prompt_tokenizers import (
-     AlpacaPromptTokenizingStrategy,
-     InstructionPromptTokenizingStrategy,
-     PromptTokenizingStrategy,
-     ShareGPTPromptTokenizingStrategy,
- )
- from axolotl.prompters import AlpacaInstructionPrompter, PromptStyle, ShareGPTPrompter
- from axolotl.utils.logging import get_logger
+ import pytest
+ import json
+ from pathlib import Path

+ from axolotl.utils.logging import get_logger
+ from axolotl.prompt_strategies.alpaca import AlpacaPrompter, NoSystemPrompter
+ from axolotl.prompt_strategies.alpaca_w_system import (
+     SystemDataPrompter,
+     InstructionWSystemPromptTokenizingStrategy,
+ )
+ from axolotl.prompt_strategies.llama2_chat import (
+     Llama2ChatPrompter,
+     LLama2ChatTokenizingStrategy,
+ )
+ from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
+ from axolotl.prompters import PromptStyle

These changes will:

  • Eliminate lint errors for unused imports
  • Fix the import errors for missing classes
  • Keep only the imports that are actually referenced by the tests
📝 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
import unittest
from axolotl.prompt_strategies.alpaca_chat import NoSystemPrompter
from axolotl.prompt_strategies.alpaca_w_system import (
InstructionWSystemPromptTokenizingStrategy,
SystemDataPrompter,
)
from axolotl.prompt_strategies.llama2_chat import (
Llama2ChatPrompter,
LLama2ChatTokenizingStrategy,
)
from axolotl.prompt_strategies.orpo.chat_template import load
from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
from axolotl.prompters import AlpacaPrompter, PromptStyle
from axolotl.utils.dict import DictDefault
import pytest
from transformers import AutoTokenizer
from tests.hf_offline_utils import enable_hf_offline
from axolotl.prompt_strategies.alpaca import AlpacaPrompter
from axolotl.prompt_tokenizers import (
AlpacaPromptTokenizingStrategy,
InstructionPromptTokenizingStrategy,
PromptTokenizingStrategy,
ShareGPTPromptTokenizingStrategy,
)
from axolotl.prompters import AlpacaInstructionPrompter, PromptStyle, ShareGPTPrompter
from axolotl.utils.logging import get_logger
import pytest
import json
from pathlib import Path
from axolotl.utils.logging import get_logger
from axolotl.prompt_strategies.alpaca import AlpacaPrompter, NoSystemPrompter
from axolotl.prompt_strategies.alpaca_w_system import (
SystemDataPrompter,
InstructionWSystemPromptTokenizingStrategy,
)
from axolotl.prompt_strategies.llama2_chat import (
Llama2ChatPrompter,
LLama2ChatTokenizingStrategy,
)
from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
from axolotl.prompters import PromptStyle
🧰 Tools
🪛 Ruff (0.11.9)

3-3: unittest imported but unused

Remove unused import: unittest

(F401)


6-6: transformers.AutoTokenizer imported but unused

Remove unused import: transformers.AutoTokenizer

(F401)


11-11: axolotl.prompt_tokenizers.InstructionPromptTokenizingStrategy imported but unused

Remove unused import

(F401)


12-12: axolotl.prompt_tokenizers.PromptTokenizingStrategy imported but unused

Remove unused import

(F401)


13-13: axolotl.prompt_tokenizers.ShareGPTPromptTokenizingStrategy imported but unused

Remove unused import

(F401)


15-15: axolotl.prompters.AlpacaInstructionPrompter imported but unused

Remove unused import

(F401)


15-15: axolotl.prompters.ShareGPTPrompter imported but unused

Remove unused import

(F401)

🪛 GitHub Actions: lint

[error] 3-221: flake8 and pylint errors: multiple unused imports (e.g., 'unittest', 'transformers.AutoTokenizer'), undefined names (e.g., 'NoSystemPrompter', 'SystemDataPrompter', 'InstructionWSystemPromptTokenizingStrategy', 'Path', 'json', 'Llama2ChatPrompter', 'LLama2ChatTokenizingStrategy', 'load', 'DictDefault'), and E0611 import errors for missing attributes in modules 'axolotl.prompt_tokenizers' and 'axolotl.prompters'.


[error] 9-15: mypy errors: Module 'axolotl.prompt_tokenizers' has no attribute 'ShareGPTPromptTokenizingStrategy'; Module 'axolotl.prompters' has no attribute 'AlpacaInstructionPrompter' and 'ShareGPTPrompter'.

🤖 Prompt for AI Agents
In tests/test_prompt_tokenizers.py lines 3 to 16, the import statements include
unused modules like unittest and transformers.AutoTokenizer, and also import
classes that do not exist in the specified modules, causing lint and import
errors. Remove unused imports unittest, transformers.AutoTokenizer,
InstructionPromptTokenizingStrategy, PromptTokenizingStrategy,
ShareGPTPromptTokenizingStrategy, AlpacaInstructionPrompter, and
ShareGPTPrompter. Retain pytest, get_logger, and PromptStyle imports. Add
missing imports for NoSystemPrompter, SystemDataPrompter,
InstructionWSystemPromptTokenizingStrategy, Llama2ChatPrompter,
LLama2ChatTokenizingStrategy, and built-in modules json and Path to match the
classes actually used in the tests. This will fix lint errors and import
mismatches.

@winglian
Copy link
Collaborator

@SalmanMohammadi black and flake8 doesn't like a lot of the formatting changes

Copy link

@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

♻️ Duplicate comments (2)
src/axolotl/utils/logging.py (2)

37-46: ⚠️ Potential issue

Potential memory leak with lru_cache on a method.

Using functools.lru_cache on methods can lead to memory leaks as it keeps references to self and all arguments indefinitely, preventing proper garbage collection.

Consider implementing a module-level cache instead:

+_warning_cache = {}
+
+def _cached_warning(message, *args):
+    """Helper function to cache warning messages."""
+    key = str(message) + str(args)
+    if key not in _warning_cache:
+        _warning_cache[key] = True
+        return True
+    return False
+
 class MultiProcessAdapter(logging.LoggerAdapter):
     # ...other methods...
 
-    @functools.lru_cache(maxsize=10)
     def warning_once(self, *args, **kwargs):
         """
         This method is identical to `logger.warning()`, but will emit the warning with the same message only once
@@ -44,6 +44,7 @@
         cache. The assumption here is that all warning messages are unique across the code. If they aren't then need to
         switch to another type of cache that includes the caller frame information in the hashing function.
         """
-        self.warning(*args, **kwargs)
+        if _cached_warning(args[0] if args else kwargs.get("msg", ""), *args[1:]):
+            self.warning(*args, **kwargs)
🧰 Tools
🪛 Ruff (0.11.9)

37-37: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)


49-56: 🛠️ Refactor suggestion

Add use_environ parameter to get_logger function.

The get_logger function should allow configuration of the use_environ parameter to provide flexibility for different usage scenarios, as noted in previous comments.

-def get_logger(name: str, log_level: str | None = None):
+def get_logger(name: str, log_level: str | None = None, use_environ: bool = False):
     if log_level is None:
         log_level = os.environ.get("AXOLOTL_LOG_LEVEL", None)
     logger = logging.getLogger(name)
     if log_level is not None:
         logger.setLevel(log_level.upper())
         logger.root.setLevel(log_level.upper())
-    return MultiProcessAdapter(logger, {})
+    return MultiProcessAdapter(logger, {}, use_environ=use_environ)

This requires updating the MultiProcessAdapter init method to accept and store the use_environ parameter:

def __init__(self, logger, extra=None, use_environ: bool = False):
    super().__init__(logger, extra or {})
    self.use_environ = use_environ

And updating the _should_log and log methods to use this instance variable.

🧹 Nitpick comments (2)
src/axolotl/utils/logging.py (2)

20-24: Consider making _should_log a regular instance method instead of a static method.

Since this method is only used by instance methods and now accepts a use_environ parameter, it would be more natural as a regular instance method, especially if you store the use_environ preference as an instance variable.

-    @staticmethod
-    def _should_log(main_process_only, use_environ):
+    def _should_log(self, main_process_only, use_environ):
         return not main_process_only or (
             main_process_only and is_main_process(use_environ=use_environ)
         )

49-56: Add docstring to get_logger function.

The get_logger function lacks a docstring explaining its purpose, parameters, and return value.

 def get_logger(name: str, log_level: str | None = None):
+    """
+    Create a logger with the given name and configure its level.
+    
+    Args:
+        name: The name of the logger.
+        log_level: The log level to set. If None, tries to get from AXOLOTL_LOG_LEVEL env var.
+    
+    Returns:
+        A MultiProcessAdapter wrapping the configured logger.
+    """
     if log_level is None:
         log_level = os.environ.get("AXOLOTL_LOG_LEVEL", None)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3dbe0f4 and faa1e03.

📒 Files selected for processing (3)
  • src/axolotl/integrations/cut_cross_entropy/__init__.py (2 hunks)
  • src/axolotl/integrations/liger/__init__.py (4 hunks)
  • src/axolotl/utils/logging.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/axolotl/integrations/liger/init.py
  • src/axolotl/integrations/cut_cross_entropy/init.py
🧰 Additional context used
🪛 Ruff (0.11.9)
src/axolotl/utils/logging.py

37-37: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.5.1)
  • GitHub Check: PyTest (3.11, 2.5.1)
🔇 Additional comments (2)
src/axolotl/utils/logging.py (2)

1-10: Good logging module structure and documentation.

The module is well-organized with a clear purpose statement and appropriate imports. Attribution to the original source (Accelerate) is properly documented.


26-35: LGTM: The log method correctly handles distributed logging.

The implementation properly extracts parameters and only logs when appropriate for the current process, making it suitable for distributed environments.

Copy link

@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

♻️ Duplicate comments (1)
src/axolotl/utils/logging.py (1)

41-50: ⚠️ Potential issue

Fix potential memory leak in warning_once method.

Using lru_cache on methods can lead to memory leaks because it keeps references to self and all arguments, preventing garbage collection. Although setting maxsize=10 limits the cache size, it doesn't fully solve the issue.

Consider implementing a class-level cache instead:

-@functools.lru_cache(maxsize=10)
 def warning_once(self, *args, **kwargs):
     """
     This method is identical to `logger.warning()`, but will emit the warning with the same message only once

     Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the
     cache. The assumption here is that all warning messages are unique across the code. If they aren't then need to
     switch to another type of cache that includes the caller frame information in the hashing function.
     """
-    self.warning(*args, **kwargs)
+    # Use a class-level cache to avoid memory leaks
+    if not hasattr(MultiProcessAdapter, "_warning_cache"):
+        MultiProcessAdapter._warning_cache = set()
+    
+    # Create a cache key from the arguments
+    key = str(args) + str(sorted(kwargs.items()))
+    
+    if key not in MultiProcessAdapter._warning_cache:
+        MultiProcessAdapter._warning_cache.add(key)
+        self.warning(*args, **kwargs)
+        
+        # Limit cache size to prevent unbounded growth
+        if len(MultiProcessAdapter._warning_cache) > 10:
+            MultiProcessAdapter._warning_cache.pop()

This implementation avoids the memory leak while maintaining the same functionality.

🧰 Tools
🪛 Ruff (0.11.9)

41-41: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)

🧹 Nitpick comments (4)
src/axolotl/utils/logging.py (4)

20-22: Consider reordering parameters in constructor for clarity.

The parameter order in the constructor is unusual - extra is a required parameter for the parent class LoggerAdapter, but it's placed after the optional use_environ parameter. Consider reordering to match standard Python conventions with required parameters first:

-def __init__(self, logger, use_environ=False, extra=None):
+def __init__(self, logger, extra=None, use_environ=False):
     super().__init__(logger, extra)
     self.use_environ = use_environ

24-28: Consider converting _should_log to an instance method.

Since the class already stores use_environ as an instance variable, _should_log could be an instance method that uses this value directly, reducing parameter duplication:

-@staticmethod
-def _should_log(main_process_only, use_environ=False):
-    return not main_process_only or (
-        main_process_only and is_main_process(use_environ=use_environ)
-    )
+def _should_log(self, main_process_only):
+    return not main_process_only or (
+        main_process_only and is_main_process(use_environ=self.use_environ)
+    )

Then update the log method to use the instance method:

-if self.isEnabledFor(level) and self._should_log(
-    main_process_only, use_environ=use_environ
-):
+if self.isEnabledFor(level) and self._should_log(main_process_only):

This would simplify the code while maintaining the ability to override use_environ per log call.


60-60: Fix parameter order in MultiProcessAdapter constructor call.

The parameter order in the MultiProcessAdapter constructor call doesn't match the order defined in the constructor:

-return MultiProcessAdapter(logger, use_environ=use_environ, extra={})
+return MultiProcessAdapter(logger, extra={}, use_environ=use_environ)

This ensures the parameters are passed in the correct order, matching the constructor definition.


30-39: Consider simplifying use_environ handling in log method.

If you implement the suggested change to make _should_log an instance method, you could simplify the log method by removing the use_environ parameter handling. However, if you want to maintain the ability to override use_environ per log call, consider updating the instance variable temporarily:

 def log(self, level, msg, *args, **kwargs):
     use_environ = kwargs.pop("use_environ", self.use_environ)
     main_process_only = kwargs.pop("main_process_only", True)
     kwargs.setdefault("stacklevel", 2)

-    if self.isEnabledFor(level) and self._should_log(
-        main_process_only, use_environ=use_environ
-    ):
+    # Store original value to restore later
+    original_use_environ = self.use_environ
+    
+    try:
+        # Temporarily update instance variable if needed
+        self.use_environ = use_environ
+        
+        if self.isEnabledFor(level) and self._should_log(main_process_only):
+            msg, kwargs = self.process(msg, kwargs)
+            self.logger.log(level, msg, *args, **kwargs)
+    finally:
+        # Restore original value
+        self.use_environ = original_use_environ

This approach maintains flexibility while simplifying the code structure.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9dcb21d and 9c8403d.

📒 Files selected for processing (6)
  • src/axolotl/cli/config.py (5 hunks)
  • src/axolotl/integrations/cut_cross_entropy/__init__.py (2 hunks)
  • src/axolotl/integrations/liger/__init__.py (4 hunks)
  • src/axolotl/utils/logging.py (1 hunks)
  • src/axolotl/utils/schemas/config.py (7 hunks)
  • src/axolotl/utils/schemas/model.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/axolotl/utils/schemas/model.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/axolotl/cli/config.py
  • src/axolotl/integrations/liger/init.py
  • src/axolotl/integrations/cut_cross_entropy/init.py
  • src/axolotl/utils/schemas/config.py
🧰 Additional context used
🪛 Ruff (0.11.9)
src/axolotl/utils/logging.py

41-41: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • 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.5.1)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.0, 2, true)
  • GitHub Check: test-axolotl-multigpu (124, 12.4.1, 3.11, 2.5.1, 2, true)
  • GitHub Check: PyTest (3.11, 2.5.1)
  • GitHub Check: test-axolotl-multigpu (124, 12.4.1, 3.11, 2.6.0, vllm, 2, true)
  • GitHub Check: pre-commit

Copy link
Member

@djsaunde djsaunde left a comment

Choose a reason for hiding this comment

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

great stuff, thanks for doing this. just need to rebase and (IMO) make the LOG statements one-liners where possible.

Copy link
Member

Choose a reason for hiding this comment

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

🚀

)

def log(self, level, msg, *args, **kwargs):
use_environ = kwargs.pop("use_environ", self.use_environ)
Copy link
Member

Choose a reason for hiding this comment

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

nice, I like that you can set this at different levels like this

Copy link

@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

♻️ Duplicate comments (1)
src/axolotl/utils/logging.py (1)

41-50: ⚠️ Potential issue

Fix potential memory leak in warning_once method

Using functools.lru_cache on a method can lead to memory leaks because it keeps a reference to self. While setting maxsize=10 is better than None, it still risks memory leaks.

Consider using a class-level cache instead:

-    @functools.lru_cache(maxsize=10)
     def warning_once(self, *args, **kwargs):
         """
         This method is identical to `logger.warning()`, but will emit the warning with the same message only once
@@ -48,4 +47,11 @@
         cache. The assumption here is that all warning messages are unique across the code. If they aren't then need to
         switch to another type of cache that includes the caller frame information in the hashing function.
         """
-        self.warning(*args, **kwargs)
+        # Use a class-level cache
+        if not hasattr(MultiProcessAdapter, "_warning_cache"):
+            MultiProcessAdapter._warning_cache = {}
+        
+        key = str(args) + str(sorted(kwargs.items()))
+        if key not in MultiProcessAdapter._warning_cache or len(MultiProcessAdapter._warning_cache) > 10:
+            MultiProcessAdapter._warning_cache[key] = True
+            self.warning(*args, **kwargs)
🧰 Tools
🪛 Ruff (0.11.9)

41-41: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)

🧹 Nitpick comments (3)
src/axolotl/utils/logging.py (3)

20-22: Parameter order inconsistency in constructor

The parameter order in __init__ is unusual - typically optional parameters come after required ones, but extra comes after use_environ. This could cause confusion when initializing the adapter.

-    def __init__(self, logger, use_environ=False, extra=None):
+    def __init__(self, logger, extra=None, use_environ=False):
     super().__init__(logger, extra)
     self.use_environ = use_environ

24-28: Consider making _should_log an instance method

This method is marked as static but uses use_environ which is also stored as an instance variable. For consistency, it should be an instance method that accesses self.use_environ by default.

-    @staticmethod
-    def _should_log(main_process_only, use_environ=False):
+    def _should_log(self, main_process_only, use_environ=None):
+        use_environ = self.use_environ if use_environ is None else use_environ
         return not main_process_only or (
             main_process_only and is_main_process(use_environ=use_environ)
         )

53-62: Parameter mismatch between get_logger and MultiProcessAdapter.__init__

The order of parameters in the call to MultiProcessAdapter doesn't match the order in its definition, which could lead to confusion and potential errors.

-    return MultiProcessAdapter(logger, use_environ=use_environ, extra={})
+    return MultiProcessAdapter(logger, extra={}, use_environ=use_environ)

Also, good job adding the return type annotation as previously suggested.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9c8403d and 9dfd461.

📒 Files selected for processing (7)
  • src/axolotl/cli/config.py (5 hunks)
  • src/axolotl/monkeypatch/unsloth_.py (3 hunks)
  • src/axolotl/utils/data/sft.py (7 hunks)
  • src/axolotl/utils/logging.py (1 hunks)
  • src/axolotl/utils/models.py (10 hunks)
  • src/axolotl/utils/schemas/config.py (4 hunks)
  • src/axolotl/utils/schemas/model.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/axolotl/utils/schemas/model.py
  • src/axolotl/monkeypatch/unsloth_.py
  • src/axolotl/cli/config.py
  • src/axolotl/utils/schemas/config.py
  • src/axolotl/utils/models.py
  • src/axolotl/utils/data/sft.py
🧰 Additional context used
🪛 Ruff (0.11.9)
src/axolotl/utils/logging.py

41-41: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • 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.5.1)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.0, 2, true)
  • GitHub Check: test-axolotl-multigpu (124, 12.4.1, 3.11, 2.5.1, 2, true)
🔇 Additional comments (3)
src/axolotl/utils/logging.py (3)

1-13: Well-structured module for distributed logging control

This is a well-organized implementation for controlling logging in distributed environments. The attribution to Accelerate is proper and helps future maintainers understand the origin of this pattern.


30-39: Good implementation of conditional logging logic

The log method is implemented properly to respect both the logging level and distributed environment considerations. I like how you can set the use_environ parameter at different levels.


1-62: Great implementation of rank 0-only logging

This module successfully implements the PR's objective of restricting logs to only rank 0 in distributed training environments. The implementation is clean, well-documented, and provides flexibility through configuration options. This will significantly reduce redundant logging output across multiple ranks.

🧰 Tools
🪛 Ruff (0.11.9)

41-41: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

(B019)

Copy link
Member

@djsaunde djsaunde left a comment

Choose a reason for hiding this comment

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

Approving now since this largely looks good, but there's still a some cases of trailing commas in the LOG commands that should be fixed before merge. For example, in src/axolotl/utils/data/sft.py:

    LOG.info(
        f"Maximum number of steps set at {total_num_steps}",
    )

@djsaunde djsaunde mentioned this pull request May 27, 2025
Copy link

@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 (1)
tests/e2e/multigpu/solo/test_grpo.py (1)

121-124: Good fix! Replaced incorrect directory removal with proper file deletion.

The change from shutil.rmtree to os.remove is correct since /tmp/vllm.log is a file, not a directory. The added error handling for FileNotFoundError is also appropriate.

Consider using contextlib.suppress for cleaner error handling:

+import contextlib
+
         with open("/tmp/vllm.log", "r", encoding="utf-8") as log_file:
             print(log_file.read())
 
-        try:
-            os.remove("/tmp/vllm.log")
-        except FileNotFoundError:
-            pass
+        with contextlib.suppress(FileNotFoundError):
+            os.remove("/tmp/vllm.log")
🧰 Tools
🪛 Ruff (0.11.9)

121-124: Use contextlib.suppress(FileNotFoundError) instead of try-except-pass

Replace with contextlib.suppress(FileNotFoundError)

(SIM105)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dd76a13 and 1df853f.

📒 Files selected for processing (15)
  • src/axolotl/cli/utils.py (1 hunks)
  • src/axolotl/common/datasets.py (1 hunks)
  • src/axolotl/core/trainer_builder.py (1 hunks)
  • src/axolotl/integrations/base.py (2 hunks)
  • src/axolotl/integrations/liger/__init__.py (4 hunks)
  • src/axolotl/monkeypatch/gradient_checkpointing/offload_disk.py (1 hunks)
  • src/axolotl/monkeypatch/peft/utils.py (1 hunks)
  • src/axolotl/prompt_strategies/chat_template.py (3 hunks)
  • src/axolotl/train.py (3 hunks)
  • src/axolotl/utils/config/__init__.py (1 hunks)
  • src/axolotl/utils/data/rl.py (3 hunks)
  • src/axolotl/utils/samplers/multipack.py (1 hunks)
  • src/axolotl/utils/schemas/config.py (4 hunks)
  • tests/e2e/multigpu/solo/test_grpo.py (1 hunks)
  • tests/patched/test_validation.py (15 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/axolotl/monkeypatch/gradient_checkpointing/offload_disk.py
  • src/axolotl/integrations/liger/init.py
🚧 Files skipped from review as they are similar to previous changes (11)
  • src/axolotl/integrations/base.py
  • src/axolotl/utils/schemas/config.py
  • src/axolotl/utils/config/init.py
  • src/axolotl/monkeypatch/peft/utils.py
  • src/axolotl/cli/utils.py
  • src/axolotl/common/datasets.py
  • src/axolotl/utils/samplers/multipack.py
  • src/axolotl/utils/data/rl.py
  • src/axolotl/prompt_strategies/chat_template.py
  • src/axolotl/train.py
  • tests/patched/test_validation.py
🧰 Additional context used
🪛 Ruff (0.11.9)
tests/e2e/multigpu/solo/test_grpo.py

121-124: Use contextlib.suppress(FileNotFoundError) instead of try-except-pass

Replace with contextlib.suppress(FileNotFoundError)

(SIM105)

src/axolotl/core/trainer_builder.py

92-95: Use contextlib.suppress(ImportError) instead of try-except-pass

(SIM105)

🔇 Additional comments (2)
src/axolotl/core/trainer_builder.py (2)

89-89: Custom logger import
Good replacement of the standard logging import with the project’s get_logger utility to unify logging behavior across modules, especially for distributed training.


97-97:

✅ Verification successful

Verify distributed logging behavior
Ensure that get_logger(__name__) is configured to emit logs only on rank 0 in multi-process/distributed runs to prevent redundant output.

Run the following script to inspect its implementation:


🏁 Script executed:

#!/bin/bash
# Inspect the get_logger definition to confirm rank filtering
rg -A5 "def get_logger" src/axolotl/utils/logging.py

Length of output: 292


🏁 Script executed:

#!/bin/bash
# Inspect MultiProcessAdapter definition to confirm rank filtering
rg -A50 "class MultiProcessAdapter" src/axolotl/utils/logging.py

Length of output: 2062


Distributed logging configuration verified
The call to get_logger(__name__) returns a MultiProcessAdapter with main_process_only=True by default. Its log() method uses is_main_process() to suppress logs on non-main ranks, ensuring output only on the primary process. No changes are needed.

@SalmanMohammadi SalmanMohammadi merged commit 65c5481 into main May 28, 2025
14 of 16 checks passed
@SalmanMohammadi SalmanMohammadi deleted the dist_logging branch May 28, 2025 13:57
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.

3 participants