Skip to content

feat: share a GPU across jobs by declared VRAM with a live free-VRAM check - #184

Merged
ycpss91255 merged 4 commits into
mainfrom
feat/issue-180-gpu-vram-share-v2
Nov 29, 2026
Merged

ycpss91255 merged 4 commits into
mainfrom
feat/issue-180-gpu-vram-share-v2

Conversation

@ycpss91255

Copy link
Copy Markdown
Member

Summary

GPU jobs can now share one GPU by declaring VRAM with a vram-gb-<N> / vram-gb-all runs-on label. The listener admits a job onto a GPU only when declared VRAM fits the per-GPU budget and live free VRAM still covers the reserve, pins the job to that GPU, and records peak VRAM in the job history ledger.

Motivation

Today a gpu job holds a whole GPU, so small jobs waste most of the VRAM and other users' workloads (for example Isaac training) are not accounted for. Declared VRAM gives a budget; a live nvidia-smi check protects processes the listener did not start; recorded peaks let repos pick N from data (#104, #80).

Changes

  • vram-gb-<N> / vram-gb-all labels (1..128 or all, case-insensitive, largest wins, N above budget = whole GPU); no label = whole GPU as before.
  • Per-GPU budget floor(vram_total_gib * (1 - reserve)), gpu reserve default 20, upward-only.
  • Live free-VRAM check before admission; GPU selection packs several jobs per GPU when they fit; job pinned to the chosen GPU only.
  • Charge after worker slot + ctx check, release on exit and every failure path (same pattern as Refactor and review the declared job size code (backfill for #171, #172, #176) #177).
  • Peak VRAM recorded in runner-history.
  • VRAM read via thin bash probe; Go does the math (ADR-0003). cpu path (ADR-0006) unchanged.
  • Fail safe when nvidia-smi fails: whole GPU, one job per GPU.
  • gpu sample type (deploy + listener/testdata, identical) lists vram-gb labels.
  • ADR-0007, deploy/README.md, CHANGELOG.

Test plan

  • Unit tests for label parsing, budget math, GPU selection, charge/release paths
  • bats tests for the gpu probe
  • cpu admission tests unchanged and passing
  • Deploy to gpu hosts and verify sharing (separate step)

Notes

Stage commits:

  • 38e8ee0 test: admit gpu jobs by declared VRAM per GPU, pin and record peak VRAM
  • 13eee68 feat: admit gpu jobs by declared VRAM per GPU, pin them and record peak VRAM
  • 97cde5f refactor: share the reserve budget floor and name the mode reserve floor
  • 0b85a35 fix: address review findings

Known limits: nothing caps VRAM (no MIG on RTX 5090 / RTX 2000 Ada; MPS/HAMi cap CUDA only, Isaac/Kit render via Vulkan), shared compute slows jobs, Isaac needs pid: host (#80). Refs #104, #80.

Closes #180

Rebased onto the rewritten main (replaces #183, which was based on the old history). just check passes; Go coverage is 95.2%.

…AM (#180)

Specify shared-GPU admission (owner decisions 2026-11-29):
- vram-gb-<N>/vram-gb-all labels, no label holds the whole GPU
- per-GPU budget floor(total*(1-reserve)), reserve default and floor 20
- live free VRAM must keep the reserve; pick the lowest-index GPU that fits
- charge after the worker slot and ctx check, release on every failure path
- fail-safe on probe error: whole GPU, one job per GPU, last known GPUs
- pin via RUNNER_GPU -> NVIDIA_VISIBLE_DEVICES and filtered /dev/nvidia<N>
- gpu-probe.sh line format; GPU peak VRAM, index and declaration in the ledger
- sample gpu type moves to mode: vram with the vram-gb-* labels
…ak VRAM (#180)

A gpu type with concurrency mode vram admits each job on the lowest-index
GPU where its vram-gb-<N> declaration (none = the whole GPU) fits the
per-GPU budget and the live free VRAM keeps the reserve (default and
minimum 20). VRAM is charged after the slot and ctx check and released on
every exit path. The job is pinned to that GPU via its /dev/nvidia<N> node
and NVIDIA_VISIBLE_DEVICES, a failing probe falls back to one whole-GPU job
per GPU, and the ledger records the GPU's peak used VRAM. Adds ADR-0007.
…oor (#180)

coreBudget, memBudget and vramBudget now share reserveBudget and a named floatSlack, and validateConcurrency reads Concurrency.reserveFloor; no behaviour change.
- Pick the GPU and run the live reserve check after the worker slot is
  acquired, so dispatch never uses a reading taken before a slot wait.
- An unpinned fail-safe job now holds the whole host until it exits,
  even if the GPU probe recovers mid-job; snapshots report zero then.
- Filter /dev/nvidia<N> by the nvidia-smi minor number (gpu-probe.sh
  now reports it), not the index, and handle host:container mappings;
  NVIDIA_VISIBLE_DEVICES keeps the index.
- Probe parsing rejects duplicate index/minor and out-of-range memory
  readings; probe and sampler nvidia-smi calls are time-bounded.
- vram-gb-* accepts only 1,2,4,8,16,32,64,128,all; other values fall
  back to whole-GPU. An explicit vram reserve is clamped to the floor.
- The peak sampler exits when provision-job.sh dies (no orphan loop),
  is stopped in the EXIT trap, and a sampler failure never fails the
  job. The ledger records vram_charged_gb and vram_peak_scope
  (whole_gpu, or unavailable for an unpinned fallback job).
- The cpu budget code is restored to main verbatim (no cpu change).
- Capacity snapshots also respect free worker slots.
- Docs (ADR-0007, deploy/README.md, listener/README.md, CHANGELOG) and
  the sample types aligned with the behaviour above.
- Test stub resolves the real mktemp path instead of /usr/bin/mktemp.
@ycpss91255
ycpss91255 enabled auto-merge November 29, 2026 11:02
@ycpss91255
ycpss91255 added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit ae7c5c2 Nov 29, 2026
9 checks passed
@ycpss91255
ycpss91255 deleted the feat/issue-180-gpu-vram-share-v2 branch November 29, 2026 11:06
@ycpss91255

Copy link
Copy Markdown
Member Author

Red evidence (backfilled)

Stage 1, 38e8ee0 test: admit gpu jobs by declared VRAM per GPU, pin and record peak VRAM (#180). This is the test-stage report from the tdd workflow; the raw command output was not kept.

just lint: passes
just test-unit / just test-integration: only the new #180 tests fail (5 unit, 7 integration),
  each for the missing behaviour:
  - no gpu-probe.sh
  - no NVIDIA_VISIBLE_DEVICES pin before the image
  - no gpu ledger fields (gpu_index, vram_declared_gb, gpu_used_peak_mib)
  - sample still `mode: auto`
just coverage-go: fails at compile time on the undefined new API
  (GPU, GPUProbe, jobVRAM, ...)  -> COMPILE-ONLY RED for the Go tests

To check the Go tests apart from the missing API, the workflow built a scratch copy of the package with empty stand-ins for the new names. In that copy only the new or updated tests failed, and the rest of the suite, including all cpu tests, passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share a GPU across jobs: declared vram-gb-<N> plus a live free-VRAM check

1 participant