Update GPU performance tuning and documentation for context length
- Enhanced the `OllamaTune` class to include a new `context_length` attribute, improving the configuration for different GPU tiers. - Updated performance tuning logic to set appropriate context lengths for low, mid, high, and ultra tiers, ensuring optimal resource allocation. - Modified installation scripts to reflect the new context length settings, enhancing the installation process for Ollama. - Revised documentation to include context length details in the GPU performance table, providing clearer guidance for users. - Added tests to validate the correct context length settings in various scenarios, ensuring robustness in performance tuning.
This commit is contained in:
@@ -30,6 +30,7 @@ class OllamaTune:
|
||||
max_loaded_models: int
|
||||
kv_cache_type: str | None
|
||||
gpu_overhead_bytes: int
|
||||
context_length: int
|
||||
notes: str
|
||||
|
||||
|
||||
@@ -72,23 +73,27 @@ def ollama_tune_for(info: GpuInfo) -> OllamaTune:
|
||||
overhead = 20 * 1024**3
|
||||
keep = "30m"
|
||||
kv = "q8_0"
|
||||
note = "ultra: flash+q8 KV, 20GiB reserved for Swarm, keep 30m"
|
||||
ctx = 32768
|
||||
note = "ultra: flash+q8 KV, 20GiB reserved for Swarm, ctx 32k, keep 30m"
|
||||
elif info.tier == TIER_HIGH:
|
||||
overhead = 14 * 1024**3
|
||||
keep = "15m"
|
||||
kv = "q8_0"
|
||||
note = "high: flash+q8 KV, 14GiB reserved for Swarm, keep 15m"
|
||||
ctx = 16384
|
||||
note = "high: flash+q8 KV, 14GiB reserved for Swarm, ctx 16k, keep 15m"
|
||||
elif info.tier == TIER_MID:
|
||||
overhead = 10 * 1024**3
|
||||
keep = "5m"
|
||||
kv = "q8_0"
|
||||
note = "mid: flash+q8 KV, 10GiB reserved for Swarm, keep 5m"
|
||||
ctx = 16384
|
||||
note = "mid: flash+q8 KV, 10GiB reserved for Swarm, ctx 16k, keep 5m"
|
||||
else:
|
||||
overhead = 6 * 1024**3
|
||||
keep = "2m"
|
||||
kv = "q4_0"
|
||||
ctx = 8192
|
||||
flash = False # prefer stability on tiny cards
|
||||
note = "low: conservative, 6GiB reserved, short keep-alive"
|
||||
note = "low: conservative, 6GiB reserved, ctx 8k, short keep-alive"
|
||||
|
||||
return OllamaTune(
|
||||
flash_attention=flash,
|
||||
@@ -97,6 +102,7 @@ def ollama_tune_for(info: GpuInfo) -> OllamaTune:
|
||||
max_loaded_models=1,
|
||||
kv_cache_type=kv,
|
||||
gpu_overhead_bytes=overhead,
|
||||
context_length=ctx,
|
||||
notes=note,
|
||||
)
|
||||
|
||||
@@ -139,6 +145,7 @@ def ollama_env_lines(tune: OllamaTune) -> list[str]:
|
||||
f"Environment=OLLAMA_MAX_LOADED_MODELS={tune.max_loaded_models}",
|
||||
f"Environment=OLLAMA_KEEP_ALIVE={tune.keep_alive}",
|
||||
f"Environment=OLLAMA_GPU_OVERHEAD={tune.gpu_overhead_bytes}",
|
||||
f"Environment=OLLAMA_CONTEXT_LENGTH={tune.context_length}",
|
||||
]
|
||||
if tune.flash_attention:
|
||||
lines.append("Environment=OLLAMA_FLASH_ATTENTION=1")
|
||||
|
||||
Reference in New Issue
Block a user