Rank 0-only logging#2608
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
* 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
WalkthroughThis update replaces all uses of the standard Python Changes
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
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (11)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 11
🔭 Outside diff range comments (2)
src/axolotl/monkeypatch/transformers_fa_utils.py (1)
47-53:⚠️ Potential issueFix linter error for
warning_once.
Static analysis reports thatMultiProcessAdapterlacks awarning_oncemember. 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(...)ifwarning_onceis 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 issueRemove unsupported
warning_oncecalls
MultiProcessAdapterdoes not exposewarning_once, causing lint errors. Replace these calls with standardLOG.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-commitisorthook flagged import ordering issues. Please runisort(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
isortreported 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. Runisortto 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
isortflagged 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.
Theisorthook indicated import-order changes in this file. Please runisortto 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-commitisortfixed import sorting; please re-runisortso imports are grouped (stdlib first, then third-party, then local).src/axolotl/cli/checks.py (1)
3-3: Ensure imports are correctly sorted.
Theisorthook reordered imports here; please re-runisortto 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 importsget_loggerand definesLOGbut 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.
isortfixed 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_loggersrc/axolotl/integrations/cut_cross_entropy/args.py (1)
18-22: Fix import order to satisfy isort
Theget_loggerimport 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_loggersrc/axolotl/cli/merge_lora.py (1)
3-15: Fix import sorting to satisfy isort
Reorder imports into standard library, third-party, then local. Move theget_loggerimport 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 DictDefaultsrc/axolotl/train.py (1)
34-34: Import grouping and sorting
The newget_loggerimport should be grouped with otheraxolotl.utilsimports and run throughisortto resolve the pipeline lint failure.src/axolotl/prompt_strategies/bradley_terry/__init__.py (1)
5-5: Import grouping
Please runisortto maintain consistent import order and group theget_loggerimport 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 ofget_loggershould 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_loggersrc/axolotl/integrations/cut_cross_entropy/__init__.py (1)
22-33: Fix import sorting (isort failure)
The added import ofget_loggerand the placement ofLOG = 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 setupThe new import
get_loggerandLOG = get_logger(__name__)are correct for centralized logging, but the import order conflicts withisort. 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 groupingSwitching to
get_loggerimproves distributed log control viaMultiProcessAdapter. Ensure imports are sorted (standard → third-party → local) to satisfyisortand 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_loggerimport andLOG = get_logger(__name__)should be placed after standard-library and third-party imports, per the project’sisortconfiguration. Runningisortwill 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_loggerimport and the subsequentLOG = get_logger(__name__)initialization into the correct section—after built-in and third-party imports—and re-runisort.src/axolotl/prompt_strategies/llama2_chat.py (2)
32-35: Adjust import placement perisort.The
from axolotl.utils.logging import get_loggerandLOG = get_logger(__name__)lines must follow other imports in the proper grouping (standard library → third-party → local). Applyisortto auto-fix ordering.
134-138: Simplify warning message text.Since
LOG.warningalready denotes a warning, the prefixWARNING: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: Useget_logger’slog_levelparameter & 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
isortto 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_loggerimport andLOG = get_logger(__name__)into the correct section of imports (after third-party, before local) and re-runisortto satisfy the lint hook.src/axolotl/core/trainers/grpo/__init__.py (1)
27-27: Remove unused import
SchedulerTypefromtransformers.trainer_utilsis 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
SchedulerTypefromtransformers.trainer_utilsis imported but not utilized. Please remove this line to satisfy lint checks.🧰 Tools
🪛 Ruff (0.11.9)
27-27:
transformers.trainer_utils.SchedulerTypeimported but unusedRemove 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 testThe condition
not (trainer_cls in [AxolotlRewardTrainer, AxolotlPRMTrainer])can be more idiomatically expressed using thenot inoperator.- 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 inConvert 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 runisortto 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. Runningisortwill 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 runisort.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). Useisortto auto-correct.
69-71: Simplify dynamic import in exec.
Consider using an f‐string in theexeccall 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 newget_loggerimport after the standard libraries and third-party imports. Runningisortwill automatically adjust this.src/axolotl/prompt_strategies/chat_template.py (1)
546-549: Fix line break positioning in conditionalThe 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
osmodule is imported but not used anywhere in this file.-import os🧰 Tools
🪛 Ruff (0.11.9)
3-3:
osimported but unusedRemove unused import:
os(F401)
src/axolotl/monkeypatch/mistral_attn_hijack_flash.py (1)
168-168: Remove unnecessarygetattrcall.Using
getattrwith 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
getattrwith a constant attribute value. It is not any safer than normal property access.Replace
getattrwith attribute access(B009)
update_logging.py (3)
9-9: Remove unused import.The
Pathimport frompathlibis 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.Pathimported but unusedRemove 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 ofif-else-blockReplace
if-else-block withbase_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
ifstatement instead of nestedifstatementsCombine
ifstatements usingand(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 honoursAXOLOTL_LOG_LEVEL. Creating the logger is enough—no need to callsetLevel()here (and you don’t in other modules). Dropping explicit level-setting keeps the behaviour uniform across the codebase.
615-633: Replace inlinelambdapad helpers with named functions for consistencyElsewhere in the PR (e.g.
mistral_attn_hijack_flash.py) the anonymouslambdahelpers were promoted to smalldeffunctions to improve tracebacks and avoid the# noqa: E731override. 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
elsebranch a few lines below.src/axolotl/utils/samplers/multipack.py (2)
9-10: Remove unusedget_contextimport to satisfy lint and avoid confusion
multiprocessing.get_contextis 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_contextimported but unusedRemove 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 silenceDEBUGmessages even if a user setsAXOLOTL_LOG_LEVEL=DEBUG. Removing this line lets the centralget_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
📒 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_loggerfrom axolotl's logging utility, which wraps loggers with aMultiProcessAdapterto 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_loggerensures 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_codewill 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 standardloggingimport withget_loggeraligns with the PR’s goal of centralized, multiprocess-aware logging.
12-12: Initialize module logger viaget_logger
Usingget_logger(__name__)ensures logs flow through theMultiProcessAdapter. 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
Importingget_loggerreplaces the standard logging import to standardize behavior across processes.
8-8: Instantiate module logger
LOG = get_logger(__name__)wraps the logger inMultiProcessAdapter. 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 standardloggingwithget_loggeris consistent with the PR’s strategy for rank-aware logging.
8-8: Initialize logger viaget_logger
Ensure that the returnedMultiProcessAdapterfilters logs to rank 0 by default in distributed scenarios.src/axolotl/cli/inference.py (2)
4-4: Adopt centralized logger import
Switching toget_loggerensures CLI logs go through the multiprocess adapter for rank-0 filtering.
26-26: Instantiate CLI logger appropriately
LOG = get_logger(__name__)is correct; please verifyMultiProcessAdaptersuppresses non-rank-0 output during distributed inference.src/axolotl/monkeypatch/peft/utils.py (2)
11-11: Replace standard logging import
Importingget_loggerfromaxolotl.utils.loggingfollows 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 fromlogging.getLogger("axolotl")toget_logger(__name__)properly adopts the custom multiprocess-aware logger.src/axolotl/monkeypatch/accelerate/fsdp2.py (2)
10-10: LOG initialization updated correctly.
Usingget_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. AssumingMultiProcessAdapterfilters 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.
Replacinglogging.getLogger(__name__)withget_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 toget_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_loggerfrom 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_loggerfrom 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_loggerfunction 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_loggerfrom 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_loggerfunction 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_loggerfrom 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_loggerfunction 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 standardloggingimport with the centralizedget_loggerutility fromaxolotl.utils.loggingto unify log configuration across processes.
20-20: Initialize distributed-aware logger
InstantiatingLOG = 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 standardloggingimport withget_loggerfor consistent, multi-process logging.
16-16: Initialize distributed-aware logger
UsingLOG = get_logger("axolotl.tests.e2e.multigpu")aligns this test with the rank 0-only logging strategy.src/axolotl/utils/comet_.py (1)
8-8: Useget_logger(__name__)for module logging
Switching toget_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 replacedlogging.getLoggerwithget_loggerfor 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 importget_loggerinstead of the standard logging module for uniform main-process logging.
19-19: Initialize distributed-aware logger
UsingLOG = 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 withget_loggerfromaxolotl.utils.logging, aligning test files with the new custom logger API.
17-17: Initialize distributed-aware logger
LoggerLOGis now created viaget_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
Replacedlogging.getLoggerwithget_logger(__name__)to leverage theMultiProcessAdapterand centralized log-level control.tests/e2e/test_falcon.py (2)
15-15: Standardize logging import
Updated to importget_loggerfromaxolotl.utils.logginginstead of the standardloggingmodule.
19-19: Initialize distributed-aware logger
LoggerLOGnow usesget_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 withget_loggerfromaxolotl.utils.loggingfor uniform logging.
19-19: Initialize distributed-aware logger
InitializedLOGviaget_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 importingget_loggerfromaxolotl.utils.loggingin place of the standard module.
17-17: Initialize distributed-aware logger
LoggerLOGnow obtained viaget_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 contextsSwitching from
logging.getLoggertoget_logger(__name__)is correct—this will wrap the logger inMultiProcessAdapterand respect distributed rank-0 logging.tests/e2e/patched/test_mixtral_samplepack.py (2)
13-13: Standardize to custom logging utilityReplacing the standard
loggingimport withget_loggerfromaxolotl.utils.loggingaligns this test with the project's distributed logging approach.
17-17: Initialize test logger viaget_loggerGood 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 importUsing
get_loggerinstead of the standardloggingmodule 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 importReplacing the standard
loggingimport withget_loggeris consistent with other tests and ensures proper multiprocess logging.
17-17: Initialize logger for rank-0-only outputGood update:
LOG = get_logger("axolotl.tests.e2e")sets up the logger correctly.src/axolotl/integrations/llm_compressor/plugin.py (1)
23-23: Instantiate plugin loggerUsing
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 standardloggingimport withget_loggerto align with the project-wide logging strategy for multiprocess environments.
18-18: Initialize logger with MultiProcessAdapter
TheLOGinstantiation now leveragesget_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 toget_logger(__name__), wrapping the logger inMultiProcessAdapterfor controlled log emission across processes.tests/e2e/test_llama_vision.py (2)
13-13: Use project logger in tests
Replaced the standard Pythonloggingimport withget_loggerfor consistency across the test suite.
17-17: Initialize test logger with MultiProcessAdapter
LOGnow usesget_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
LOGnow leveragesget_logger(__name__)withMultiProcessAdapterto 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 standardloggingmodule toget_loggerfor consistent, rank-aware logging in end-to-end tests.
17-17: Initialize test logger with MultiProcessAdapter
LOGis now created viaget_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 standardloggingimport with the customget_loggerutility and initializedLOGvia aMultiProcessAdapterfor"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 toget_loggerand created aLOGinstance for"axolotl.tests.e2e". This leverages theMultiProcessAdapterto 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
Importedget_loggerand set upLOG = get_logger("axolotl.tests.e2e"), ensuring test logs are filtered through theMultiProcessAdapterso 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 withget_loggerand instantiatedLOGfor"axolotl.tests.e2e", guaranteeing that only rank 0 emits test logs via theMultiProcessAdapter.Also applies to: 17-17
tests/e2e/test_phi.py (1)
13-13: Switch to MultiProcessAdapter logger
Importedget_loggerand initializedLOGwithget_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 standardloggingimport withget_loggerensures 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 outlogging.getLoggerforget_loggeraligns 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 toget_loggerensures 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 withget_loggermaintains 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 fromlogging.getLoggerto theget_loggerutility 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 standardloggingimport with the centralizedget_loggerensures uniform logging behavior across distributed tests.
19-19: Initialize custom logger for distributed tests
Usingget_loggerhere 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 standardloggingmodule to the project'sget_loggerutility aligns this test with the centralized logging strategy.
19-19: Initialize custom logger in E2E tests
Instantiating the logger viaget_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
Usingget_logger(__name__)scopes logs per module and leveragesMultiProcessAdapterfor main-process-only log emission in distributed training.tests/e2e/test_dpo.py (2)
16-16: Consistent logging import
Replacingimport loggingwithfrom axolotl.utils.logging import get_loggerbrings this test in line with the project's logging refactor.
20-20: Initialize custom logger for E2E tests
Creating theLOGviaget_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
Usingget_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 changeThe changes to replace standard logging with the custom
get_loggerfunction 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 implementationThe replacement of standard logging with the custom
get_loggerfunction 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 fileThe 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 testsThe 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_loggerfunction which wraps the standard logger with aMultiProcessAdapter, 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_loggerfunction which wraps the standard logger with aMultiProcessAdapter, 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_loggerfunction which wraps the standard logger with aMultiProcessAdapter, 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:
- Using the
get_loggerfunction which wraps the standard logger with aMultiProcessAdapter- Using
__name__instead of a hardcoded string, which improves maintainabilityNote: 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 ofget_loggerand the instantiation ofLOGalign with the project-wide switch toaxolotl.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 toget_loggerand the creation ofLOGhere 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 standardloggingmodule toget_loggerand initializingLOGat the module level aligns with the pattern used across other CLI modules.
181-181: Error logging now uses the custom logger
Replacinglogging.errorwithLOG.errorensures 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 updateSwitching from
num_epochstomax_stepschanges how training length is defined. Please ensure downstream training loops and tooling supportmax_stepsand that documentation/examples reflect this shift. Also verify consistency with other example configs.src/axolotl/core/chat/messages.py (2)
12-15: Standardize logger initializationImporting and initializing
LOG = get_logger(__name__)aligns this module with the centralized logging utility. This change is correct and enables rank-0-only logging viaMultiProcessAdapter.
163-163: Replace commented logging call with module loggerThe commented-out
LOG.warningcorrectly updates the reference to use the newLOGinstance instead of the standardloggingmodule. This maintains consistency even in commented code.src/axolotl/integrations/spectrum/__init__.py (2)
24-29: Use centralized logger for SpectrumPluginReplacing standard logging with
LOG = get_logger(__name__)standardizes log output and leverages rank-aware filtering.
88-99: Update warning calls to use custom loggerAll warnings now correctly use
LOG.warningto 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
MultiProcessAdapterwrapper.
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
loggingimport with the customget_loggerfunction aligns with the goal of standardizing rank-0-only logging throughout the codebase.
20-20: Proper logger initialization with custom adapter.Using
get_loggerensures the logger is wrapped withMultiProcessAdapter, 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
optimizerandlr_schedulerimproves 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_loggerfunction aligns with the goal of standardizing rank-0-only logging throughout the codebase.
7-7:Details
✅ 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 theMultiProcessAdapter.
🏁 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.pyLength of output: 594
Logger initialization verified
I’ve confirmed that
MultiProcessAdapter’slogmethod properly checksis_main_process(use_environ=False)before emitting logs, so usingget_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 Pythonloggingimport and configuration with the centralizedget_loggerutility, 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
Importsget_loggerand initializesLOGto 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-inloggingsetup withget_loggerfromaxolotl.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
Importsget_loggerand initializesLOGfor consistent, rank-aware logging across the test module.Also applies to: 18-18
src/axolotl/integrations/base.py (2)
30-33: Initialize module logger viaget_logger
Addsget_loggerimport and createsLOGfor unified, main-process logging in distributed setups.
351-357: UseLOGfor plugin load messages
Replacesloggingcalls withLOG.info/LOG.errorto 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 withget_loggerfromaxolotl.utils.loggingis correct and aligns with the project-wide refactor.
25-25: Logger initialization updated
InitializingLOGwithget_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
Importingget_loggerfromaxolotl.utils.loggingand initializingLOG = 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_checkLevelhandling 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 toget_logger(__name__)improves granularity.
405-407: Removedmain_process_only—verify behavior
Omitting themain_process_onlyargument relies on the custom adapter to enforce rank-0 logging. Please confirm that duplicate debug messages from non-zero ranks are suppressed.
451-453: Removedmain_process_only—verify behavior
Ensure the centralized logging adapter still filters out non-rank-0 logs for this debug statement.
481-483: Removedmain_process_only—verify behavior
Double-check that debug output remains unique to rank 0 after removing the argument.
517-519: Removedmain_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"forcaplog.set_levelis consistent with the custom logging API and pytest; no issues detected.
58-61: Caplog context-level string
Switching to"WARNING"incaplog.at_levelis 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 withget_logger(__name__)correctly standardizes logging across data utilities.
163-165: Warning on missing column preserved
TheLOG.warningcall for missinginput_idsis unchanged in logic and correctly informs the user.
176-179: Logging minimum input length
The multi-lineLOG.infoformin_input_lenis clear and functionally equivalent to previous one-liner.
180-183: Logging maximum input length
The new formatting formax_input_lenremains 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 loggingThe change from standard Python logging to the custom
get_loggerutility 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 implementationUpdated 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 implementationUpdated 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 implementationUpdated 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 loggingThe import of
get_loggerfrom the custom logging utility will help implement rank 0-only logging, reducing duplicate logs in multi-GPU environments.
14-14: Standardized logging implementationReplaced standard logging with the custom logger that supports rank-aware logging.
67-67: Fixed style issue in slice notationRemoved 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 loggingThe import of
get_loggerfrom the custom logging utility will help implement rank 0-only logging, reducing duplicate logs in multi-GPU environments.
9-9: Standardized logging implementationReplaced standard logging with the custom logger that supports rank-aware logging.
196-198: Improved string concatenation styleString 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 styleString 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 loggingThe import of
get_loggerfrom the custom logging utility will help implement rank 0-only logging, reducing duplicate logs in multi-GPU environments.
97-97: Standardized logging implementationReplaced standard logging with the custom logger that supports rank-aware logging.
249-251: Improved boolean expression formattingReformatted multi-line boolean expression to use inline conjunction with the
andoperator, improving readability while maintaining the same logic.
267-270: Improved boolean expression formattingReformatted multi-line boolean expression to use inline conjunction with the
andoperator, improving readability while maintaining the same logic.
530-539: Improved boolean expression formattingReformatted complex multi-line boolean expression to use inline conjunctions with the
andoperator, improving readability while maintaining the same logic.src/axolotl/monkeypatch/trainer_fsdp_optim.py (1)
12-12: Use customMultiProcessAdapterlogger.
Initializing the module‐level logger withLOG = get_logger(__name__)ensures consistent log configuration and multi‐process safety.src/axolotl/utils/chat_templates.py (2)
12-12: Initialize module logger correctly.
UsingLOG = 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 customMultiProcessAdapterlogger.
InitializingLOG = 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 withMultiProcessAdapter.src/axolotl/core/trainers/mixins/scheduler.py (7)
17-17: Consistent logger initialization.
UsingLOG = get_logger(__name__)ensures the scheduler mixin logs through the centralized, multi-process-aware adapter.
39-40: Approve multi-line boolean expression formatting.
Breaking thecosinecheck into separate lines within parentheses enhances readability without changing logic.
44-45: Approve multi-line boolean expression formatting.
Thecosine_min_lrcondition split into two lines is clear and maintains original behavior.
83-84: Approve conditionalmin_lrassignment formatting.
The multi-line inlineifexpression is a concise way to handlemin_lrand is clear in intent.
90-91: Approve structured warning message.
Using a parenthesized multi-lineLOG.warningcall improves readability; the message remains unchanged.
120-121: Approve structured warning message.
The warning in theelsebranch is correctly formatted and retains original semantics.
124-125: Approve structured warning message.
The thirdLOG.warningis 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_loggerfromaxolotl.utils.loggingaligns 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_loggerfromaxolotl.utils.loggingaligns 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_loggerfromaxolotl.utils.loggingaligns 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_loggerfromaxolotl.utils.loggingaligns 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 theuse_environflag, 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_loggerfunction 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_loggerfunction 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_loggerfunction 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
andoperators improves code readability.
83-88: LGTM! Simplified conditional check.Simplifying the debug logging conditional check to only check for
cli_argsand 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_loggerfunction 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
andoperators 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_loggerinstead oflogging.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
andoperators, 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 42instead 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
andoperators, 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 : endtostart:endformat 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
andoperators, improving code readability while maintaining the same logic.Also applies to: 180-182
🧰 Tools
🪛 Ruff (0.11.9)
168-168: Do not call
getattrwith a constant attribute value. It is not any safer than normal property access.Replace
getattrwith attribute access(B009)
251-251: Standardized slice notation.Removed spaces in slice expressions from
start : endtostart:endformat 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.Pathimported but unusedRemove unused import:
pathlib.Path(F401)
86-89: Use ternary operator
base_dir = sys.argv[1] if len(sys.argv) > 1 else "tests"instead ofif-else-blockReplace
if-else-block withbase_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
MultiProcessAdapterclass 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=Trueeffectively 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
ifstatement instead of nestedifstatementsCombine
ifstatements usingand(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 oflogging.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_gathersin FSDP config has been reformatted with line breaks after operators for better readability.🧰 Tools
🪛 Ruff (0.11.9)
561-565: Use a single
ifstatement instead of nestedifstatementsCombine
ifstatements usingand(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 oflogging.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
andoperator, 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@njitfunction or using in-place selection sort inside the JIT to keep nopython compliance.
| # 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 |
There was a problem hiding this comment.
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
TRLConfigschema to include avllmobject withhost,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.
| PromptComponentStatus, | ||
| PromptTemplateAnalyzer, | ||
| ) | ||
| from axolotl.utils.logging import get_logger |
There was a problem hiding this comment.
💡 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 PromptComponentStatus → JinjaTemplateAnalysis and PromptTemplateAnalyzer → JinjaTemplateAnalyzer.
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.
| 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.
| 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 |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Fix multiple unused imports.
Several imported modules are not being used in this file, causing linting errors:
unittesttransformers.AutoTokenizer- Multiple unused imports from
axolotl.prompt_tokenizersandaxolotl.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.pyLength 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 || trueLength 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"
fiLength 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:
unittesttransformers.AutoTokenizerInstructionPromptTokenizingStrategy,PromptTokenizingStrategy,ShareGPTPromptTokenizingStrategy(they’re not inaxolotl.prompt_tokenizers)AlpacaInstructionPrompter,ShareGPTPrompter(never referenced in tests)
• Keep these existing imports:
pytestget_logger(forLOG = get_logger(…))PromptStyle(used inTestInstructionWSystemPromptTokenizingStrategy)
• Add missing imports for classes actually used in the tests:
NoSystemPrompterSystemDataPrompter,InstructionWSystemPromptTokenizingStrategyLlama2ChatPrompter,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 PromptStyleThese 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.
| 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.
|
@salmanmohammadi black and flake8 doesn't like a lot of the formatting changes |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/axolotl/utils/logging.py (1)
41-50:⚠️ Potential issueFix potential memory leak in warning_once method.
Using
lru_cacheon methods can lead to memory leaks because it keeps references toselfand all arguments, preventing garbage collection. Although settingmaxsize=10limits 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_cacheorfunctools.cacheon 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 -
extrais a required parameter for the parent classLoggerAdapter, but it's placed after the optionaluse_environparameter. 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_environas an instance variable,_should_logcould 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
logmethod 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_environper 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_logan instance method, you could simplify thelogmethod by removing theuse_environparameter handling. However, if you want to maintain the ability to overrideuse_environper 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_environThis approach maintains flexibility while simplifying the code structure.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
| ) | ||
|
|
||
| def log(self, level, msg, *args, **kwargs): | ||
| use_environ = kwargs.pop("use_environ", self.use_environ) |
There was a problem hiding this comment.
nice, I like that you can set this at different levels like this
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/axolotl/utils/logging.py (1)
41-50:⚠️ Potential issueFix potential memory leak in
warning_oncemethodUsing
functools.lru_cacheon a method can lead to memory leaks because it keeps a reference toself. While settingmaxsize=10is better thanNone, 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_cacheorfunctools.cacheon methods can lead to memory leaks(B019)
🧹 Nitpick comments (3)
src/axolotl/utils/logging.py (3)
20-22: Parameter order inconsistency in constructorThe parameter order in
__init__is unusual - typically optional parameters come after required ones, butextracomes afteruse_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_logan instance methodThis method is marked as static but uses
use_environwhich is also stored as an instance variable. For consistency, it should be an instance method that accessesself.use_environby 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 betweenget_loggerandMultiProcessAdapter.__init__The order of parameters in the call to
MultiProcessAdapterdoesn'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
📒 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 controlThis 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 logicThe
logmethod is implemented properly to respect both the logging level and distributed environment considerations. I like how you can set theuse_environparameter at different levels.
1-62: Great implementation of rank 0-only loggingThis 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_cacheorfunctools.cacheon methods can lead to memory leaks(B019)
djsaunde
left a comment
There was a problem hiding this comment.
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}",
)There was a problem hiding this comment.
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.rmtreetoos.removeis correct since/tmp/vllm.logis a file, not a directory. The added error handling forFileNotFoundErroris also appropriate.Consider using
contextlib.suppressfor 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 oftry-except-passReplace with
contextlib.suppress(FileNotFoundError)(SIM105)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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 standardloggingimport with the project’sget_loggerutility to unify logging behavior across modules, especially for distributed training.
97-97:Details
✅ Verification successful
Verify distributed logging behavior
Ensure thatget_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.pyLength of output: 292
🏁 Script executed:
#!/bin/bash # Inspect MultiProcessAdapter definition to confirm rank filtering rg -A50 "class MultiProcessAdapter" src/axolotl/utils/logging.pyLength of output: 2062
Distributed logging configuration verified
The call toget_logger(__name__)returns aMultiProcessAdapterwithmain_process_only=Trueby default. Itslog()method usesis_main_process()to suppress logs on non-main ranks, ensuring output only on the primary process. No changes are needed.
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.
Summary by CodeRabbit
New Features
Refactor
Chores