[Feature]: Add percentage-based VRAM and RAM override flags
I'm a lazy person, and math is annoying. To not do math, having a flag that could cleanly calculate the percentage of my detected VRAM and memory I am willing to allocate to llmfit would be amazing. Thank you! (Will mainly be used to create a DIY profile of preferred settings between different machines dynamically)
Problem or motivation
llmfit currently supports absolute hardware-capacity overrides:
llmfit --memory=10.8GiB
llmfit --ram=48GiBThis works when the desired budget is known in advance, but it is awkward for applications that want to reserve a percentage of the detected hardware rather than hardcode a capacity.
For example, an application may want to allow LLM inference to use at most 90% of detected VRAM so some capacity remains available for the OS, display, desktop applications, CUDA overhead, or other workloads.
On a 12 GiB GPU this currently requires the caller to:
- Detect the GPU's total VRAM separately.
- Calculate
12 × 0.90 = 10.8 GiB. - Pass
--memory=10.8GiB.
The same application then has to repeat this hardware-detection/calculation logic for every GPU configuration.
Since llmfit already detects VRAM and system RAM, it would be useful for the CLI to support percentage-based capacity overrides directly.
Proposed solution
Add percentage equivalents of the existing memory override flags:
--memory-percent <PERCENT>
--ram-percent <PERCENT>Examples:
# Use at most 90% of detected GPU VRAM
llmfit --memory-percent=90 fit
# Use at most 80% of detected system RAM
llmfit --ram-percent=80 recommend
# Apply both limits
llmfit --memory-percent=90 --ram-percent=80 recommend --json
# Other commands should inherit the same effective capacities
llmfit --memory-percent=90 system --json
llmfit --memory-percent=90 plan "Qwen/Qwen3-32B"For a detected 12 GiB GPU:
detected VRAM = 12 GiB
--memory-percent=90
effective VRAM = 10.8 GiBFor 64 GiB of detected system RAM:
detected RAM = 64 GiB
--ram-percent=75
effective RAM = 48 GiBWhy percentage flags belong in llmfit
The alternative is for every caller integrating llmfit to duplicate:
- GPU detection
- total-VRAM parsing
- system-RAM detection
- unit conversion
- percentage calculation
- rounding behavior
- special handling for unified-memory systems
llmfit already owns hardware detection, so it has the authoritative capacity values required to perform this calculation consistently.
This is particularly useful for applications consuming recommend --json or fit --json, where a caller may want a fixed utilization policy such as:
LLM budget = 90% of installed VRAMregardless of whether the machine has 8, 12, 16, 24, or 48 GiB of VRAM.
Suggested semantics
Accept a percentage greater than 0 and up to 100:
0 < percentage <= 100Examples:
--memory-percent=90
--memory-percent=87.5
--ram-percent=75Fractional percentages should be supported.
Internally:
effective_vram =
detected_vram × memory_percent / 100
effective_ram =
detected_ram × ram_percent / 100The resulting capacity should feed the same existing paths as the absolute --memory and --ram overrides.
Conflict behavior
Percentage and absolute forms for the same resource should conflict rather than silently override each other:
# Invalid
llmfit --memory=12G --memory-percent=90
# Invalid
llmfit --ram=64G --ram-percent=80Suggested Clap behavior:
--memory conflicts with --memory-percent
--ram conflicts with --ram-percentHardware profiles should also conflict with percentage overrides for the same reason they currently conflict with --memory, --ram, and --cpu-cores.
For example:
# Invalid
llmfit --profile nvidia-rtx-4090 --memory-percent=90unless profile-relative percentage overrides are intentionally supported separately.
Hardware detection failure
Unlike --memory, a percentage cannot create a synthetic GPU because it requires a detected baseline.
Therefore:
llmfit --memory-percent=90should return a clear error if total GPU VRAM cannot be detected.
Example:
error: --memory-percent requires detected GPU VRAM; use --memory <SIZE> when VRAM detection is unavailableLikewise, --ram-percent should fail clearly if total system RAM is unavailable.
Unified-memory systems
Unified-memory systems need explicit semantics.
The existing behavior says that --ram also updates VRAM on unified-memory systems, while --memory can override VRAM independently.
Percentage flags should mirror those semantics.
Suggested behavior:
--ram-percent=80
→ system RAM = 80% of detected unified memory
→ VRAM capacity follows the same adjusted shared pool
--memory-percent=80
→ only the accelerator/VRAM budget is limited to 80%
→ total system RAM remains unchangedThis would keep the percentage flags consistent with their existing absolute counterparts.
JSON/system output
When a percentage override is active, system --json should expose both the detected and effective values if possible.
For example:
{
"gpu_vram_gb": 10.8,
"detected_gpu_vram_gb": 12.0,
"memory_percent": 90.0
}or equivalent provenance.
This would let programmatic callers determine whether a reported capacity is physical or policy-limited.
The same applies to RAM:
{
"total_ram_gb": 51.2,
"detected_total_ram_gb": 64.0,
"ram_percent": 80.0
}If adding provenance fields is considered too broad for the first implementation, the minimum requirement is that all fit/recommend calculations consistently use the percentage-adjusted capacity.
CLI help
The global help could become:
--memory <SIZE>
Override GPU VRAM with an absolute capacity.
--memory-percent <PERCENT>
Use this percentage of detected GPU VRAM.
--ram <SIZE>
Override system RAM with an absolute capacity.
--ram-percent <PERCENT>
Use this percentage of detected system RAM.Acceptance criteria
- Add
--memory-percent <PERCENT>. - Add
--ram-percent <PERCENT>. - Support integer and fractional percentages.
- Validate
0 < percent <= 100. -
--memory-percentderives capacity from detected total VRAM. -
--ram-percentderives capacity from detected total system RAM. - The calculated capacities feed the same fit/scoring paths as existing absolute overrides.
-
--memory-percentconflicts with--memory. -
--ram-percentconflicts with--ram. - Percentage overrides conflict with
--profile, matching existing hardware-override behavior. - Give a clear error when percentage mode is requested but the required hardware capacity cannot be detected.
- Define and test behavior on unified-memory systems.
- Percentage-adjusted capacities work consistently with
fit,recommend,plan,info, TUI mode, and JSON output. - Add tests showing, for example, that 90% of 12 GiB becomes 10.8 GiB.
Example use case
A model manager wants to reserve 10% of VRAM for the desktop and runtime overhead on every machine:
llmfit --memory-percent=90 --max-context=131072 recommend --jsonThe caller no longer needs to know whether the installed GPU has 8, 12, 16, 24, or 48 GiB of VRAM. The same policy automatically scales with the detected hardware.
Source: AlexsJones/llmfit