Skip to content

fix(training): a calibration run takes the VRAM free at admission, not the number it read at plan time - #4914

Merged
joelteply merged 1 commit into
canaryfrom
fix/calibration-reads-free-at-admission
Oct 10, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/calibration-reads-free-at-admission

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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. (#4912's lane-replaced return didn't apply: the job never reached bind.)

Change (forge/training_admission.rs, the one owner of training admission):

  • TrainingNeed::{Measured(bytes), Calibrate}. Measured leases exactly that, as before. Calibrate reads available_for() under the serving gate on every attempt and leases what's free then, waiting on the authority only while nothing is.
  • bind receives the bytes actually granted.
  • The engine adapter sends Calibrate for an unmeasured shape, and sets memory_budget_mib and the residency record's reserved_bytes from 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 the Measured wrapper, 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/132 genome::fine_tuning pass.

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

…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
@joelteply

Copy link
Copy Markdown
Contributor Author

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 joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_mib for that chunk (footprint_from_refusal) and writes EngineRefused into the job's returnable file. The next plan is then Measured, and choose_chunk reads 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-time bytes == 0 failure 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.

@joelteply
joelteply merged commit 2462a10 into canary Oct 10, 2026
7 checks passed
@joelteply
joelteply deleted the fix/calibration-reads-free-at-admission branch October 10, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant