Files
homelab/ansible/roles/llm-inference-multimodel/templates/llama-swap-config.yaml.j2

60 lines
2.6 KiB
Django/Jinja

{#
FILE: roles/llm-inference-multimodel/templates/llama-swap-config.yaml.j2
DESCRIPTION: llama-swap v250 configuration template.
Generates /etc/llama-swap/config.yaml with all models, routing matrix,
and per-model settings (ctx_size, n_gpu_layers, cmd args).
v250 SYNTAX NOTES:
- Uses routing.router DSL with expression-based matrix (not old list-of-arrays)
- Each model has its own cmd field with full per-model args
- Matrix rows use "model1 & model2" syntax for co-resident sets
- sleep_idle_seconds: -1 = never idle; 0+ = idle after N seconds
- load_on_startup: true = start this model on service startup
Reference: /etc/llama-swap/config.yaml on astro-orbiter (Phase 1 artifact)
#}
# llama-swap configuration for astro-orbiter
# Generated by Ansible roles/llm-inference-multimodel on {{ ansible_date_time.iso8601 }}
# See: https://github.com/mostlygeek/llama-swap (v250 release notes for syntax)
# ============================================================================
# LISTEN — Address and port for the llama-swap proxy
# ============================================================================
listen: "{{ llm_swapmode_bind_address }}:{{ llm_swapmode_port }}"
# ============================================================================
# MODELS — All model definitions (cmd, port, ctx_size, etc.)
# ============================================================================
models:
{% for model in llm_swapmode_models %}
{{ model.id }}:
cmd: >
llama-server
--port ${PORT}
--model {{ model.gguf_path }}
--n-gpu-layers {{ model.n_gpu_layers }}
--ctx-size {{ model.ctx_size }}
--batch-size {{ model.batch_size }}
--ubatch-size {{ model.ubatch_size }}
--parallel {{ model.parallel }}
{% if model.cache_type is defined %}--cache-type-k {{ model.cache_type }} --cache-type-v {{ model.cache_type }}{% endif %}
{% if model.flash_attn is defined %}--flash-attn {{ model.flash_attn }}{% endif %}
{% if model.sleep_idle_seconds is defined %}--sleep-idle-seconds {{ model.sleep_idle_seconds }}{% endif %}
{% if model.load_on_startup is defined and model.load_on_startup %}--load-on-startup{% endif %}
--host 127.0.0.1
port: {{ model.port }}
{% endfor %}
# ============================================================================
# ROUTING — Matrix-based hot-swap policy (v250 expression DSL)
# ============================================================================
routing:
router:
use: matrix
settings:
matrix:
sets:
{% for row in llm_swapmode_matrix_rows %}
{{ row.row }}: "{{ row.expr }}"
{% endfor %}