Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Axolotl ai cloud Axolotl Load Cfg

From Leeroopedia


Knowledge Sources
Domains Configuration, CLI
Last Updated 2026-02-06 23:00 GMT

Overview

Concrete tool for loading and normalizing YAML training configurations provided by the Axolotl framework.

Description

The load_cfg function is the primary entry point for configuration loading in Axolotl. It accepts a YAML file path, URL, directory, or pre-constructed DictDefault object and returns a fully resolved configuration dictionary. The function handles multiple input formats: local file paths, HTTP/HTTPS URLs for remote configs, directories (scanning for YAML files), and pre-built dictionary objects. CLI keyword arguments are merged as overrides on top of the loaded configuration.

Usage

Import this function when initializing any Axolotl training, evaluation, or preprocessing pipeline. It is called at the very beginning of every CLI command (train, preprocess, evaluate, merge-lora, etc.).

Code Reference

Source Location

  • Repository: axolotl
  • File: src/axolotl/cli/config.py
  • Lines: L173-264

Signature

def load_cfg(
    config: Union[Path, str, DictDefault] = Path("examples/"),
    **kwargs,
) -> DictDefault:
    """Load a configuration from a YAML file, URL, directory, or DictDefault.

    Args:
        config: Path to YAML config file, HTTP URL, directory of configs,
                or pre-built DictDefault object.
        **kwargs: CLI overrides merged into the loaded configuration.

    Returns:
        DictDefault: Validated, normalized configuration dictionary with
        all training parameters resolved.
    """

Import

from axolotl.cli.config import load_cfg

I/O Contract

Inputs

Name Type Required Description
config Union[Path, str, DictDefault] No (default: Path("examples/")) Path to YAML config file, HTTP(S) URL, directory containing configs, or pre-built DictDefault
**kwargs dict No CLI argument overrides merged into config (e.g., learning_rate=1e-4)

Outputs

Name Type Description
return DictDefault Fully resolved configuration dictionary with all training parameters, dataset specs, model settings, and runtime options normalized

Usage Examples

Loading from YAML File

from axolotl.cli.config import load_cfg

# Load from a local YAML file
cfg = load_cfg("examples/llama-3/qlora-1b.yml")
print(cfg.base_model)  # "meta-llama/Llama-3.2-1B"
print(cfg.learning_rate)  # 2e-4

Loading with CLI Overrides

from axolotl.cli.config import load_cfg

# Load config and override specific values
cfg = load_cfg(
    "examples/llama-3/qlora-1b.yml",
    learning_rate=1e-5,
    num_epochs=5,
    output_dir="./my_output",
)

Loading from URL

from axolotl.cli.config import load_cfg

# Load config from a remote URL
cfg = load_cfg("https://raw.githubusercontent.com/axolotl-ai-cloud/axolotl/main/examples/llama-3/qlora-1b.yml")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment