← Back to Pull requests

Add InstructLab and Mini-Trainer adapters for TrainingHubCallback (RHOAIENG-77627) #141

Merged
Sridhar1030 merged 12 files (1091 lines) on Aug 06, 2026 19:42 UTC
View on GitHub
Sridhar1030 Sridhar1030 commented on Aug 05, 2026 10:11 UTC
Author

Summary

Extension of #128 (RHOAIENG-77626): completes unified callbacks across all Training Hub backends.

#128 added TrainingHubCallback + TrainingHubContext and the Unsloth adapter for lora_sft(callbacks=...). This PR adds the InstructLab and Mini-Trainer bridge adapters so the same callback API works on sft() and osft() — including torchrun serialization across the subprocess boundary.

Split 2 of RHOAIENG-54744. Closes RHOAIENG-77627.

What's included

| Piece | Details |
| --- | --- |
| adapters/serialize.py | Class-source encode/decode for torchrun boundary |
| adapters/distributed.py | HubCallbackDispatcher, native → TrainingHubContext mapping |
| adapters/instructlab.py | InstructLabCallbackBridge + adapt_hub_callbacks() |
| adapters/mini_trainer.py | MiniTrainerCallbackBridge + adapt_hub_callbacks() |
| sft() / osft() | callbacks= param wired through algorithm + backend |
| callbacks.py | Torchrun serialization constraints documented |
| Tests | tests/test_callbacks.py (+242 lines) |
| Examples | callback_smoke_instructlab.py, callback_smoke_mini_trainer.py |

Backend requirements

Requires native callback modules in upstream backends:

| Package | Minimum version |
| --- | --- |
| instructlab-training | 0.16.2 |
| rhai-innovation-mini-trainer | 0.8.3 |

Universal image tracking (not a merge blocker): RHOAIENG-81150

Test plan

  • pytest tests/test_callbacks.py (26 tests; mini bridge needs mini-trainer ≥0.8.3)

  • E2E on OC workbench: sft(callbacks=...) + osft(callbacks=...) with pinned backend versions

  • Verified import instructlab.training.callbacks + import mini_trainer.callbacks with 0.16.2 / 0.8.3
  • Smoke (GPU):

    python examples/scripts/callback_smoke_instructlab.py
    python examples/scripts/callback_smoke_mini_trainer.py
    

    Related

  • #128 — TrainingHubCallback + Unsloth adapter (merged)

  • RHOAIENG-81150 — universal image backend versions

  • RHOAIENG-79848 — Kubeflow SDK callbacks= (follow-up)
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added callback support to SFT and OSFT training workflows.
    Added lifecycle event reporting across InstructLab and Mini-Trainer backends.
    Added callback persistence and restoration for distributed training.
    Added standalone smoke-test scripts for both training workflows.

    Documentation
    Expanded callback documentation with backend support, distributed usage, and examples.
    Documented backend user-experience differences and configuration considerations.

    Tests
    Added coverage for callback dispatch, serialization, distributed execution, and backend integration.
    * Added a validation script for callback tests and optional smoke checks.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 1091 lines (+1072 / -19) across 12 files Reviewer: RobotSail Review duration: 2010m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.59) × (1 − Review Confidence (0.65)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 1091 lines diff across 12 files
    0.59
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.47 · 1 substantive comment(s)
    0.47
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    64%
    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.400
    Real PR Conversation Timeline
    1 comments
    "Review active on #141"
    general weight: 0.35
    Reviewers
    Assignees
    Sridhar1030 Sridhar1030
    Labels
    risk: low confidence: 64.7% 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: 59.1% (MEDIUM) · Higher = larger blast radius
    59.1%
    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: 64.7% · Lower = rushed or shallow review
    64.7%
    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: 20.9% · Safe to merge
    20.9%