Repository navigation
fix(training): a calibration run takes the VRAM free at admission, not the number it read at plan time - #4914
Conversation
…sion, not the number it read at plan time Measured on the 5090 2026-10-10 (job a7893e09, Kimi's 18 'code' examples): an unmeasured shape plans as a calibration run that leases "everything governed and free". The plan read 7.05 GB free while serving was mid-handoff at a 6k window; serving then re-homed to 68k, and the job waited in admission for 7.05 GB with 4.26 GB free, with no way out, until a hand cancelled it. training_admission takes a TrainingNeed: Measured(bytes) leases exactly that, as before; Calibrate reads available_for() under the serving gate on every attempt and leases what is free then, waiting on the authority only while nothing is. bind receives the bytes granted. The engine adapter sends Calibrate for an unmeasured shape, and takes memory_budget_mib and the residency record's reserved_bytes from the GRANTED lease. A plan-time zero no longer fails the job (it was exactly the handoff window). wait_for_training_memory(bytes) stays as the Measured wrapper, so the CUDA and MLX callers are unchanged. Test: everything is free at plan; serving then takes 768 of 1024; the calibration admission completes at once with a 256-byte lease and binds with 256. 132 genome::fine_tuning pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
|
Approve at a3bfd85, Fable (M5), as a comment (shared account), pending green. A closed TrainingNeed instead of a zero sentinel; Calibrate re-reads availability under the serving gate on every attempt and waits on the change channel when nothing is free instead of failing the job; bind and the engine budget take the GRANTED bytes. The test reproduces today's 5090 case (everything free at plan, serving takes most, the run leases what is left). Non-blocking: a calibration run still takes all that is free, as before; once its footprint is filed the next run is Measured, so it is a one-run cost. |
joelteply
left a comment
There was a problem hiding this comment.
Approve once the two pending lanes are green. The fix is in the right place: the number a calibration run leases is read under the serving gate, at the moment it's granted, and both the residency record and memory_budget_mib take the granted bytes. That removes the plan-time read that a7893e09 waited on forever.
What I checked:
- A small grant doesn't leave a bad record. If Calibrate is granted less than the graph needs, the engine refuses before allocating. That refusal records the true
graph_mibfor that chunk (footprint_from_refusal) and writesEngineRefusedinto the job's returnable file. The next plan is thenMeasured, andchoose_chunkreads that footprint against what's free when it plans. So a moment of low memory costs one engine attempt and leaves an accurate footprint behind. Nothing ratchets the chunk down for good, and no number becomes an admission gate. - Waiting at zero. With nothing free under the gate, the loop drops the hold, reports
waiting(0)once and waits for the authority to change. It doesn't spin, and the plan-timebytes == 0failure is rightly gone. - The test fails if anything still leases the plan-time number, and it checks that the bind sees the granted bytes, not the planned ones.
Nit (it doesn't block): under Calibrate, the waiting closure still reports the plan-time bytes as the need (progress.waiting_for_capacity(bytes, available)). So a waiting calibration run says it needs 7.05 GB while it actually waits for any free memory. Reporting the need as "calibrate: whatever is free" would make the wait read true.
Measured on the 5090, 2026-10-10 (job a7893e09, Kimi's 18
codeexamples): an unmeasured shape plans as a calibration run that leases "everything governed and free". The plan read 7.05 GB free while serving was mid-handoff at a 6k window. Serving then re-homed to 68k, and the job waited in admission for 7.05 GB with 4.26 GB free, with no way out, until a hand cancelled it. (#4912's lane-replaced return didn't apply: the job never reachedbind.)Change (
forge/training_admission.rs, the one owner of training admission):TrainingNeed::{Measured(bytes), Calibrate}.Measuredleases exactly that, as before.Calibratereadsavailable_for()under the serving gate on every attempt and leases what's free then, waiting on the authority only while nothing is.bindreceives the bytes actually granted.Calibratefor an unmeasured shape, and setsmemory_budget_miband the residency record'sreserved_bytesfrom the granted lease. A plan-time zero no longer fails the job, since that was exactly the handoff window.wait_for_training_memory(bytes)stays as theMeasuredwrapper, so the CUDA and MLX callers are unchanged.Test (
a_calibration_run_takes_what_is_free_at_admission_not_at_plan): everything is free at plan; serving then takes 768 of 1024; the calibration admission completes at once with a 256-byte lease and binds with 256. 132/132genome::fine_tuningpass.Follow-up (a) from gene 1's receipt; it completes the stranded-run case #4912 covers at bind.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc