hiyouga/LlamaFactory · error · ValueError

Radio-based BAdam does not yet support distributed training,

Error message

Radio-based BAdam does not yet support distributed training, use layer-wise BAdam.

What it means

Raised in parser.py:514 inside the distributed block when use_badam is true and badam_mode == "ratio" (note: the message's "Radio" is a typo for ratio-based). Ratio-based BAdam updates a random fraction of blocks per step; the random choice diverges across ranks in distributed training, so only layer-wise BAdam is supported there.

Source

Thrown at src/llamafactory/hparams/parser.py:514

        raise ValueError("Please use scripts/pissa_init.py to initialize PiSSA in DeepSpeed ZeRO-3.")

    if finetuning_args.pure_bf16:
        if not (is_torch_bf16_gpu_available() or (is_torch_npu_available() and torch.npu.is_bf16_supported())):
            raise ValueError("This device does not support `pure_bf16`.")

        if is_deepspeed_zero3_enabled():
            raise ValueError("`pure_bf16` is incompatible with DeepSpeed ZeRO-3.")

    if training_args.parallel_mode == ParallelMode.DISTRIBUTED:
        if finetuning_args.use_galore and finetuning_args.galore_layerwise:
            raise ValueError("Distributed training does not support layer-wise GaLore.")

        if finetuning_args.use_apollo and finetuning_args.apollo_layerwise:
            raise ValueError("Distributed training does not support layer-wise APOLLO.")

        if finetuning_args.use_badam:
            if finetuning_args.badam_mode == "ratio":
                raise ValueError("Radio-based BAdam does not yet support distributed training, use layer-wise BAdam.")
            elif not is_deepspeed_zero3_enabled():
                raise ValueError("Layer-wise BAdam only supports DeepSpeed ZeRO-3 training.")

    if training_args.deepspeed is not None and (finetuning_args.use_galore or finetuning_args.use_apollo):
        raise ValueError("GaLore and APOLLO are incompatible with DeepSpeed yet.")

    if (
        not finetuning_args.use_mca
        and not finetuning_args.use_megatron_bridge
        and training_args.fp8
        and model_args.quantization_bit is not None
    ):
        raise ValueError("FP8 training is not compatible with quantization. Please disable one of them.")

    if model_args.infer_backend != EngineName.HF:
        raise ValueError("vLLM/SGLang backend is only available for API, CLI and Web.")

    if model_args.use_unsloth and is_deepspeed_zero3_enabled():

View on GitHub (pinned to f28afaf635)

Solutions

  1. Set `badam_mode: layer-wise` for distributed runs
  2. Or drop use_badam entirely and use a supported distributed optimizer (adamw_torch, GaLore non-layerwise, or DeepSpeed)
  3. Run single-GPU if ratio-based BAdam is specifically needed

Example fix

# before (YAML)
use_badam: true
badam_mode: ratio  # multi-GPU launch

# after
use_badam: true
badam_mode: layer-wise
Defensive patterns

Strategy: validation

Validate before calling

if world_size > 1 and config.get("use_badam") and config.get("badam_mode", "ratio") == "ratio":
    raise SystemExit("Set badam_mode: layer-wise for distributed runs")

Prevention

When it happens

Trigger: Multi-GPU launch with `use_badam: true` and `badam_mode: ratio` in the finetuning args.

Common situations: Using the BAdam blockwise optimizer to cut optimizer memory on a multi-GPU finetune while keeping the default ratio mode; copying BAdam docs/examples that default to ratio.

Related errors


AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14). Data as JSON: /api/errors/1233af61e079224b. Report an issue: GitHub.