Repository navigation
Widen the pinned child GPU mask when extra args name a companion device (#11810) - #11823
Conversation
|
Thanks for getting the #11810 reporter to confirm this on the V100 + 3060 Ti host. Widening the pinned mask only when --mmproj-device or --spec-draft-device names a hidden card, while pinning the main model with --device, looks like the right scope. Will get this reviewed. |
The widening compared the user's CUDA<n> tokens with physical ids and left the tokens as written, so: - main pinned to GPU 1 with --mmproj-device CUDA0 widened the mask to 1,0, where the child's CUDA0 is the main card, and the projector silently landed on GPU 1; - a companion on the pinned card itself (pin 1, CUDA1) was still an invalid device, since the one-card child only has CUDA0; - under an inherited mask such as CUDA_VISIBLE_DEVICES=2,3, CUDA0 was read as physical 0 and exposed a card the parent had hidden. Read the tokens through the inherited mask (skipping a uuid or MIG mask), from the launch argv so stripped flags change nothing, only for the flag that wins in each group, and rewrite them to the card's position in the child's mask. ROCm<n> tokens get the same treatment.
…ion widening - An explicit gpu_ids pin is the pool the training guard budgeted, so a companion flag is only renumbered within it and never adds another card to the child's mask. - With LLAMA_ARG_DEVICE inherited and no argv --device, widening would append a --device overriding the user's main-device choice, so that launch is left unchanged.
The widening numbers the companion flags and the generated main --device for the launch's mask. When a kernel-image crash respawns on other cards, the generated --device is dropped and the same fit runs again against the retry's mask, reading each token as a position in the crashed launch's mask, so the projector or drafter keeps its card and the main model gets the new ones.
|
Review record for #11823, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#177. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
Fixes #11810.
The pin is a placement constraint on the MAIN model only, but it surfaced as an absolute mask: when _select_gpus decides the main model + KV fit on one card, _emit_child_gpu_visibility sets CUDA_VISIBLE_DEVICES to that subset, and any --mmproj-device / -mmdev / --spec-draft-device the user's extra args name outside that set makes llama.cpp reject the flag at argument parsing as "invalid device". Studio's retry chain then misreads the reject as a fit and as a speculative-drafter failure and burns all four attempts on the same masked environment.
One change in the single-GPU pinning arm of load_model, applied after the inherited visibility order has resolved and rewritten the split and just before the mask becomes the child's environment: _widen_pin_ids_for_companion_devices parses the CUDA GPUs the extra args point commas-included at (reusing _extra_args_device / _extra_args_draft_device, now in the same table as the other device readers), unions any GPU the pin hides, and -- since the widened mask would otherwise spread the main model across it under -ngl -1 -- emits a --device naming the main model's original cards so they keep the placement the fit picked. llama.cpp numbers CUDA-n by position in the visible set, so the remap goes through the final widened mask; a user's own --device is never touched. Tokens that are not CUDA-n (cpu, none, HIP names) are ignored, so the widening is a no-op everywhere the flags already resolve.
Validated upstream by the reporter on a V100 + 3060 Ti host: the exact config that rejected all four attempts now starts (llama-server ready on port 10584, VRAM consistent with mmproj moving to GPU 1, main model staying on GPU 0).
tests/test_companion_device_widening.py pins the helper: hidden-companion widening, the CUDA-n remap under a non-ascending main order, no --device emitted when the user supplied one, an in-mask flag changing nothing, non-CUDA tokens ignored, the inline --flag=value spelling, comma lists, and last-wins among repeated flags. One unrelated pre-existing failure in tests/test_gpu_selection.py (Could not determine home directory under {'CUDA_VISIBLE_DEVICES': 'GPU-aaa,GPU-bbb'} env-clearing) reproduces identically with the change stashed; everything nearby (204 tests + 94 subtests) passes.