← Back to Pull requests

Add CLI for Training Hub (thub command) #103

Merged
Maxusmusti merged 4 files (353 lines) on Sep 24, 2026 21:24 UTC
View on GitHub
Maxusmusti Maxusmusti commented on Jun 22, 2026 16:14 UTC
Author

Summary

  • Adds thub CLI command with subcommands for all 6 training algorithms: sft, osft, lora-sft, lora-grpo, grpo, gepa

  • Supports YAML config files (--config/-c) with CLI argument override precedence

  • Callable parameters (e.g., reward_fn, rollout_fn, iteration_callback) accept dotted import paths (e.g., my_module.my_reward_fn) that are resolved at runtime

  • JSON parameters (e.g., seed_candidate, lr_scheduler_kwargs) are parsed from JSON strings

  • Adds pyyaml>=6.0 to dependencies and [project.scripts] entry point
  • Usage examples

    # Direct argument passing
    thub sft --model-path ./model --data-path ./data.jsonl --ckpt-output-dir ./out
    
    # YAML config file
    thub osft --config my_config.yaml
    
    # Config file with CLI overrides (CLI wins)
    thub lora-grpo --config base.yaml --learning-rate 1e-3
    
    # Callable via dotted import path
    thub grpo --config grpo.yaml --reward-fn my_rewards.compute_reward
    

    YAML config format

    model_path: Qwen/Qwen3-4B
    ckpt_output_dir: ./output
    data_path: ./data.jsonl
    reward_fn: my_module.my_reward_function  # dotted import path
    num_iterations: 10
    learning_rate: 5e-6
    n_gpus: 4
    

    Test plan

  • thub --help shows all subcommands

  • thub --version shows the installed version

  • thub <algo> --help works for all 6 algorithms (sft, osft, lora-sft, lora-grpo, grpo, gepa)

  • Missing required params produces clear error with hint about --config

  • YAML config loading and type coercion (int, float, bool, str) verified

  • CLI args correctly override config file values

  • Dotted import path resolution works for training_hub.algorithms.rewards.tool_call_reward and stdlib functions

  • Invalid dotted paths produce clear error messages

  • thub entry point installed and functional via pip install -e .

  • End-to-end training run via thub (not tested — requires GPU + model download)
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added the thub command-line interface with subcommands for sft, osft, lora-sft, lora-grpo, grpo, and gepa.
    Configure runs with YAML files using --config; command-line options take precedence over values in the file.
    Supports boolean values in common formats and JSON-encoded parameters.
    Displays dictionary results as JSON and reports errors with clear messages. Use --traceback to view detailed error information.
    Check the command’s version with --version. Invalid YAML configuration and missing required parameters are reported as errors.
    * Interrupting a run exits gracefully with a status code.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 353 lines (+264 / -89) across 4 files Reviewer: None requested Review duration: 135670m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.55) × (1 − Review Confidence (0.44)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 353 lines diff across 4 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.351
    Shallow Review Depth shallow_review_depth
    0.344
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 comments
    "Review active on #103"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    Maxusmusti Maxusmusti
    Labels
    risk: low confidence: 44.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 54.5% (MEDIUM) · Higher = larger blast radius
    54.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.2% · Lower = rushed or shallow review
    44.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.4% · Safe to merge
    30.4%