Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions xtuner/v1/datasets/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import os
import pydoc
from functools import partial
from pathlib import Path
from typing import Annotated, Iterable, Literal, Optional, Protocol, Union, runtime_checkable
Expand Down Expand Up @@ -271,7 +272,7 @@ class DataloaderConfig(BaseDataloaderConfig):
dataset_config_list: DatasetConfigList | None = None

collator: Annotated[
Literal["sft_llm_collator", "intern_s1_vl_sft_collator", "qwen3_vl_sft_collator", "fake_collator"],
Literal["sft_llm_collator", "intern_s1_vl_sft_collator", "qwen3_vl_sft_collator", "fake_collator"] | str,
Parameter(help="collator func name"),
] = "sft_llm_collator"
pack_to_max_length: Annotated[bool, Parameter(help="whether to pack to max length")] = True
Expand Down Expand Up @@ -300,7 +301,10 @@ def build_collator(self):
elif self.collator == "fake_collator":
return fake_collator # for RL
else:
raise ValueError(f"Unsupported collator: {self.collator}")
collator = pydoc.locate(self.collator)
if collator is None:
raise ImportError(f"Cannot locate collator: {self.collator}")
return collator

@model_validator(mode="before")
@classmethod
Expand Down
Loading