Repository navigation
Studio FLUX.3 upsampler: pin the sidecar to the native sd.cpp image card - #14696
Conversation
_SdState records its card as physical_gpu_id, but the upsampler and the segmentation helper read placed_ordinal off the active engine state, so a native sd.cpp FLUX.3 load read as unplaced and llama-server launched with no device mask on multi-GPU hosts. Map physical_gpu_id back to the torch-visible ordinal through get_parent_visible_gpu_ids.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
[skip ci]
[skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Studio: pin the FLUX.3 prompt upsampler to the native sd.cpp image card
The Enhance prompt sidecar (#14137) finds the image model's card by reading
placed_ordinaloff the active engine's state. The diffusers state has that field. The native sd.cpp state (_SdState) does not: it records its card asphysical_gpu_id. So when FLUX.3 runs on native sd.cpp, the upsampler always reads "no card":On a host with more than one visible GPU, the on-demand launch then starts llama-server with no device mask. llama.cpp's default splits layers over every visible card, so the 6-7.5 GB sidecar can land on cards the image model never claimed, and the free-memory probe (
_accelerator_memory_mib(None)) and the laterrelease_if_tightread the current device rather than the card the sidecar uses. The speculative warm start already declined in this case ("placement"), but the first enhanced generate still launched unpinned.Change
_SdStategains a read-onlyplaced_ordinalproperty. It mapsphysical_gpu_idback to the torch-visible ordinal throughget_parent_visible_gpu_ids(), which is the same list_resolved_server_physical_gpu_idused to build the physical id. It returns None when:physical_gpu_idis None (CPU, Metal, Vulkan,--offload-to-cpu, automatic multi-GPU, one-shot mode), orUNSLOTH_DIFFUSION_SD_CPP_DEVICEoff-torch card, orIn all three cases the answer stays what it was before. Nothing assigns
placed_ordinalon an_SdState, and it is not a dataclass field, so construction,replace()and equality are unchanged.The upsampler and the segmentation helper both read
placed_ordinalthroughgetattr, so both now see the native card. For the upsampler that means_child_device_maskpins llama-server to the image model's card (honouring a parentCUDA_VISIBLE_DEVICES/HIP_VISIBLE_DEVICESmask), the memory probe reads that card, and the warm start no longer declines a resolvable native placement. Single-GPU hosts are unchanged, since_child_device_maskreturns no mask when torch sees one card.Tests
New
studio/backend/tests/test_sd_cpp_upsampler_placement.py:[0, 1], card 1 and card 0) and for a parent mask (3,5, physical 5 is ordinal 1), and None for an id outside the maskCUDA_VISIBLE_DEVICES=3,5and two torch cards, the llama-server child env becomesCUDA_VISIBLE_DEVICES=5On main 4 of the 6 cases fail (
assert None == 1, and{} == {'CUDA_VISIBLE_DEVICES': '5'}for the mask). With this change all 6 pass, and the existingtest_flux3_prompt_upsampler.py,test_diffusion_segment.py,test_gpu_arbiter.pyandtest_swap_kv_resume.pypass unchanged.Not covered
--offload-to-cpu, automatic multi-GPU) still launches the sidecar unpinned on a multi-GPU host, as before.