hiyouga/LlamaFactory · error · ValueError
Unsupported model type: {getattr(config, 'model_type')}.
Error message
Unsupported model type: {getattr(config, 'model_type')}. What it means
get_train_dataloader in the HyperParallel trainer (trainer.py:311) mirrors the upstream transformers behavior: if self.train_dataset is None it cannot build a dataloader and raises ValueError('Trainer: training requires a train_dataset.'). In LlamaFactory this means the YAML stage/dataset wiring produced no dataset before the trainer was constructed.
Source
Thrown at scripts/qwen_omni_merge.py:117
Args:
model_path (str): Directory path of the original model.
thinker_path (str): Path to the saved thinker weights.
save_path (str): Directory where the merged model and configurations will be saved.
extra_file (str): Name of the extra file to be copied (default: "spk_dict.pt").
"""
# 1. Load the saved thinker module and the original model
config = AutoConfig.from_pretrained(model_path)
if getattr(config, "model_type") == "qwen2_5_omni":
from transformers.models.qwen2_5_omni import Qwen2_5OmniThinkerForConditionalGeneration # type: ignore
ThinkerClass = Qwen2_5OmniThinkerForConditionalGeneration
elif getattr(config, "model_type") == "qwen3_omni_moe":
from transformers.models.qwen3_omni_moe import Qwen3OmniMoeThinkerForConditionalGeneration # type: ignore
ThinkerClass = Qwen3OmniMoeThinkerForConditionalGeneration
else:
raise ValueError(f"Unsupported model type: {getattr(config, 'model_type')}.")
thinker = ThinkerClass.from_pretrained(thinker_path, torch_dtype="auto", device_map="cpu")
base_model = AutoModelForTextToWaveform.from_pretrained(model_path, torch_dtype="auto", device_map="cpu")
base_model.thinker = thinker
processor = AutoProcessor.from_pretrained(thinker_path)
print("Successfully loaded model weights and processor.")
# 2. Save the complete model along with its tokenizer and processor configuration
base_model.save_pretrained(save_path)
processor.save_pretrained(save_path)
print(f"Merged model and processor saved to {save_path}.")
# 3. Copy the extra file from the base model directory to the save_path
try:
source_file = cached_file(path_or_repo_id=model_path, filename=extra_file)
shutil.copy(source_file, os.path.join(save_path, extra_file))
print(f"File '{extra_file}' copied from {model_path} to {save_path}.")
except Exception:View on GitHub (pinned to f28afaf635)
Solutions
- Add a valid `dataset: <name>` entry (present in data/dataset_info.json) to the training YAML
- Check for typos in the dataset name and that dataset_dir points at the right dataset_info.json
- If you meant preprocessing-only or no data, use a different workflow — the HP trainer cannot run without a train dataset
Example fix
# before (YAML) ### dataset # dataset: (missing) # after (YAML) dataset: alpaca_gpt4_zh # must exist in data/dataset_info.json
Defensive patterns
Strategy: validation
Validate before calling
assert data_args.dataset, 'No dataset configured: add a `dataset:` entry that exists in data/dataset_info.json' assert train_dataset is not None, 'train_dataset resolved to None; check dataset names and dataset_dir'
Type guard
def has_train_dataset(data_args) -> bool:
return bool(getattr(data_args, 'dataset', None)) Try / catch
try:
trainer.train()
except ValueError as e:
if 'requires a train_dataset' in str(e):
raise SystemExit('Add dataset: <name> (from data/dataset_info.json) to the YAML') from e
raise Prevention
- Fail fast in your wrapper: reject train YAMLs without a dataset key
- Verify dataset names resolve during tokenization dry-run before distributed launch
When it happens
Trigger: Training YAML omits `dataset:` / `dataset_dir:` so DataArguments carries no datasets; or the stage (e.g. pt/sft) resolved to an empty dataset list and the trainer was instantiated with train_dataset=None.
Common situations: Reusing a chat/eval YAML for a HyperParallel train run and forgetting the dataset key; dataset name typo causing zero matching datasets; intentionally testing trainer construction without data.
Related errors
- Cannot specify `val_size` if `eval_dataset` is not None.
- The model does not have a submodule named '{submodule_name}'
- Template is required for MultiModalDataCollator.
- Dataset converter {name} not found.
- Unknown mixing strategy: {data_args.mix_strategy}.
AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14).
Data as JSON: /api/errors/d70aed2fe81a050d.
Report an issue: GitHub.