From 3ff04c3d094426b45425c6d0249b3f8f5ff04b88 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Mon, 30 Jun 2025 16:39:36 -0700 Subject: [PATCH] Convert torch.bfloat16, torch.float16, etc. to vLLM valid dtypes (#2811) * Convert torch.bfloat16, torch.float16, etc. to vLLM valid dtypes * removed newlines and extra whitespace --- unsloth/dataprep/synthetic.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/unsloth/dataprep/synthetic.py b/unsloth/dataprep/synthetic.py index de6aff560c..f3fbf77222 100644 --- a/unsloth/dataprep/synthetic.py +++ b/unsloth/dataprep/synthetic.py @@ -78,7 +78,17 @@ class SyntheticDataKit: use_bitsandbytes = False, **kwargs, ) - + if "dtype" in engine_args: + dtype_val = engine_args["dtype"] + # Convert torch.bfloat16, torch.float16, etc. to valid CLI string + if hasattr(dtype_val, "name"): + engine_args["dtype"] = dtype_val.name + elif isinstance(dtype_val, str) and dtype_val.startswith("torch."): + engine_args["dtype"] = dtype_val.split(".")[-1] + # Only allow valid vLLM choices + valid_dtypes = {"auto", "bfloat16", "float", "float16", "float32", "half"} + if engine_args["dtype"] not in valid_dtypes: + engine_args["dtype"] = "auto" if "device" in engine_args: del engine_args["device"] if "model" in engine_args: del engine_args["model"] if "compilation_config" in engine_args: