Skip to content

Fix/n startup sampler - #121

Merged
aas008 merged 8 commits into
openshift-psap:mainfrom
aas008:fix/n-startup-sampler
Nov 13, 2025
Merged

Fix/n startup sampler#121
aas008 merged 8 commits into
openshift-psap:mainfrom
aas008:fix/n-startup-sampler

Conversation

@aas008

@aas008 aas008 commented Nov 12, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Configuration Changes

    • Startup trial count now defaults to 10 and validation enforces it is less than total trials; sampler configuration is now logged.
  • Improvements

    • Boolean parameters now emit explicit on/off CLI flags for clearer control.
    • Prefix caching now relies on the vLLM server's default behavior.

- Update TrialConfig to handle boolean False values by adding --no- prefix
  to CLI parameters (e.g., --no-enable-chunked-prefill)
- Remove hardcoded --no-enable-prefix-caching from trial_controller
  as it's now handled by the boolean parameter logic
- Fixes issue where boolean False values were not properly passed to vLLM CLI
openshift-psap#115)

This commit fixes the broken link between the n_startup_trials config parameter
and the actual sampler creation, ensuring user-defined values are properly used.

Changes:
- Set explicit default n_startup_trials=10 in OptimizationConfig (matching Optuna default)
- Updated _create_sampler() to read and pass n_startup_trials to supported samplers
- Added validation to ensure n_startup_trials < n_trials (prevents all-random trials)
- Now passes n_startup_trials to: TPESampler, GPSampler, and BoTorchSampler
- Added informative logging showing sampler configuration
Fixes openshift-psap#115
openshift-psap#115)

This commit fixes the broken link between the n_startup_trials config parameter
and the actual sampler creation, ensuring user-defined values are properly used.

Changes:
- Set explicit default n_startup_trials=10 in OptimizationConfig (matching Optuna default)
- Updated _create_sampler() to read and pass n_startup_trials to supported samplers
- Added validation to ensure n_startup_trials < n_trials (prevents all-random trials)
- Now passes n_startup_trials to: TPESampler, GPSampler, and BoTorchSampler
- Added informative logging showing sampler configuration

Fixes openshift-psap#115
@coderabbitai

coderabbitai Bot commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Default startup trials set to 10; study controller validates startup < total trials and passes startup count to samplers; boolean CLI flags now emit --<param> or --no-<param>; vLLM server startup no longer includes an explicit --no-enable-prefix-caching flag.

Changes

Cohort / File(s) Summary
Startup Trial Configuration
auto_tune_vllm/core/config.py, auto_tune_vllm/core/study_controller.py
n_startup_trials changed from Optional[int] to int = 10; added validation ensuring n_startup_trials < n_trials for startup-capable samplers; sampler creation updated to pass n_startup_trials to TPESampler, GPSampler, and BoTorchSampler; sampler config logging added.
Boolean Parameter Handling
auto_tune_vllm/core/trial.py
Boolean CLI flag generation changed so True emits --<param> and False emits --no-<param> (previously False emitted no flag).
vLLM Server Configuration
auto_tune_vllm/execution/trial_controller.py
Removed the explicit --no-enable-prefix-caching flag from the vLLM server startup command.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Config
    participant Controller as StudyController
    participant Sampler as Optuna Sampler
    participant TrialExec as TrialExecution

    Config->>Controller: Provide OptimizationConfig (n_startup_trials=10)
    Controller->>Controller: Validate n_startup_trials < n_trials
    alt valid
        Controller->>Sampler: Create sampler (n_startup_trials=10)
        Sampler->>Sampler: Initialize with startup trials
        TrialExec->>TrialExec: Build CLI flags (--param / --no-param)
        TrialExec->>TrialExec: Start vLLM server (without --no-enable-prefix-caching)
    else invalid
        Controller->>Controller: Raise ValueError
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention areas:
    • Validation in auto_tune_vllm/core/study_controller.py (correct enforcement and error message clarity)
    • Sampler constructor compatibility where n_startup_trials is passed
    • Boolean flag generation in auto_tune_vllm/core/trial.py (ensure all booleans handled)
    • Confirm removing --no-enable-prefix-caching doesn't change expected runtime behavior

Poem

🐰 Ten hops begin the tuning race,
I check the counts and set the pace,
Flags flip true or false with flair,
No prefix ban — the server's bare,
Small changes, big hope in every space.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix/n startup sampler' accurately reflects the main changes: adding n_startup_trials configuration validation and passing it to samplers (TPESampler, GPSampler, BoTorchSampler).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Removed detailed comments on boolean parameter handling in vllm_args property.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6d0eab and 2dd4279.

📒 Files selected for processing (4)
  • auto_tune_vllm/core/config.py (1 hunks)
  • auto_tune_vllm/core/study_controller.py (1 hunks)
  • auto_tune_vllm/core/trial.py (1 hunks)
  • auto_tune_vllm/execution/trial_controller.py (0 hunks)
