Repository navigation
Conversation
…M load limit The native GLM-5.3-Flash engine refuses checkpoints heavier than 70% of RAM with no way to raise it, where the Python engine honours TENSORFOLD_MEMORY_LIMIT_GB. A new --load-limit-gib serve flag (and the TENSORFOLD_LOAD_LIMIT_GB env fallback, now in the env table) sets the load limit in GiB in its place, clamped to physical RAM; the refusal message names the knob. fit() and cacheBudget() follow the same limit, so stream admission and the prompt-cache budget stay consistent with what loaded.
e24a46a to
8f571f6
Compare
|
Thank you, @heitke, and sorry for the wait while we decided the 70% question. The answer is yes, by explicit request only, with the risk in the message. Main already has |
|
Thank you, @heitke, and sorry for the wait while we decided the 70% question. The answer is yes, on explicit request only, with the risk in the message. Main already had Your design came with it: the limit is resolved once per load and read by the load check, stream admission and the cache budget, a value that doesn't parse is refused instead of ignored, and an unknown RAM size refuses every load. Past 70% the limit is capped at the GPU's recommended working set rather than at RAM, and the server logs the risk at startup. The commit has you as co-author, and the release notes thank you. I'm closing this in favour of 601417f. Thank you for the tests and the receipt. |
|
Thanks for adding the feature and sorry for the duplicate, PR! I'll try to check better in the future to see if others are working on the same thing. Odd that you were getting panics at a fairly low usage level. It seems like down the road there is probably a better way to have the system set an intelligent memory cap without a overly cautious hard-coded limit and without the user having to "guess" with a variable. Either way, this unblocks a lot of things for the 256gb machines, so thanks again for the fix! |
What this changes
The native GLM-5.3-Flash Metal engine refuses checkpoints heavier than 70% of RAM — a hardcoded gate with no way to raise it, unlike the Python 0.6.x engine's
TENSORFOLD_MEMORY_LIMIT_GB. This adds the same escape hatch in the native engine's own idiom:--load-limit-gib GIB— a serve flag that sets the memory admission budget in place of 70% of RAM. It requires a finite, strictly positive GiB value below 2³⁴; zero is refused (nothing would load), as are negative, NaN and out-of-range values. A value past physical RAM is clamped to it.TENSORFOLD_LOAD_LIMIT_GB— the environment-variable fallback, honoured when the flag is absent and listed in theenvtable (capabilities --jsonreports it). An absent or empty variable is unset; a set one is always read, and an invalid one is a configuration error even when a valid flag override would win.The limit is resolved once per engine load and kept on the engine (
limit_bytes): the same value gates weight loading, stream admission (fit) and the prompt-cache budget (cacheBudget). No later calculation re-reads the environment, so a higher variable can never supersede a lower explicit cap after load.The refusal message names the knob:
Scope. The knob applies to the GLM-5.3-Flash Metal engine's admission budget only. An explicit
--load-limit-gibon any othermodel_typeis refused with a message saying so; the variable is read only by the GLM Metal loader, so other engines ignore it (their own memory settings — CUDA'sTENSORFOLD_CUDA_MEMORY_LIMIT_GB/TENSORFOLD_MEMORY_RESERVE_GIB, Flash Next's--prompt-cache-gibpolicy — are unchanged).About safety. Raising the budget does not make the load safe; it trades the headroom macOS and other processes would have for model room, and the load remains subject to actual memory pressure — the same trade
TENSORFOLD_MEMORY_LIMIT_GBoffers on the Python side. Clamping to physical RAM only bounds the budget by what exists; it does not guarantee the load fits comfortably. GiB inputs are converted to bytes (2³⁰ per GiB); log output reports GB (10⁹), as the existing lines do.Receipt
mainatf8fe17d(1.0.2) + this branch; Zig0.17.0(the version pinned in.zig-version).model_type glm5_next), 45 of 45 layers + the MTP layer, 180.58 GB in buffers.python3 tools/zig/lean_check.py: 783 files, 511 problems against the target branch's 782 files, 517 — zero added problems; six inherited findings fixed as a side effect of edits (per-file diff againstmainshows no file newly carrying findings).zig fmt --checkon every touched file: clean.zig build test: 162/163 host tests pass, 1 skipped, the single failure beingfamilies.nemotron.kernels.test.the prebuilt metallib carries every packed kernel function, which reproduces on unmodifiedmainon this machine (it validates the real Metal library; this machine lacks full Xcode, and the Zig compiler otherwise type-checks the whole graph — a full-Xcode build compiles that library for real).zig build test-native: success (includes the newload_limit.zigtests, 9 cases: default across RAM sizes, integer/fractional conversion, flag-over-env precedence, lower-cap authority, clamping, zero/negative/NaN/inf refusal for both settings, empty-vs-set variable, unknown-RAM refusal, exact-fit boundary).zig build test-cli: success (includes the--load-limit-gibparser tests: accepted values, null default, zero/negative/oversized/malformed refusals).zig build nativebuildszig-out/native/bin/tensorfold-native; the server-side serve parser tests run insidezig build test(thecli.zigtest binary under theteststep), not only the checkpoint CLI target.TENSORFOLD_LOAD_LIMIT_GB=235loaded and served;--load-limit-gib 235loaded and served —info: GLM-5.3-Flash loaded in 76.4 s (180.6 GB of weights), context 131072 tokens, 1 streams, thenserving glm-5.3-flash at http://127.0.0.1:8421/v1; a chat completion round-tripped against the running server. Prompt-cache behaviour is identical between the two settings because both resolve to the same retainedlimit_bytesfeedingcacheBudget(). Automatic parallelism admitted what fit under the retained budget; an explicit--parallelabove it is refused byfit()as before.zig build test-golden— the frozen-corpus step requires the real Metal toolchain (full Xcode) to produce the kernels the goldens drive; the host portion of the corpus work that does not need the GPU ran insidezig build test. Exactness receipts (tools/bench_concurrent.py --alone --serial,token_shaagainst"draft": false) were not taken on this branch because the shim-built binary's Metal kernels are placeholders; these contracts are untouched by the change (the limit gates loading, not arithmetic), and the maintainer's release gate runs them on a full toolchain.main.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Untouched by this change: the limit gates loading, not arithmetic.)load_limit.zigtests exercise pure resolution helpers — no GPU, no model — and the refusal paths they cover were the pre-fix behaviour: an invalid value silently fell back to the default, andfit()/cacheBudget()re-read the environment instead of the resolved limit.)