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
This commit is contained in:
Rishabh 2025-06-30 16:39:36 -07:00 committed by GitHub
commit 3ff04c3d09

View file

@ -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: