← Back to Pull requests

Add ITS Hub rollout adapter for GRPO training #83

Closed
unknown closed this pull request without merging on Jun 19, 2026 18:36 UTC
View on GitHub
unknown unknown commented on Jun 01, 2026 16:53 UTC
Author

Summary

  • Add ITSRollout adapter class that lets users plug ITS Hub inference-time scaling algorithms (BestOfN, SelfConsistency, BeamSearch, ParticleFiltering) into lora_grpo() as custom rollout functions

  • Add example script demonstrating usage with SelfConsistency and BestOfN

  • ART backend only — verl support is a follow-up
  • Motivation

    Users can already pass custom rollout_fn to lora_grpo() with the ART backend, but must manually implement generation logic. ITS Hub provides sophisticated generation strategies that produce higher-quality training signal for GRPO. This adapter bridges the two with minimum changes — one new file, no modifications to lora_grpo.py.

    Design

    ITSRollout is a picklable callable class that:
    1. Points ITS Hub's OpenAICompatibleLanguageModel at the training model's co-located vLLM server (using include_raw_choices=True to preserve full API response data)
    2. Runs the user's chosen ITS Hub algorithm to generate and select a response
    3. Converts the result to an art.Trajectory with the reward set by the user's reward function

    The user provides:

  • algorithm_factory — module-level function (lm) -> algorithm (picklable)

  • reward_fn — module-level function (response_text, task) -> float (picklable)

  • budget — candidates per rollout
  • Dependencies

    Requires ITS Hub with include_raw_choices support (merged in its_hub#226).

    Files changed

  • New: src/training_hub/algorithms/its_rollout.py — _dict_to_choice() helper + ITSRollout class

  • Edit: src/training_hub/__init__.py — export ITSRollout

  • New: examples/scripts/its_rollout_example.py — example with SelfConsistency and BestOfN
  • Test plan

  • Verify ITSRollout is importable: from training_hub import ITSRollout

  • Verify picklability: pickle.dumps/loads round-trips successfully (including mp.get_context("spawn"))

  • Verify no regressions on existing imports

  • End-to-end test with SelfConsistency on full GRPO training loop (requires openpipe-art)
  • Verified with real vLLM

    Tested against a live vLLM 0.9.1 server serving Qwen/Qwen2.5-0.5B-Instruct on an NVIDIA H100.

    _dict_to_choice conversion

  • Converts text response to OpenAI SDK Choice — correct finish_reason, message.role, message.content

  • Preserves tool_calls when present
  • _raw_choice correctness

  • _raw_choice present when include_raw_choices=True — keys: index, message, logprobs, finish_reason, stop_reason

  • No circular reference: result is not result["_raw_choice"]["message"] → True

  • json.dumps() succeeds (270 bytes) — no infinite recursion

  • JSON roundtrip preserves all data

  • _raw_choice absent when include_raw_choices=False (default behavior unchanged)
  • SelfConsistency end-to-end (budget=3)

  • ITSRollout._init_its_hub() creates OpenAICompatibleLanguageModel + SelfConsistency from mock ART model

  • 3 candidates generated via live vLLM

  • _raw_choice present on all candidates (flows through ITS Hub algorithm)

  • _dict_to_choice converts each candidate to OpenAI SDK Choice

  • json.dumps() succeeds on all responses (822 bytes)

  • Selected response correct ("180" for "What is 1215?"), reward=1.0
  • Picklability

  • pickle.dumps/loads roundtrip preserves budget, max_concurrency, all config

  • Lazy state (_lm, _algorithm) correctly None after unpickling

  • Works with mp.get_context("spawn") pickle protocol
  • Not yet tested

  • Full ITSRollout.__call__ with art.Trajectory construction (openpipe-art not installed in test venv)

  • BestOfN with LLMJudge as algorithm_factory

  • Full GRPO training loop with lora_grpo(rollout_fn=ITSRollout(...), backend="art")
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Release Notes

    New Features
    Added an ITS Hub–backed rollout adapter for GRPO training with selectable rollout strategies and custom reward scoring.
    Exposed ITSRollout in the public training_hub API.
    Added an example script to configure ITS rollout + LoRA-based GRPO training (including SelfConsistency and BestOfN options).

    Bug Fixes
    * Improved resilience by handling connection/timeout failures with a safe fallback trajectory during rollout.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 566 lines (+424 / -142) across 7 files Reviewer: RobotSail Review duration: 26023m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.55) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 566 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.379
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #83"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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.7% (MEDIUM) · Higher = larger blast radius
    54.7%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 21.6% · Safe to merge
    21.6%