Validate command-line arguments.
(args)
| 221 | |
| 222 | |
| 223 | def validate_args(args): |
| 224 | """ |
| 225 | Validate command-line arguments. |
| 226 | """ |
| 227 | |
| 228 | # === Deprecation and Defaulting === |
| 229 | if args.dataset is not None: |
| 230 | warnings.warn( |
| 231 | "The '--dataset' argument will be deprecated in the next release. " |
| 232 | "Please use '--dataset-name' and '--dataset-path' instead.", |
| 233 | stacklevel=2, |
| 234 | ) |
| 235 | args.dataset_path = args.dataset |
| 236 | |
| 237 | if not getattr(args, "tokenizer", None): |
| 238 | args.tokenizer = args.model |
| 239 | |
| 240 | # === Backend Validation === |
| 241 | valid_backends = {"fastdeploy", "hf", "fastdeploy-chat"} |
| 242 | if args.backend not in valid_backends: |
| 243 | raise ValueError(f"Unsupported backend: {args.backend}") |
| 244 | |
| 245 | # === Dataset Configuration === |
| 246 | if not args.dataset and not args.dataset_path: |
| 247 | print("When dataset path is not set, it will default to random dataset") |
| 248 | args.dataset_name = "random" |
| 249 | if args.input_len is None: |
| 250 | raise ValueError("input_len must be provided for a random dataset") |
| 251 | |
| 252 | # === Dataset Name Specific Checks === |
| 253 | # --hf-subset and --hf-split: only used |
| 254 | # when dataset_name is 'hf' |
| 255 | if args.dataset_name != "hf" and ( |
| 256 | getattr(args, "hf_subset", None) is not None or getattr(args, "hf_split", None) is not None |
| 257 | ): |
| 258 | warnings.warn( |
| 259 | "--hf-subset and --hf-split will be ignored \ |
| 260 | since --dataset-name is not 'hf'.", |
| 261 | stacklevel=2, |
| 262 | ) |
| 263 | # elif args.dataset_name == "hf": |
| 264 | # if args.dataset_path in ( |
| 265 | # VisionArenaDataset.SUPPORTED_DATASET_PATHS.keys() |
| 266 | # | ConversationDataset.SUPPORTED_DATASET_PATHS): |
| 267 | # assert args.backend == "vllm-chat", f"{args.dataset_path} needs to use vllm-chat as the backend." #noqa: E501 |
| 268 | # elif args.dataset_path in (InstructCoderDataset.SUPPORTED_DATASET_PATHS |
| 269 | # | AIMODataset.SUPPORTED_DATASET_PATHS): |
| 270 | # assert args.backend == "vllm", f"{args.dataset_path} needs to use vllm as the backend." #noqa: E501 |
| 271 | # else: |
| 272 | # raise ValueError( |
| 273 | # f"{args.dataset_path} is not supported by hf dataset.") |
| 274 | |
| 275 | # --random-range-ratio: only used when dataset_name is 'random' |
| 276 | if args.dataset_name != "random" and args.random_range_ratio is not None: |
| 277 | warnings.warn( |
| 278 | "--random-range-ratio will be ignored since \ |
| 279 | --dataset-name is not 'random'.", |
| 280 | stacklevel=2, |