💤 Files with no reviewable changes (1)
  • auto_tune_vllm/execution/trial_controller.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ephoris
Repo: openshift-psap/auto-tuning-vllm PR: 104
File: auto_tune_vllm/core/study_controller.py:605-609
Timestamp: 2025-10-20T20:40:13.235Z
Learning: In the auto-tuning-vllm codebase, configuration validation is performed at entry points before reaching execution paths like trial submission in study_controller.py. Defensive try-except blocks around config value parsing (e.g., VLLM_STARTUP_TIMEOUT) are unnecessary and considered bloat since validation has already occurred upstream.
📚 Learning: 2025-10-20T20:40:13.235Z
Learnt from: ephoris
Repo: openshift-psap/auto-tuning-vllm PR: 104
File: auto_tune_vllm/core/study_controller.py:605-609
Timestamp: 2025-10-20T20:40:13.235Z
Learning: In the auto-tuning-vllm codebase, configuration validation is performed at entry points before reaching execution paths like trial submission in study_controller.py. Defensive try-except blocks around config value parsing (e.g., VLLM_STARTUP_TIMEOUT) are unnecessary and considered bloat since validation has already occurred upstream.

Applied to files:

  • auto_tune_vllm/core/study_controller.py
🪛 GitHub Actions: lint-ci
auto_tune_vllm/core/config.py

[error] 72-72: Ruff: E501 Line too long (117 > 88)

🪛 GitHub Check: ruff
auto_tune_vllm/core/config.py

[failure] 72-72: Ruff (E501)
auto_tune_vllm/core/config.py:72:89: E501 Line too long (117 > 88)

🔇 Additional comments (5)
auto_tune_vllm/core/study_controller.py (3)

401-412: Validation logic is sound and user-friendly.

The check ensures that startup trials don't consume all available trials, which would result in purely random sampling. The error message provides actionable suggestions for resolution.


414-418: Clear and informative logging.

The log message helps users understand the sampler configuration being used.


420-431: The sampler constructors do accept n_startup_trials as a parameter in Optuna's API. The code correctly passes this parameter to TPESampler, GPSampler, and BoTorchSampler with the exact parameter name required by the library.

auto_tune_vllm/core/config.py (1)

72-72: The default value of Optuna's TPESampler's n_startup_trials is 10, confirming the code comment is accurate.

auto_tune_vllm/core/trial.py (1)

92-94: I need to verify whether vLLM's argument parser supports --no- prefix for ALL boolean parameters, or if there are any exceptions. Let me search for vLLM's actual argument handling:

The web search confirms vLLM uses argparse.BooleanOptionalAction, which is Python's standard mechanism for boolean flags with automatic --no- prefix support. However, I need to verify how the parameter names are being generated in trial.py and whether they align with vLLM's actual parameter names.

Based on my verification using both shell scripts and web searches, vLLM uses argparse.BooleanOptionalAction for boolean arguments, which automatically supports the --no- prefix negation syntax. For example, --enable-prefix-caching can be negated as --no-enable-prefix-caching.

The code change in trial.py correctly implements this pattern by emitting --no-<param> for False boolean values. The existing codebase in vllm_cli_parser.py already recognizes --no- as a valid boolean flag indicator, and the change aligns with vLLM's CLI conventions.


All boolean parameters in vLLM support the --no- prefix syntax through argparse.BooleanOptionalAction; the implementation is correct.

Comment thread auto_tune_vllm/core/config.py Outdated
Updated comment for n_startup_trials for clarity.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
auto_tune_vllm/core/config.py (1)

72-72: Good change; remove trailing whitespace.

Making n_startup_trials non-optional with a sensible default of 10 simplifies downstream logic and aligns with Optuna's TPESampler default.

Remove the trailing whitespace after the comment to keep the code clean:

-    n_startup_trials: int = 10  # Number of random startup trials 
+    n_startup_trials: int = 10  # Number of random startup trials
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dd4279 and d51782b.

📒 Files selected for processing (1)
  • auto_tune_vllm/core/config.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-20T20:40:13.235Z
Learnt from: ephoris
Repo: openshift-psap/auto-tuning-vllm PR: 104
File: auto_tune_vllm/core/study_controller.py:605-609
Timestamp: 2025-10-20T20:40:13.235Z
Learning: In the auto-tuning-vllm codebase, configuration validation is performed at entry points before reaching execution paths like trial submission in study_controller.py. Defensive try-except blocks around config value parsing (e.g., VLLM_STARTUP_TIMEOUT) are unnecessary and considered bloat since validation has already occurred upstream.

Applied to files:

  • auto_tune_vllm/core/config.py

@aas008 aas008 linked an issue Nov 12, 2025 that may be closed by this pull request
@aas008 aas008 self-assigned this Nov 12, 2025

@thameem-abbas thameem-abbas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aas008
aas008 merged commit 31e0bb8 into openshift-psap:main Nov 13, 2025
2 of 3 checks passed
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.

Re-establish link between OptimizationConfig and the Sampler creation

2 participants