← Back to Pull requests

fix: stub wandb so lora_grpo survives without it in ART 0.5.18 #150

Merged
Maxusmusti merged 2 files (101 lines) on Sep 24, 2026 19:57 UTC
View on GitHub
Maxusmusti Maxusmusti commented on Sep 23, 2026 19:00 UTC
Author

Problem

lora_grpo with backend="art" hangs forever after the first training iteration when wandb is not installed, silently returning partial results.

Root cause chain (reproduced deterministically 3× on H100, diagnosed via py-spy + an asyncio task dump of the training subprocess):

1. ART 0.5.18 bug: LocalBackend.train() unconditionally calls model._get_wandb_run() after each training step to record W&B provenance, and _get_wandb_run() does import wandb before checking whether WANDB_API_KEY is set. Without wandb installed, this raises ModuleNotFoundError right after iteration 1's train → wake → LoRA adapter load.
2. The exception kills vLLM: it unwinds into _run_training's cleanup, which shuts down the vLLM runtime — the sleep/wake log ends with an unexpected "Shutting down" immediately after the first wake + load_lora_adapter.
3. The hang: due to nest_asyncio re-entrancy in the trainer task (blocked inside a nested asyncio.run waiting on the inputs queue), the cancellation in ART's cleanup never delivers. The exception stays trapped in the completed main task, asyncio.run can't return, and the subprocess never exits — no error file, no traceback. The parent sits in proc.join() until TRAINING_HUB_JOIN_TIMEOUT and returns the partial iteration-1 results.

Fix

_install_wandb_stub() — same pattern as the existing megatron bridge stub for ART 0.5.18. When the real wandb is absent and no WANDB_API_KEY is configured, install a minimal no-op wandb module into sys.modules before importing art. In that configuration _get_wandb_run() returns None immediately after the (stubbed) import, so no wandb functionality is ever exercised. If the real wandb is installed, or an API key is set but the package is missing, the stub is not installed so the genuine behavior/error surfaces.

Validation

Functional, on H100 with training_hub v0.10.0, ART 0.5.18, trl 1.13.0, vLLM 0.28 runtime, torch 2.13.0+cu130 (the RHAI 3.6 EA2 lockfile stack):

| | before | after |
|---|---|---|
| iterations completed | 1/3 (hang) | 3/3 |
| mean reward per iter | 0.39 (partial) | 0.39 → 0.45 → 0.48 |
| vLLM sleep/wake cycles | 1, then "Shutting down" | 3/3, shutdown only at end |
| checkpoints | 0000–0001 | 0000–0003 |

Also:

  • new unit tests for the stub behavior (tests/test_lora_grpo_wandb_stub.py, 4 tests)

  • full local suite: 115 passed
  • Caveat: the underlying ART issue (unguarded import wandb) is worth reporting/fixing upstream too — the stub carries a "remove when ART guards the import" note, same as the megatron stub.

    🤖 Generated with Claude Code

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

    Summary by CodeRabbit

    Bug Fixes
    Improved training startup in environments without a W&B installation or API key. Existing W&B setups remain unaffected, and configured API keys continue to be respected. This helps avoid startup issues in setups that do not use W&B while preserving behavior when W&B is available or explicitly configured.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 101 lines (+101 / -0) across 2 files Reviewer: coderabbitai[bot] Review duration: 1497m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.56)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 101 lines diff across 2 files
    0.37
    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: 50%
    55%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.277
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #150"
    general weight: 0.35
    Assignees
    Maxusmusti Maxusmusti
    Labels
    risk: low confidence: 55.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: 37.1% (MEDIUM) · Higher = larger blast radius
    37.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: 55.7% · Lower = rushed or shallow review
    55.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: 16.4% · Safe to merge
    16.4%