/spml:ml-runtime-validatorfrom spml
Runs a 6-stage ML runtime validation pipeline: data loading, model instantiation, training with performance/health metrics, checkpoint, inference, and evaluation.
Ships in spml. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Run a sequential 6-stage pipeline: load data, instantiate model, train for an estimated 5 minutes of training volume (collecting performance and health metrics), then verify checkpoint save/load, inference, and evaluation. One run, one unified report.
L1 is validation, not the experiment. The full training run happens later via spml:training-handoff → spml:watchdog.
This is a RIGID skill. Run all 6 stages. Don't skip stages. Don't skip metrics collection.
[INTEGRATION] subtask in spml:ml-subagent-dev, after L0 (spml:ml-static-checks) passesspml:ml-iteration, spml:autoresearch) since each round is itself an integration deliveryUser declares during brainstorming which data flow to use:
Stage 1: Data Loading
- Load N batches, verify shapes, no NaN/Inf in inputs
- Verify DataLoader iterator doesn't crash or hang
Stage 2: Model Instantiation
- Create model with training config
- Pass one batch through forward pass
- Verify output shape correct, no errors
Stage 3: Training (~5 min estimated training volume)
- forward + backward + optimizer.step
- Collect simultaneously:
· Performance: MFU, TCA, throughput, memory
· Health: loss trend, gradient health, parameter drift
· Architecture-specific checks (see below)
· Logging output validation (see below)
Stage 4: Checkpoint
- Save model state_dict and optimizer state_dict
- Load into fresh model instance
- Verify all parameters match (torch.allclose), optimizer state restored
Stage 5: Inference
- Switch to eval mode
- Run N forward passes
- Verify no NaN/Inf in outputs, deterministic (if seeds set)
Stage 6: Evaluation
- Compute evaluation metrics on N batches
- Verify metrics are finite numbers, metric function doesn't crash
| Category | Metric | Source |
|---|---|---|
| Performance | MFU | FlopCounterMode + CUDA Events |
| Performance | TCA | DCGM field 1004 |
| Performance | Sample/Token throughput | batch_size / step_time |
| Performance | Memory usage | peak / allocated / fragmentation |
| Training health | Loss trend | Whether loss is decreasing (not absolute value) |
| Training health | Gradient health | NaN/Inf, exploding/vanishing detection |
| Training health | Parameter drift | Parameters updating, drift rate |
Load based on model architecture:
| Architecture | Metric | What to check |
|---|---|---|
| Transformer | Attention entropy | Not collapsed (all mass on one token) or uniform (no learning) |
| MoE | Expert load balance | Experts receiving roughly equal traffic, aux loss active |
| RecSys | Embedding stability | Embedding norms not diverging, negative sampling working |
| LLM | KV cache growth | Memory growth linear with sequence length, not quadratic |
| ResNet | Residual write ratio | Residual branch contributing meaningful signal |
Checks that the training code's logging actually produces correct output at runtime. Each check validates three layers: existence → frequency → value correctness.
| # | Check | Severity | Validation Method |
|---|---|---|---|
| L.1 | Loss file output correctness | Mandatory | File exists, non-empty, parseable format; values reasonable (no all-NaN/Inf/zero, trend consistent with gradient behavior) |
| L.2 | Step speed output correctness | Mandatory | File exists, non-empty; values match wall clock (step count × reported step time ≈ actual elapsed time) |
| L.3 | Data loading duration correctness | Advisory | Duration record exists; values reasonable (non-zero, non-negative, consistent with actual time window) |
| L.4 | Output frequency reasonableness | Advisory | Console: tqdm refresh interval or print output interval is approximately minute-level. File: actual log entry timestamps have intervals approximately minute-level. Complements L0 check 22 |
| L.5 | Console metrics correctness | Advisory | Progress bar total matches training target; advance rate matches actual speed. Console output (tqdm postfix or print) includes key runtime metrics (at least loss); metric values are consistent with those recorded in file logs |
| L.6 | Visualization tool output correctness (if enabled) | Mandatory | Output directory/API has data; frequency reasonable; values cross-validated against loss/speed files for consistency; skip if not enabled |
| L.7 | Checkpoint periodic saving | Advisory | During L1 training (~5 min), at least one checkpoint file is produced (if configured interval should trigger within 5 min); checkpoint file is non-empty and loadable (reuse Stage 4 verification logic) |
Two tiers of thresholds:
During brainstorming, user defines acceptable minimums for key metrics. Examples:
These are stored in the experiment design doc and checked during L1. If no baselines are declared, L1 only checks for anomalies.
Catches obvious problems regardless of baselines:
L1 is a validation step, not the experiment itself. You MUST limit training to a short run.
Default: An estimated 5 minutes of training volume. User can override during brainstorming.
How to limit — in order of preference:
--max_steps=N or --epochs=M or equivalent flag directly to the training script. Estimate step count to yield ~5 minutes of training. This is the most reliable method.epochs/max_steps, and pass it to the script. Keep this config file next to the training script for traceability.Do NOT monkey-patch runtime objects (e.g., patching trainer.max_epochs after construction). Monkey-patches fail silently when internal APIs change, causing L1 to run the full experiment.
Verification (mandatory): Within the first 30 seconds of L1 execution, confirm that the training process reports the expected limited total (e.g., "Training for M epochs" or "Total steps: N" in the log). If the log shows the full experiment total (e.g., 80 epochs), kill immediately — the limiting didn't work. This counts as a failure and enters the fix loop.
Total timeout: 15 minutes for the entire L1 run (all 6 stages).
Timeout is a safety net, not the limiting mechanism. If L1 hits timeout, it likely means training volume estimation was wrong or a stage hung. Treat timeout as a bug to investigate, not an expected path.
Background execution liveness check: When L1 dispatches stages to background execution, the orchestrator MUST monitor:
Start runtime validation (6 stages)
-> Background execution with 30s liveness checks
-> Total timeout: 15 minutes
-> Normal completion -> check all metrics + stage results
-> Timeout -> kill process
-> Analyze hang cause (deadlock, communication block, data loading stuck, stage hung)
-> Send to Implementer for fix
-> Counts toward 5-retry limit
Critical: Do NOT dispatch to background and then wait indefinitely. A hung process with no timeout detection will stall the entire VP flow.
Reuse existing toolkit/profiling/ for performance metrics:
l0_runner.py — main entry for performance collection (named after old L0, used by L1)mfu_calculator.py, dcgm_profiler.py, gap_analyzer.py — unchangedmemory_profiler.py, layer_profiler.py — unchangedTraining health metrics (gradient hooks, loss recording, arch-specific monitors) are written per-project by the Implementer. Skills guide what to collect; toolkit extraction happens only after proven need.
When a metric fails, decompose to find root cause before fixing:
Overall metric not meeting target
-> Decompose into substructures
-> Profile each substructure
-> Locate bottleneck
-> Drill to operator level if needed
Example: MFU low -> per-layer profiling -> attention layer 3x slower than expected -> missing FlashAttention on that layer.
=== L1 Runtime Validation Report ===
[Data Loading] PASS 5 batches loaded, shapes correct
[Model Init] PASS output shape [B, C] matches expected
[Training] PASS 150 steps, 4m52s
MFU: 38.2%
Throughput: 12.4k tokens/sec
Peak Memory: 24.3 GB
Loss: 2.41 -> 1.87 (down 23%)
Gradients: healthy (no NaN/Inf)
Param Drift: normal
[Checkpoint] PASS save/load match (max diff: 1e-7)
[Inference] PASS 5 passes, deterministic
[Evaluation] PASS metrics computed (acc: 0.34)
RESULT: PASS (6/6 stages)
Total time: 5m38s
Uses the shared fix loop from spml:validation-pyramid:
Issues found across the 6 stages:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub qqhard/superpowers-ml --plugin spml17 skills in this plugin
/autoresearchUse when running an automated research loop — reads protocol, dispatches Researcher subagent, runs eval + compliance, manages git state, accumulates experience across iterations/autoresearch-createUse when the user wants to start an Auto Research workflow - explicit entry point that activates autoresearch mode and routes into brainstorming for protocol definition/autoresearch-handoffUse after VP passes when the experiment needs automated iteration — verifies base code, generates research protocol, and produces startup prompt for autonomous exploration/autoresearch-runUse when the user wants to execute an Auto Research loop - explicit entry point that locates the protocol and starts the autonomous iteration/data-preparationUse when constructing or transforming datasets for training - guides TDD-first workflow to validate data processing logic on small-scale data before running full-scale/diagnosticsUse when ML training isn't converging, shows anomalous behavior, or runs too slowly - systematic diagnosis for training failures, early anomalies, and efficiency bottlenecksOther plugins' skills for the same job