Skip to content

[Feat] grid cardinality auto switch#7

Merged
VincentG1234 merged 3 commits intomainfrom
FEAT/grid-cardinality-auto-switch
Apr 27, 2026
Merged

[Feat] grid cardinality auto switch#7
VincentG1234 merged 3 commits intomainfrom
FEAT/grid-cardinality-auto-switch

Conversation

@VincentG1234
Copy link
Copy Markdown
Collaborator

Summary

This PR adds grid cardinality calculation and implements smart sampler selection logic to automatically switch between optimization strategies based on the study configuration.

Changes

New: Grid Cardinality Calculator (auto_tune_vllm/utils/grid_cardinality.py)

  • Computes the total number of parameter combinations in the search space
  • Supports all parameter types: ListParameter, RangeParameter, BooleanParameter

Smart Sampler Auto-Switching (auto_tune_vllm/cli/main.py)

Case 1: n_trials >= grid_cardinality

  • Action: Switch to sampler="grid" and set n_trials = cardinality
  • Why: Grid search explores all combinations exhaustively
  • User benefit: No wasted trials on duplicate parameter combinations

Case 2: n_trials <= n_startup_trials

  • Action: Switch to sampler="random" and ignore n_startup_trials
  • Why: TPE's startup phase is meaningless when we can't even complete it
  • User benefit: Immediate optimization without waiting for random startup

CLI Enhancement

  • Grid cardinality is now displayed in the validate command output
  • Clear warning messages inform users when auto-switching occurs

Example Behavior

study_config.yaml with small search space
parameters:
tensor_parallel_size:
type: list
options: [1, 2] # 2 values
dtype:
type: list
options: [float16, bfloat16] # 2 values
→ Grid cardinality = 2 × 2 = 4

  • If user requests --trials 10 (> 4) → Warning: n_trials (10) exceeds grid cardinality (4). Search set to grid mode with n_trials = 4.

  • If user requests --trials 5 with n_startup_trials=10 → Warning: n_trials (5) <= n_startup_trials (10). Search set to random mode; n_startup_trials ignored.

Signed-off-by: Vincent Gimenes <vincent.gimenes@gmail.com>
Signed-off-by: Vincent Gimenes <vincent.gimenes@gmail.com>
Signed-off-by: Vincent Gimenes <vincent.gimenes@gmail.com>
@VincentG1234 VincentG1234 merged commit eb2e236 into main Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant