|
6 | 6 | import copy |
7 | 7 | from typing import Any, Dict, List |
8 | 8 |
|
9 | | -# Param entry: key, label, type ("int"|"float"|"bool"|"string"), default, min, max (optional), description (optional) |
| 9 | +# Param entry: key, label, type ("int"|"float"|"bool"|"string"), default, min, max (optional), description (optional), options (optional) |
| 10 | +# options: list of {"value": ..., "label": "..."} for select/dropdown; when present, frontend renders a select instead of text/number input |
10 | 11 | ParamDef = Dict[str, Any] |
11 | 12 |
|
12 | 13 | # Basic params shown by default (most common for chat/embedding) |
|
15 | 16 | {"key": "model_alias", "label": "Model alias", "type": "string", "default": "", "description": "Expose this model under a custom runtime ID instead of the default Hugging Face-derived name"}, |
16 | 17 | {"key": "ctx_size", "label": "Context size", "type": "int", "default": 2048, "min": 512, "max": 1_000_000, "description": "Maximum context length in tokens"}, |
17 | 18 | {"key": "n_gpu_layers", "label": "GPU layers", "type": "int", "default": -1, "min": -1, "max": 1000, "description": "Number of layers to offload to GPU (-1 = all)"}, |
| 19 | + {"key": "tensor_split", "label": "Tensor split", "type": "string", "default": "", "description": "Comma-separated GPU allocation (e.g. 40,30,30)"}, |
| 20 | + {"key": "main_gpu", "label": "Main GPU", "type": "int", "default": 0, "min": 0, "description": "Index of the main GPU"}, |
18 | 21 | {"key": "batch_size", "label": "Batch size", "type": "int", "default": 512, "min": 1, "max": 2048, "description": "Batch size for prompt processing"}, |
19 | 22 | {"key": "threads", "label": "Threads", "type": "int", "default": 4, "min": 1, "max": 64, "description": "Number of threads"}, |
20 | 23 | {"key": "embedding", "label": "Embedding mode", "type": "bool", "default": False, "description": "Enable embedding-only mode"}, |
21 | 24 | ] |
22 | 25 |
|
23 | 26 | # Advanced params (shown in expandable "Advanced" section) |
24 | 27 | LLAMA_CPP_ADVANCED: List[ParamDef] = [ |
25 | | - {"key": "n_predict", "label": "Max tokens to predict", "type": "int", "default": -1, "min": -1, "max": 100_000}, |
26 | | - {"key": "ubatch_size", "label": "Ubatch size", "type": "int", "default": 512, "min": 1, "max": 2048}, |
27 | | - {"key": "temp", "label": "Temperature", "type": "float", "default": 0.8, "min": 0, "max": 2}, |
28 | | - {"key": "top_k", "label": "Top K", "type": "int", "default": 40, "min": 0, "max": 1000}, |
29 | | - {"key": "top_p", "label": "Top P", "type": "float", "default": 0.9, "min": 0, "max": 1}, |
30 | | - {"key": "min_p", "label": "Min P", "type": "float", "default": 0.0, "min": 0, "max": 1}, |
31 | | - {"key": "typical_p", "label": "Typical P", "type": "float", "default": 1.0, "min": 0, "max": 1}, |
32 | | - {"key": "repeat_penalty", "label": "Repeat penalty", "type": "float", "default": 1.1, "min": 1, "max": 2}, |
33 | | - {"key": "presence_penalty", "label": "Presence penalty", "type": "float", "default": 0, "min": -2, "max": 2}, |
34 | | - {"key": "frequency_penalty", "label": "Frequency penalty", "type": "float", "default": 0, "min": -2, "max": 2}, |
35 | | - {"key": "seed", "label": "Seed", "type": "int", "default": -1, "min": -1, "max": 2**31 - 1}, |
36 | | - {"key": "threads_batch", "label": "Threads (batch)", "type": "int", "default": -1, "min": -1, "max": 64}, |
37 | | - {"key": "parallel", "label": "Parallel", "type": "int", "default": 1, "min": 1, "max": 64}, |
38 | | - {"key": "rope_freq_base", "label": "RoPE freq base", "type": "float", "default": 0, "min": 0}, |
39 | | - {"key": "rope_freq_scale", "label": "RoPE freq scale", "type": "float", "default": 0, "min": 0}, |
40 | | - {"key": "flash_attn", "label": "Flash attention", "type": "bool", "default": False}, |
41 | | - {"key": "yarn_ext_factor", "label": "YaRN ext factor", "type": "float", "default": -1, "min": -1}, |
42 | | - {"key": "yarn_attn_factor", "label": "YaRN attn factor", "type": "float", "default": 1, "min": 0}, |
43 | | - {"key": "no_mmap", "label": "No mmap", "type": "bool", "default": False}, |
44 | | - {"key": "mlock", "label": "MLock", "type": "bool", "default": False}, |
45 | | - {"key": "low_vram", "label": "Low VRAM", "type": "bool", "default": False}, |
46 | | - {"key": "logits_all", "label": "Logits all", "type": "bool", "default": False}, |
47 | | - {"key": "cont_batching", "label": "Continuous batching", "type": "bool", "default": True}, |
48 | | - {"key": "no_kv_offload", "label": "No KV offload", "type": "bool", "default": False}, |
49 | | - {"key": "tensor_split", "label": "Tensor split", "type": "string", "default": ""}, |
50 | | - {"key": "main_gpu", "label": "Main GPU", "type": "int", "default": 0, "min": 0}, |
51 | | - {"key": "split_mode", "label": "Split mode", "type": "string", "default": ""}, |
52 | | - {"key": "cache_type_k", "label": "Cache type K", "type": "string", "default": ""}, |
53 | | - {"key": "cache_type_v", "label": "Cache type V", "type": "string", "default": ""}, |
54 | | - {"key": "grammar", "label": "Grammar", "type": "string", "default": ""}, |
55 | | - {"key": "json_schema", "label": "JSON schema", "type": "string", "default": ""}, |
56 | | - {"key": "cpu_moe", "label": "CPU MoE", "type": "bool", "default": False}, |
57 | | - {"key": "n_cpu_moe", "label": "N CPU MoE", "type": "int", "default": 0, "min": 0}, |
58 | | - {"key": "override_tensor", "label": "Override tensor", "type": "string", "default": ""}, |
59 | | - {"key": "rope_scaling", "label": "RoPE scaling", "type": "string", "default": ""}, |
60 | | - {"key": "mirostat", "label": "Mirostat", "type": "int", "default": 0, "min": 0, "max": 2}, |
61 | | - {"key": "mirostat_tau", "label": "Mirostat tau", "type": "float", "default": 5.0, "min": 0}, |
62 | | - {"key": "mirostat_eta", "label": "Mirostat eta", "type": "float", "default": 0.1, "min": 0}, |
| 28 | + {"key": "n_predict", "label": "Max tokens to predict", "type": "int", "default": -1, "min": -1, "max": 100_000, "description": "Maximum tokens to generate (-1 = no limit)"}, |
| 29 | + {"key": "ubatch_size", "label": "Ubatch size", "type": "int", "default": 512, "min": 1, "max": 2048, "description": "Micro-batch size for prompt processing"}, |
| 30 | + {"key": "temp", "label": "Temperature", "type": "float", "default": 0.8, "min": 0, "max": 2, "description": "Sampling temperature (higher = more random)"}, |
| 31 | + {"key": "top_k", "label": "Top K", "type": "int", "default": 40, "min": 0, "max": 1000, "description": "Limit sampling to top K tokens (0 = disabled)"}, |
| 32 | + {"key": "top_p", "label": "Top P", "type": "float", "default": 0.9, "min": 0, "max": 1, "description": "Nucleus sampling: keep smallest set with cumulative probability"}, |
| 33 | + {"key": "min_p", "label": "Min P", "type": "float", "default": 0.0, "min": 0, "max": 1, "description": "Minimum token probability for sampling"}, |
| 34 | + {"key": "typical_p", "label": "Typical P", "type": "float", "default": 1.0, "min": 0, "max": 1, "description": "Typical sampling (1 = disabled)"}, |
| 35 | + {"key": "repeat_penalty", "label": "Repeat penalty", "type": "float", "default": 1.1, "min": 1, "max": 2, "description": "Penalize repeated tokens"}, |
| 36 | + {"key": "presence_penalty", "label": "Presence penalty", "type": "float", "default": 0, "min": -2, "max": 2, "description": "Penalize tokens that have appeared"}, |
| 37 | + {"key": "frequency_penalty", "label": "Frequency penalty", "type": "float", "default": 0, "min": -2, "max": 2, "description": "Penalize by token frequency"}, |
| 38 | + {"key": "seed", "label": "Seed", "type": "int", "default": -1, "min": -1, "max": 2**31 - 1, "description": "Random seed for reproducibility (-1 = random)"}, |
| 39 | + {"key": "threads_batch", "label": "Threads (batch)", "type": "int", "default": -1, "min": -1, "max": 64, "description": "Threads for batch inference (-1 = use threads)"}, |
| 40 | + {"key": "parallel", "label": "Parallel", "type": "int", "default": 1, "min": 1, "max": 64, "description": "Number of parallel sequences"}, |
| 41 | + {"key": "rope_freq_base", "label": "RoPE freq base", "type": "float", "default": 0, "min": 0, "description": "RoPE base frequency (0 = from model)"}, |
| 42 | + {"key": "rope_freq_scale", "label": "RoPE freq scale", "type": "float", "default": 0, "min": 0, "description": "RoPE frequency scaling (0 = from model)"}, |
| 43 | + {"key": "flash_attn", "label": "Flash attention", "type": "bool", "default": False, "description": "Use Flash Attention when available"}, |
| 44 | + {"key": "yarn_ext_factor", "label": "YaRN ext factor", "type": "float", "default": -1, "min": -1, "description": "YaRN extension factor (-1 = disabled)"}, |
| 45 | + {"key": "yarn_attn_factor", "label": "YaRN attn factor", "type": "float", "default": 1, "min": 0, "description": "YaRN attention factor"}, |
| 46 | + {"key": "no_mmap", "label": "No mmap", "type": "bool", "default": False, "description": "Disable memory-mapped model loading"}, |
| 47 | + {"key": "mlock", "label": "MLock", "type": "bool", "default": False, "description": "Lock model in RAM to prevent swapping"}, |
| 48 | + {"key": "low_vram", "label": "Low VRAM", "type": "bool", "default": False, "description": "Reduce VRAM use (slower inference)"}, |
| 49 | + {"key": "logits_all", "label": "Logits all", "type": "bool", "default": False, "description": "Return logits for all tokens (embedding mode)"}, |
| 50 | + {"key": "cont_batching", "label": "Continuous batching", "type": "bool", "default": True, "description": "Use continuous batching for higher throughput"}, |
| 51 | + {"key": "no_kv_offload", "label": "No KV offload", "type": "bool", "default": False, "description": "Disable KV cache offload to CPU"}, |
| 52 | + {"key": "split_mode", "label": "Split mode", "type": "string", "default": "", "description": "Tensor split mode (e.g. layer, row)", "options": [{"value": "", "label": "Default"}, {"value": "layer", "label": "Layer"}, {"value": "row", "label": "Row"}]}, |
| 53 | + {"key": "cache_type_k", "label": "Cache type K", "type": "string", "default": "", "description": "K cache backend (e.g. f16, q8_0)", "options": [{"value": "", "label": "Default"}, {"value": "f16", "label": "f16"}, {"value": "q8_0", "label": "q8_0"}, {"value": "q4_0", "label": "q4_0"}, {"value": "q4_1", "label": "q4_1"}]}, |
| 54 | + {"key": "cache_type_v", "label": "Cache type V", "type": "string", "default": "", "description": "V cache backend (e.g. f16, q8_0)", "options": [{"value": "", "label": "Default"}, {"value": "f16", "label": "f16"}, {"value": "q8_0", "label": "q8_0"}, {"value": "q4_0", "label": "q4_0"}, {"value": "q4_1", "label": "q4_1"}]}, |
| 55 | + {"key": "grammar", "label": "Grammar", "type": "string", "default": "", "description": "BNF grammar for constrained output"}, |
| 56 | + {"key": "json_schema", "label": "JSON schema", "type": "string", "default": "", "description": "JSON schema for structured output"}, |
| 57 | + {"key": "cpu_moe", "label": "CPU MoE", "type": "bool", "default": False, "description": "Run MoE experts on CPU"}, |
| 58 | + {"key": "n_cpu_moe", "label": "N CPU MoE", "type": "int", "default": 0, "min": 0, "description": "Number of MoE experts to run on CPU"}, |
| 59 | + {"key": "override_tensor", "label": "Override tensor", "type": "string", "default": "", "description": "Override tensor layout (e.g. for debugging)"}, |
| 60 | + {"key": "rope_scaling", "label": "RoPE scaling", "type": "string", "default": "", "description": "RoPE scaling type (e.g. yarn, linear)", "options": [{"value": "", "label": "Default"}, {"value": "yarn", "label": "YaRN"}, {"value": "linear", "label": "Linear"}, {"value": "none", "label": "None"}]}, |
| 61 | + {"key": "mirostat", "label": "Mirostat", "type": "int", "default": 0, "min": 0, "max": 2, "description": "Mirostat mode (0=off, 1=mirostat, 2=mirostat 2.0)", "options": [{"value": 0, "label": "Off"}, {"value": 1, "label": "Mirostat 1"}, {"value": 2, "label": "Mirostat 2.0"}]}, |
| 62 | + {"key": "mirostat_tau", "label": "Mirostat tau", "type": "float", "default": 5.0, "min": 0, "description": "Mirostat target perplexity"}, |
| 63 | + {"key": "mirostat_eta", "label": "Mirostat eta", "type": "float", "default": 0.1, "min": 0, "description": "Mirostat learning rate"}, |
63 | 64 | ] |
64 | 65 |
|
65 | 66 | # ik_llama.cpp: same as llama_cpp plus these extras (and different mirostat flag names) |
|
78 | 79 | {"key": "tensor_parallel", "label": "Tensor parallel", "type": "int", "default": 1, "min": 1, "max": 8, "description": "Tensor parallelism degree"}, |
79 | 80 | ] |
80 | 81 | LMDEPLOY_ADVANCED: List[ParamDef] = [ |
81 | | - {"key": "dtype", "label": "Dtype", "type": "string", "default": "auto", "description": "Model dtype (auto, float16, bfloat16)"}, |
82 | | - {"key": "quant_policy", "label": "Quantization policy", "type": "int", "default": 0, "min": 0, "max": 8, "description": "KV cache quantization (0=off, 4=4bit, 8=8bit)"}, |
| 82 | + {"key": "dtype", "label": "Dtype", "type": "string", "default": "auto", "description": "Model dtype (auto, float16, bfloat16)", "options": [{"value": "auto", "label": "Auto"}, {"value": "float16", "label": "float16"}, {"value": "bfloat16", "label": "bfloat16"}]}, |
| 83 | + {"key": "quant_policy", "label": "Quantization policy", "type": "int", "default": 0, "min": 0, "max": 8, "description": "KV cache quantization (0=off, 4=4bit, 8=8bit)", "options": [{"value": 0, "label": "Off"}, {"value": 4, "label": "4-bit"}, {"value": 8, "label": "8-bit"}]}, |
83 | 84 | {"key": "enable_prefix_caching", "label": "Prefix caching", "type": "bool", "default": False, "description": "Enable prefix caching"}, |
84 | 85 | {"key": "chat_template", "label": "Chat template", "type": "string", "default": "", "description": "Override chat template"}, |
85 | 86 | ] |
|
0 commit comments