← Back to Pull requests

Add JIT preemption checkpointing with pvc/s3 checkpoint storage #145

Merged
Sridhar1030 merged 14 files (2812 lines) on Oct 07, 2026 16:30 UTC
View on GitHub
Sridhar1030 Sridhar1030 commented on Sep 02, 2026 10:27 UTC
Author

Summary

Adds JIT (just-in-time) preemption checkpointing to Training Hub as default-flow callbacks, so any consumer (Kubeflow SDK, Ray, direct use) gets SIGTERM-safe checkpoint-and-resume for free — no SDK-side instrumentation needed.

API (all of sft(), osft(), lora_sft()):

lora_sft(
    ...,
    enable_jit_checkpoint=True,          # SIGTERM -> save checkpoint -> stop; auto-resume on restart
    checkpoint_storage="s3://bucket/x",  # or "pvc"/None (default): filesystem only
)

Design

  • One unified API, per-backend mechanisms. merge_default_callbacks() prepends hub default callbacks before user callbacks (hub hooks run first, per design discussion):

  • - lora_sft (Unsloth/HF): new JITCheckpointCallback — SIGTERM handler, save via HF TrainerControl.should_save (full trainer state), .incomplete sentinel for interrupted saves, resume via trainer.train(resume_from_checkpoint=...) decided in the backend before training starts.
    - sft (instructlab-training) / osft (mini-trainer): delegate to the backends' native on_demand_checkpointing — they already own SIGTERM handling, distributed save, and auto-resume. Re-implementing in a callback would double-register signal handlers.
  • Loud failure over silent no-op: older instructlab-training / mini-trainer silently drop unknown TrainingArgs fields; requesting JIT on those now raises with an upgrade hint (instructlab-training >=0.16.2, mini-trainer >=0.8.3).

  • checkpoint_storage selector: None/"pvc" = filesystem (SDK mounts the PVC and passes a path — unchanged behavior). "s3://bucket/prefix" = S3CheckpointSyncCallback mirrors every saved checkpoint to S3 in the background (layout-preserving, .upload_complete marker written last), and on restart with an empty local dir the latest complete checkpoint is restored from S3 before training resumes. MinIO/on-prem supported via AWS_ENDPOINT_URL(_S3).
  • Testing

    Cluster e2e (OpenShift, A100, real oc delete pod SIGTERM, pod restart, resume, completion):

    | Leg | Result |
    |---|---|
    | lora_sft kill/resume (hub callback) | ✅ 5/5 checks |
    | sft kill/resume (instructlab native, 0.16.2) | ✅ 5/5 |
    | osft kill/resume (mini-trainer native, 0.8.3+) | ✅ 5/5 |
    | Edge: eval-enabled JIT save | ✅ |
    | Edge: injected corrupt .incomplete checkpoint skipped on resume | ✅ |
    | Unit tests | ✅ 50/50 |

    Draft — remaining before ready-for-review

  • S3 e2e on cluster (MinIO harness written; blocked on cluster access at time of drafting)

  • Docs: enable_jit_checkpoint, checkpoint_storage, backend version floors

  • Declare boto3 as an optional extra (e.g. [s3]) in pyproject.toml

  • Multi-node distributed validation
  • Findings for reviewers / platform team

  • instructlab-training exits 0 after a preemption save — a plain k8s Job marks it Complete and never restarts it (podReplacementPolicy + replacement policy considerations apply for the SDK/controller).

  • instructlab auto-resume crashes permanently on a truncated full_state (no sentinel validation upstream).

  • RWO PVC: a replacement pod mounting the volume while the dying pod is still saving corrupts the checkpoint (SELinux relabel revokes the old pod's write access). podReplacementPolicy: Failed avoids the overlap.
  • Jira: RHOAIENG-38119

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

    Summary by CodeRabbit

    New Features
    Added just-in-time checkpointing to preserve training progress during preemption and resume automatically.
    Added configurable remote object storage for checkpoint synchronization and restoration, with support for multiple storage backends.
    Added validation to resume from the latest complete checkpoint in the selected training format while ignoring incomplete checkpoints.
    Added callback support for requesting checkpoint saves and safely stopping training.
    Added checkpoint mirroring across supported training backends, with upload failure detection.
    Documentation
    Added a guide covering JIT checkpointing, remote storage options, deployment, and troubleshooting.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 2812 lines (+2763 / -49) across 14 files Reviewer: efazal Review duration: 50763m
    All Vouch review confidence checks passed
    Residual risk 0.12 = Change Risk (0.62) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.62 · 2812 lines diff across 14 files
    0.62
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.66 · 1 substantive comment(s)
    0.66
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    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 #145"
    general weight: 0.35
    Reviewers
    Assignees
    Sridhar1030 Sridhar1030
    Labels
    risk: low confidence: 81.4% 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: 62.1% (MEDIUM) · Higher = larger blast radius
    62.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: 81.4% · Lower = rushed or shallow review
    81.4%
    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: 11.5% · Safe to merge
    11.5%