Repository navigation
fix(mlxrunner): report a malformed cache limit, and pin the C call it makes - #188
Merged
Merged
Conversation
… makes Two gaps from a review of this PR. A malformed OLLAMA_MLX_CACHE_LIMIT was discarded in total silence. parseCacheLimit folds unset, unparseable and out-of-range into one `false`, and configureCacheLimit returned on all three -- so a hand-typed "8GiB" was indistinguishable from not setting it at all. That is precisely the defect the override work exists to remove: budgetWithOverride's own comment records that a sweep over 24/48/82 GiB produced three identical runs "because nothing in the output revealed that the request had been discarded", and this file's parseCacheLimit comment records being burned again by the same shape when cap-0 reported the DEFAULT's footprint. The zero case was fixed; the silence that made it hard to see was not. The sibling knob already warns, so the two also disagreed within one file. Exposure is higher here than for OLLAMA_MLX_MEMORY_LIMIT, which the parent machine-writes as a raw byte count. This one is hand-typed by an operator following a comment that tells them to set it, and nothing there says the value is decimal bytes -- so "8GiB" is the plausible thing to type and it parses as nothing. Unset stays silent; only malformed warns, and the warning names both the variable and the value that was read. SetCacheLimit had no test at all. mlx_set_cache_limit and mlx_set_memory_limit have identical Go-side signatures, so swapping one for the other compiles and keeps every existing test green while converting a cache bound into a cap on total allocation -- exactly the confusion memory.go's doc comment is written to defend against, and undefendable by review alone. A round-trip cannot catch it (both return the previous value); cross-checking that the MEMORY limit is untouched can, so that is what the test asserts. Verified by mutation: restoring the silent-discard fails TestMalformedCacheLimitIsReported, and deleting the negative guard fails TestSetCacheLimitRejectsNegative. Honest limitation: the cross-check test needs a real MLX library and SKIPS without one, so it does not catch the swapped-C-call mutation in CI -- only on a machine with MLX. The malformed-value and negative-guard tests return before any C call and run everywhere. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two gaps from the review of the cache-limit work, which landed on
mainas #185. Both are live there now:configureCacheLimitstill returns silently on a bad value, andmemory_test.gohas zero references toSetCacheLimit.Originally pushed to #181's branch — that PR turns out to be orphaned (its base
fix/mlx-memory-limit-overridablewas deleted when #180 merged, and its content shipped via #185 instead), so this re-targetsmainwhere the code actually lives.A malformed
OLLAMA_MLX_CACHE_LIMITwas discarded in total silenceparseCacheLimitfolds unset, unparseable and out-of-range into onefalse, andconfigureCacheLimitreturned on all three — so a hand-typed8GiBwas indistinguishable from not setting the variable at all.That is precisely the defect this feature family exists to remove.
budgetWithOverride's own comment records that a sweep over 24/48/82 GiB produced three identical runs "because nothing in the output revealed that the request had been discarded", andparseCacheLimit's comment records being burned again by the same shape when cap-0 reported the default's footprint under the cap-0 label. The zero case was fixed; the silence that made it hard to see was not. The sibling knobconfigureMemoryLimitalready warns, so the two disagreed within one file.Exposure is higher here than for
OLLAMA_MLX_MEMORY_LIMIT, which the parent machine-writes as a raw byte count. This one is hand-typed by an operator following a comment that tells them to set it, and nothing there says the value is decimal bytes — so8GiBis the plausible thing to type, and it parses as nothing.Unset stays silent. Only malformed warns, naming both the variable and the value that was read.
SetCacheLimithad no test at allmlx_set_cache_limitandmlx_set_memory_limithave identical Go-side signatures, so swapping one for the other compiles and keeps every existing test green — while converting a cache bound into a cap on total allocation. That is exactly the confusionmemory.go's doc comment is written to defend against, and it is undefendable by review alone.A round-trip on
SetCacheLimitcannot catch it: both C calls return the previous value and round-trip identically. Cross-checking that the MEMORY limit is untouched can, so that is what the test asserts.Verified by mutation
TestMalformedCacheLimitIsReportedfailslimit < 0guardTestSetCacheLimitRejectsNegativefailsHonest limitation
TestSetCacheLimitLeavesTheMemoryLimitAloneneeds a real MLX library and skips without one, so it does not catch the swapped-C-call mutation in CI — only on a machine with MLX. The malformed-value and negative-guard tests return before any C call and run everywhere, including CI.🤖 Generated with Claude Code