Add templated SFT notebook (#69) #74
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 612 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.384
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #74"
general
weight: 0.35
RobotSail
Resolves part of #69 — adds the SFT templated notebook. OSFT and LoRA versions are out of scope for this PR but can follow the same pattern.
What's in this PR
A new
examples/notebooks/templated_sft.ipynbthat lets a user with a dataset and a base model fine-tune by setting four hardware inputs and running through. The notebook does the memory-influencing hyperparameter calculation for them.Inputs the notebook asks for
| Input | Description | Default |
|---|---|---|
|
model_path| HuggingFace ID or local path |Qwen/Qwen2.5-1.5B-Instruct||
num_gpus| GPUs per node |1||
num_nodes| Number of nodes |1||
vram_per_gpu_gb| Per-GPU VRAM in GB |None→ auto-detect viatorch.cuda|How memory-influencing params are chosen
1. Per-GPU VRAM is auto-detected via
torch.cuda.get_device_properties(0).total_memorywhenvram_per_gpu_gbisNone. Otherwise the user's declared value is trusted.2. The notebook walks a list of candidate
max_tokens_per_gpuvalues (largest first: 16384, 8192, 4096, 2048, 1024, 512, 256), askstraining_hub.estimate(training_method="sft", ...)for the expected memory at each, and picks the largest value whose expected usage falls withinsafety_margin vram_per_gpu_bytes(default safety margin 0.90).3. If even the smallest candidate doesn't fit, the cell raises a
RuntimeErrorlisting the obvious options: smaller model, more/larger GPUs, LoRA instead of full SFT, or lowering the safety margin.The rest of the config
Conservative defaults for
num_epochs(3),effective_batch_size(1 per GPU),learning_rate(2e-5), andmax_seq_len(min(4096, max_tokens_per_gpu)to respect the training_hub constraint). The notebook's "Where to go from here" section calls these out explicitly as knobs to tune after the first run is stable.The final cell calls
training_hub.sft(...)with all parameters wired through, includingnproc_per_nodeandnnodesso multi-node works by just raisingnum_nodes.Scope decisions worth flagging
estimate→training_method="osft", addunfreeze_rank_ratioto inputs, swapsft→osft) and LoRA (useLoRAEstimator, swap tolora_sft, addlora_rto inputs). Happy to do those as follow-ups or in this PR if you'd prefer one combined review.data_path/ckpt_output_dirvalidation. The notebook uses placeholder strings and asks the user to update them before running the launch cell. Adding dataset-format validation feels like a bigger scope question — the comprehensive tutorial covers it.vram_per_gpu_gbexplicitly.Validation
nbformat 4.5JSON; all six code cells parse as valid Python (ast.parse).sft()andestimate()parameter names were cross-checked againstsrc/training_hub/algorithms/sft.pyandsrc/training_hub/profiling/memory_estimator.py.Open questions
1. Candidate list and safety margin. I picked
[16384, 8192, 4096, 2048, 1024, 512, 256]andsafety_margin=0.90by eyeballing the existingrunnable_l40_sft.ipynb(which uses 8192) and the memory_estimator example (which talks about a 1.3x upper bound). Are there established values you'd rather use?2. Default model. Picked
Qwen/Qwen2.5-1.5B-Instructbecause it matches the existing runnable SFT notebook. Open to a different default if you prefer Granite or something else as the canonical starter.3. File location. Placed at
examples/notebooks/templated_sft.ipynbalongside the existing notebooks. Happy to move (e.g., toexamples/notebooks/templated/sft.ipynb) if you'd rather group templated notebooks separately.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added a templated Supervised Fine-Tuning notebook that guides users through hardware setup, validates GPU/node inputs, and auto-detects VRAM when not provided.
Automatically chooses a safe token limit based on available memory, shows expected usage and utilization, and provides clear feedback if no configuration fits.
Sets up training parameters and launches distributed fine-tuning across the selected GPUs and nodes.
Documentation
* Includes detailed in-notebook guidance, limitations, and next-step recommendations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->