Repository navigation
Studio: keep Inkling 2 compute regrowth free under --fit on - #18941
Conversation
llama.cpp's fitter sizes only the load-time compute reserve, but the Inkling 2 banded buffer grows past it after the first prompt. Add the estimated growth (runtime minus reserve at the launched micro-batch, from the same banded estimate) to every --fit-target margin Studio passes for an Inkling 2 --fit on launch.
…bound The growth kept free is now the runtime estimate less a lower bound of llama.cpp's load-time reserve fitted under every Inkling-2-Mini reading (ub 512-2048, 32K-1M cells, both builds), with a runtime floor where the banded estimate reads under the measured runtime past ~262K cells. The #18919 estimate itself is unchanged.
…query On a host with visible GPUs the test reached torch.cuda through the datacenter and integrated-GPU probes, and the CPU-test guard failed it at teardown. Fake the device info the same way test_auto_fit_target_trim does.
Codex Review Summary: ✅ CompletedThis 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. |
…alone Hardware detection also names the cards through torch.cuda when the test runs by itself on a host with visible GPUs, so fake that query too.
|
The If the new call is intended (the Inkling 2 regrowth re-derivation), raise the count to 14 and add it to the list in the comment above the assertion, so the guard keeps describing every re-derivation. The other reds on that run are not from this PR: the |
…r the two-card Wan decode with the VAE seam guard (main reds) (#18945) ## Summary Two checks are red on `main` and fail on every PR that runs them, for example the staging run for #18941: | Failing check | Introduced by | Which side was wrong | Fix | |---|---|---|---| | `tests/test_python39_compatibility.py::test_studio_evaluated_unions_do_not_grow` (`Core`, all three combos): "36 studio files now evaluate PEP 604 unions on the floor, against 35 recorded" | #18917 added `core/inference/diffusion_lanczos_triton.py` | Code. Its public entry point declares `crop`, `mean` and `std` as `tuple[...] \| None`, which is evaluated when the function is defined and raises `TypeError` on Python 3.9. | Those three parameters become `Optional[tuple[...]]`. No `from __future__ import annotations`: the module's Triton kernels read their `tl.constexpr` annotations, which that import would turn into strings. | | `studio/backend/tests/test_vae_tile_geometry.py::test_every_tiled_decode_patch_is_probed` (`seam-guard`): "['video_vae_multigpu'] rebind a VAE's tiled_decode but expose no install(vae) this guard applies" | #18829 added `core/inference/video_vae_multigpu.py` | Test registry. The module mirrors the stock `AutoencoderKLWan.tiled_decode` body (checked by AST fingerprint) and only shares its tiles between two cards. It keeps the stock tile grid, and `test_video_vae_multigpu.py::test_split_tiles_match_the_stock_tiled_decode_bitwise` proves it. Its `install(pipe, partner)` takes a pipeline, not a VAE, so the guard cannot apply it. | Listed in `GEOMETRY_PRESERVING` with that reason, which is the remedy the guard's message names for a module that keeps the stock tiles. | Neither fix changes behaviour. ## Testing - `tests/test_python39_compatibility.py`: fails on `main` with the message above, 8 passed with this change. - `tests/test_vae_tile_geometry.py` and `tests/test_video_vae_multigpu.py`: `test_every_tiled_decode_patch_is_probed` fails on `main`. With this change, 55 passed, 2 skipped, 2 xfailed (the recorded known seams). - `tests/test_diffusion_ref_preprocess.py` and `tests/test_diffusion_ref_preprocess_gate.py`, the suites that exercise the Lanczos module: 33 passed. - `ruff check --select F` on the Lanczos module: clean.
…growth On builds before #399, #18919's 18 B/cell load-time reserve rate is a planner bound that overtakes its 15 B/cell runtime rate at long contexts, as the measured reserve does (growth 270 -> 140 MiB from 32K to 128K). The --fit on margin read that surplus as post-prompt growth, so it rose again past ~262K cells (4332 MiB at 1M, -ub 2048) and a Manual + Auto launch with no -c kept that maximum free whatever context the fitter picked. Price only the runtime term against the reserve bound there; every measured row keeps its value.
A budget slider above the default gives a negative margin delta, which the emitter floors at 512 MiB. The regrowth was added to the raw delta, so the negative balance ate it: a 48 GB card at a 100% budget (delta -1474 MiB) kept 2239 MiB free against 2547 MiB of measured growth. Floor the delta first, for the broadcast margin and for every per-device entry, then add the growth.
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
…atch re-derivations The regrowth margin sizes its growth at the micro-batch the launched slots get, so load_model now derives it fourteen times; the guard lists the new site.
…, and read checked-in sources as UTF-8 (main reds) (#18952) ## Summary Two checks are red on `main` and fail on every PR that runs them, for example the staging run for #18941: | Failing check | Introduced by | Which side was wrong | Fix | |---|---|---|---| | `tests/studio/install/test_mlx_install.py::test_mlx_image_engine_pins_leave_the_mlx_stack_alone` (`studio-install` shard): `assert 'mflux==0.24.0'.startswith('mflux==0.22.')` | #18933 bumped mflux to 0.24.0 (0.22.0 kept for Python 3.10) | Test. The bump is intended. The test pinned a version literal of its own, so every mflux bump breaks it. | The test now checks the installer pin against the MLX engine itself: `_MLX_DIFFUSION_PINS` must be exactly `mflux==<MFLUX_VERSION>` for the running interpreter, and that version must be in `MFLUX_COMPATIBLE_VERSIONS`. Both are read from `mlx_diffusion_convert.py`'s source, since importing it needs numpy and the installer tests do not have it. The check is stricter than before: an installer pin that drifts from what the engine accepts at runtime now fails. | | `tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding` (`rest-2` shard): 3 reads with the platform default encoding | #18923 (`tests/test_adapter_unc_base_guard.py:30` and `:91`) and `tests/test_inkling2_support.py:367` | Tests. On Windows a bare `read_text()` uses the locale code page. | `encoding = "utf-8"` on those three reads. | Only tests change. ## Testing - `tests/studio/install/test_mlx_install.py`, `tests/test_source_read_encoding.py`, `tests/test_adapter_unc_base_guard.py`, `tests/test_inkling2_support.py`: 3 failed on `main`. With this change, 92 passed, 4 skipped. - Sabotage: with `_MFLUX_PIN` changed to `mflux==0.23.0`, a version the engine does not expect, the mflux test fails with `assert 'mflux==0.23.0' == 'mflux==0.24.0'`.
Summary
Follow-up to #18919. When Studio hands an Inkling 2 load to llama.cpp's fitter (
--fit on), the fitter measures only the load-time compute reserve and leaves--fit-targetfree on each device (1024 MiB by default). The Inkling 2 banded compute buffer grows past that reserve after the first prompt. At the-ub 2048raise Studio applies when MoE experts sit in RAM, the measured growth is 1.5 to 2.5 GB, more than the margin, so a session can OOM mid-prompt after a clean load.This adds the expected growth to the
--fit-targetmargin, for Inkling 2--fit onlaunches only:-ub 2048the estimate reads under the measured runtime (524K: 5572 vs 5836 MiB).-c(Manual + Auto), the fitter picks the context, so the largest growth from the--fit-ctxfloor up to the native length is used.--fit-targetstill wins.Measured growth vs emitted
Inkling-2-Mini UD-IQ1_S, CUDA,
-np 4 --kv-unified -fa on, slot 0 filled to 90% of the context. The compute buffer is read from the load log and frommemory_breakdown_printat exit. The ub 2048 rows and the 32K ub 1024 row are--fit onlaunches on the #399 build b12628; the other rows are earlier--fit offreadings. The 32K ub 1024 row reproduces the earlier--fit offreading (1080 vs 1081 MiB).All values are MiB. The emitted growth is added on top of the existing margin (1024 MiB by default), so the real headroom is larger than the pad shown.
Inkling-2-Small launch matrix
432 simulated launches (sparse real-header GGUFs, 24 / 48 / 80 / 96 / 180 GB and 2x80 GB cards, auto and fixed context, f16 and q8_0, shipped b12602 and #399 builds), #18919 head versus this branch:
--fit on. 315 now carry a larger--fit-target. The other 106 are q8_0 on the shipped build, which runs dense attention and has no banded growth.-ub 2048, f16 and q8_0: +2978 to +3250 MiB (margin 4002 to 4274 MiB), 159 launches.-ub 2048: +1964 to +2204 MiB, 78 launches.--fit-target, all 432 argv are identical.Non-Inkling models
384 launches of qwen3moe, llama, inkling, gemma3, deepseek4 and glm4moe (8 / 24 / 48 GB and mixed cards, 1 to 80 GiB weights, f16 and q8_0, GPU and Manual + Auto, 276 of them
--fit on) produce byte-identical argv on #18919 head and on this branch.Tests
studio/backend/tests/test_inkling2_fit_target_regrowth.py:--fit-targetwith the default margin, the small-card trim and the per-device list;On #18919 head, 5 of the 49 tests pass (the unchanged cases) and the rest fail. The neighbouring fit, placement, compute buffer, OOM respawn, sidecar and Inkling suites give the same results, with the same failing test IDs, as #18919 head.
Not covered
--fit onrun. The Small numbers come from the simulated matrix, with the growth calibrated on Inkling-2-Mini.-ub 2048. That affects its--fit offdecisions and is left to Studio: price Inkling 2 quantized KV by what the bundled llama.cpp runs #18919.--fit onthrough a later retry keeps the margin of its first attempt.Test fix
test_mixed_cards_keep_their_own_margins_plus_the_headroom(from #18920) reachedtorch.cudathrough the datacenter and integrated-GPU probes on a host with visible GPUs, so the CPU-test guard failed it at teardown. It now fakes the device info the waytest_auto_fit_target_trim.pydoes. On CI runners with no GPU it already passed.Review fixes
torch.cudawhen run alone.A base vs head launch matrix (516 pairs: 8 to 24 GB cards, 2 x 24 GB and 24 + 8 GB, sparse header-only GGUFs) loads on both sides, and nothing differs outside
--fit-target.