mudler/LocalAI · error · ValueError

Unsupported training method: {training_method}. Supported: s

Error message

Unsupported training method: {training_method}. Supported: sft, dpo, grpo, orpo, kto, rloo, reward

What it means

The TRL backend dispatches on request.training_method to construct a matching Trainer subclass (SFT/DPO/GRPO/ORPO/KTO/RLOO/Reward). Any other string falls into the else branch and raises ValueError with the supported list, so typos and unsupported methods fail fast before model loading.

Source

Thrown at backend/python/trl/backend.py:596

            max_length = int(extra.get("max_length", "512"))

            training_args = RewardConfig(
                max_length=max_length,
                **_common_args,
            )

            trainer = RewardTrainer(
                model=model,
                args=training_args,
                train_dataset=dataset,
                eval_dataset=eval_dataset,
                processing_class=tokenizer,
                callbacks=[progress_cb.get_callback()],
            )

        else:
            raise ValueError(f"Unsupported training method: {training_method}. "
                             "Supported: sft, dpo, grpo, orpo, kto, rloo, reward")

        job.trainer = trainer

        # Start training
        job.progress_queue.put(backend_pb2.FineTuneProgressUpdate(
            job_id=job.job_id, status="training", message="Training started",
        ))

        resume_ckpt = request.resume_from_checkpoint if request.resume_from_checkpoint else None
        trainer.train(resume_from_checkpoint=resume_ckpt)

        # Save final model
        trainer.save_model(output_dir)
        if tokenizer:
            tokenizer.save_pretrained(output_dir)

        job.completed = True

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Set training_method to one of: sft, dpo, grpo, orpo, kto, rloo, reward (lowercase).
  2. Trim/normalize whitespace and casing on the client before sending.
  3. If you need a newer method, upgrade the TRL backend image to a build that supports it.

Example fix

# before
request.training_method = "DPO "
# after
request.training_method = "dpo"
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {"sft", "dpo", "grpo", "orpo", "kto", "rloo", "reward"}

def method_ok(method: str) -> bool:
    return (method or "").strip().lower() in SUPPORTED

Type guard

def is_supported_method(m: str) -> bool:
    SUPPORTED = {"sft", "dpo", "grpo", "orpo", "kto", "rloo", "reward"}
    return isinstance(m, str) and m.strip().lower() in SUPPORTED

Try / catch

try:
    dispatch(request)
except ValueError as e:
    if "Unsupported training method" in str(e):
        return client_error(400, str(e))
    raise

Prevention

When it happens

Trigger: training_method='SFT ' (trailing whitespace) or 'Dpo' (case mismatch) depending on how the method is normalized; training_method='pretrain' or 'rlhf'; an unset field defaulting to an unexpected value.

Common situations: Client sends free-text method names; version skew where a newer client uses a method this backend build does not know; locale/case differences.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/1f786f6f3e9c0089. Report an issue: GitHub.