Validate and configure model-specific settings. - Sets critic model path to actor model path if not specified - Loads chat templates from file if path is provided - Validates Tinker-specific configuration if enabled - Validates and sets model length parameters (max_m
(self, config: Config)
| 429 | """ |
| 430 | |
| 431 | def validate(self, config: Config) -> None: |
| 432 | """Validate and configure model-specific settings. |
| 433 | |
| 434 | - Sets critic model path to actor model path if not specified |
| 435 | - Loads chat templates from file if path is provided |
| 436 | - Validates Tinker-specific configuration if enabled |
| 437 | - Validates and sets model length parameters (max_model_len, max_prompt_tokens, etc.) |
| 438 | |
| 439 | Args: |
| 440 | config: The global configuration object to validate. |
| 441 | |
| 442 | Raises: |
| 443 | ValueError: If chat template file cannot be read, model length constraints |
| 444 | are violated, or Tinker configuration is invalid. |
| 445 | """ |
| 446 | model = config.model |
| 447 | if not model.critic_model_path: |
| 448 | model.critic_model_path = model.model_path |
| 449 | |
| 450 | if model.external_model.enable: |
| 451 | self._check_external_model(config) |
| 452 | |
| 453 | if model.tinker.enable: |
| 454 | self._check_tinker(config) |
| 455 | |
| 456 | # check template |
| 457 | if model.chat_template_path is not None and model.custom_chat_template is None: |
| 458 | try: |
| 459 | with open(model.chat_template_path, "r") as f: |
| 460 | model.custom_chat_template = f.read() |
| 461 | except Exception as e: |
| 462 | raise ValueError( |
| 463 | f"Failed to read chat template from {model.chat_template_path}: {e}" |
| 464 | ) |
| 465 | |
| 466 | # check max_model_len, max_prompt_tokens, max_response_tokens |
| 467 | self._check_model_len(config) |
| 468 | |
| 469 | def _check_external_model(self, config: Config) -> None: |
| 470 | """Validate API-specific configuration settings. |
nothing calls this directly
no test coverage detected