Repository navigation
Closed
Labels
area:cliCommand-line interface / CLI flagsarea:coremlxcel-core: MLX FFI, primitives, KV cache, layerspriority:mediumMedium prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions
Milestone
Description
Part of #52
Goal
Combine weights (sub-issue A) + KV cache (sub-issue B) + runtime headroom (calibrated via sub-issue C) into one estimator, surface it through a dedicated mlxcel inspect subcommand and an --estimate-memory preflight on generate/serve, and abort (with override) when a model won't fit.
Depends on
#53 (weights), #54 (KV cache), #55 (MLX FFI). This is the integration capstone for the epic.
Scope / implementation
estimate_total_memory(model_dir, ctx_len, batch, quant, kv_dtype) -> MemoryEstimate { weights, kv_cache, runtime_headroom, total, available, fits }in a shared module (e.g.src/execution/memory_estimate.rs), reachable from the single-device load path (not only distributed).- Runtime/activation headroom: derive an empirical factor calibrated from
get_peak_memory()(sub-issue C) across a couple of real loads instead of a guess; document the assumption. mlxcel inspect <model>subcommand (new variant inenum Commands,src/main.rs): read-only — prints the full breakdown vs available unified memory and fits/doesn't-fit. No generation.--estimate-memoryflag ongenerate/serve(next to--recommend-quant): runs the same estimate as a preflight; aborts with a clear, actionable error when total > available;--force/--no-memory-checkoverrides.- After a successful load, compare the estimate against
get_active_memory()and log the delta (feeds future calibration).
Integration (required for completion — epic capstone)
mlxcel inspect, the--estimate-memorypreflight, and--recommend-quantall consume the one estimator (no duplicate logic).- Preflight abort + override verified on a real over-capacity scenario (e.g. an artificially low limit via sub-issue C's
set_memory_limit, or a model larger than that limit). - Docs:
inspect/--estimate-memory/ override flags documented (CLI help + README/docs).
Acceptance criteria
mlxcel inspect <model> --max-tokens Nprints weights / KV / headroom / total / available / fits without running generation; numbers match sub-issues A and B.mlxcel generate --estimate-memoryaborts an over-capacity case with a clear error and respects--force.- Post-load estimate-vs-
active_memory()delta is logged and within a documented tolerance for a tested model.
Metadata
Metadata
Assignees
Labels
area:cliCommand-line interface / CLI flagsarea:coremlxcel-core: MLX FFI, primitives, KV cache, layerspriority:mediumMedium prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions
Activity
feat(ffi): wrap MLX runtime memory APIs (active/peak/limit) (#66)
feat(ffi): wrap MLX runtime memory APIs (active/peak/limit) (lablup#66)
feat: unified memory estimator with `mlxcel inspect` and preflight (l…