hung-phan/ml-skills/tune
Claude Code and agent skill by hung-phan/ml-skills
- community
Checking that the SKILL.md file is still in the repository.
Distributed hyperparameter tuning with search algorithms and early stopping. Covers Tuner API, search spaces, Optuna/HyperOpt, ASHA/PBT schedulers, and Ray Train integration. Use when tuning learning rate, architecture, or any hyperparameters across many trials in parallel.
Install
npx vskill@latest install hung-phan/ml-skills/tuneSKILL.md
The same SKILL.md was published earlier as hung-phan/ml-skills/tune.
Ray Tune
- Docs: https://docs.ray.io/en/latest/tune/index.html
- API: https://docs.ray.io/en/latest/tune/api/doc/ray.tune.Tuner.html
- Examples: https://docs.ray.io/en/latest/tune/examples/index.html
Why This Exists
Problem: Manual hyperparameter search is sequential and wasteful — running 50 trials one-at-a-time burns days of GPU time, and naive grid search scales exponentially while ignoring promising regions of the search space.
Key insight: Ray Tune parallelizes trials across a cluster and applies early-stopping schedulers (ASHA) or intelligent search algorithms (Optuna/TPE) to kill bad trials fast and concentrate compute on the most promising configurations.
Reach for this when: You have more than ~10 hyperparameters to explore, training runs take longer than a few minutes (making early stopping worthwhile), or you want Optuna/HyperOpt search algorithms with distributed parallelism — prefer it over Optuna standalone once you need multi-GPU or multi-node trials.
Core API
Search Space
| Function | Use Case | Example | |
|---|---|---|---|
tune.uniform(lo, hi) | Float range | tune.uniform(0.0, 1.0) | |
tune.loguniform(lo, hi) | Log-scale float (learning rate) | tune.loguniform(1e-5, 1e-1) | |
tune.randint(lo, hi) | Integer [lo, hi) | tune.randint(16, 256) | |
tune.choice(list) | Categorical | tune.choice(["adam", "sgd"]) | |
tune.grid_search(list) | Exhaustive | tune.grid_search([32, 64, 128]) | |
tune.quniform(lo, hi, q) | Quantized float | tune.quniform(0.1, 1.0, 0.1) | |
tune.sample_from(fn) | Custom | tune.sample_from(lambda _: 2**np.random.randint(4,8)) |
Example: PyTorch + ASHA Early Stopping
Schedulers
| Scheduler | Best For | Key Idea | |
|---|---|---|---|
| ASHA | Large search, limited budget | Aggressively kills bad trials early | |
| PBT | Long training (LLM fine-tuning) | Mutates hyperparams mid-training from top performers | |
| MedianStopping | Conservative early stopping | Stops below-median trials | |
| BOHB | Bayesian + banding | Combines TPE search with HyperBand scheduling |
PBT (Population-Based Training)
Search Algorithms
Optuna (Recommended Default)
HyperOpt (TPE)
Integration with Ray Train
Tuner(trainer) is deprecated as of Ray 2.43 (and already removed under Train V2 / RAY_TRAIN_V2_ENABLED=1). Use a function-based driver that builds the TorchTrainer inside the trial and calls trainer.fit(); surface Train metrics to Tune with a TuneReportCallback.
See: https://docs.ray.io/en/latest/train/user-guides/hyperparameter-optimization.html
Tips
| Tip | Why | |
|---|---|---|
Start with num_samples=20 + ASHA | Fast signal on what matters | |
Use loguniform for learning rate | LR spans orders of magnitude | |
Use choice for architecture decisions | Discrete, not continuous | |
Set grace_period ≥ 5-10 epochs | Don't kill trials before they warm up | |
| PBT for expensive training (>1h/trial) | Reuses compute from top performers | |
| Always report checkpoints | Enables resume after failure |
References
- Official docs: https://docs.ray.io/en/latest/tune/index.html
- Key concepts: https://docs.ray.io/en/latest/tune/key-concepts.html
- GitHub: https://github.com/ray-project/ray
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/ml-review/references/ml-libraries/ray/tune/SKILL.md
Popularity
- Repository stars
- 3
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hung-phan/ml-skills/tune)