monitoring: llama-swap GPU/LLM stack (v250) — PrometheusRule, Grafana dashboard, scrape config, VRAM exporter
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
# ==============================================================================
|
||||
# FILE: roles/llm-inference-multimodel/templates/llama-swap-alerts.yml.j2
|
||||
# DESCRIPTION: PrometheusRule CustomResource for llama-swap alert rules.
|
||||
# Defines CRITICAL, WARNING, and INFO alerts per the Ciro Luciotta
|
||||
# monitoring pattern (references/monitoring-llm-homelab-ciro-luciotta-2026.md).
|
||||
#
|
||||
# Deployed by ArgoCD as a K8s resource in the monitoring namespace.
|
||||
# Prometheus loads these rules automatically on sync.
|
||||
#
|
||||
# SCOPE: Alerts fire when:
|
||||
# - VRAM exceeds physical limit (24GB) — pending OOM-kill
|
||||
# - KV-cache spills to CPU (>92% utilization) — requests may drop
|
||||
# - Throughput degrades below baseline — model may be throttled
|
||||
#
|
||||
# AUTHOR: Wong (Infrastructure Automation Specialist)
|
||||
# DATE: 2026-08-18
|
||||
# ==============================================================================
|
||||
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: llama-swap-alerts
|
||||
namespace: monitoring
|
||||
labels:
|
||||
prometheus: kube-prometheus
|
||||
spec:
|
||||
groups:
|
||||
- name: llama-swap.rules
|
||||
interval: 30s
|
||||
rules:
|
||||
|
||||
# ====================================================================
|
||||
# CRITICAL: GPU VRAM saturation (OOM risk)
|
||||
# ====================================================================
|
||||
- alert: LlamaSwapVramSaturation
|
||||
expr: llamacpp_vram_used_mib > {{ llm_swapmode_vram_max_mib | int }}
|
||||
for: 1m
|
||||
labels:
|
||||
severity: critical
|
||||
component: llm-inference
|
||||
annotations:
|
||||
summary: "GPU VRAM saturation on {{ $labels.instance }}"
|
||||
description: |
|
||||
GPU VRAM usage is {{ $value | humanize }}MiB (critical threshold: {{ llm_swapmode_vram_max_mib }}MiB).
|
||||
|
||||
The system is at risk of out-of-memory (OOM) kernel-kill events.
|
||||
Immediate action required:
|
||||
1. Check Prometheus dashboard for request queue depth and active models
|
||||
2. Identify which model(s) are consuming VRAM
|
||||
3. If queue depth is high, consider rate-limiting or routing requests
|
||||
4. If a single request caused the spike, investigate context-window size
|
||||
|
||||
Instance: {{ $labels.instance }}
|
||||
Time: {{ $value | humanizeDuration }}
|
||||
|
||||
# ====================================================================
|
||||
# WARNING: KV-cache spill risk (context cache pressure)
|
||||
# ====================================================================
|
||||
- alert: LlamaSwapKvCacheSpill
|
||||
expr: llamacpp_kv_cache_usage_ratio > 0.92
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
component: llm-inference
|
||||
annotations:
|
||||
summary: "KV-cache spill risk on model {{ $labels.model }}"
|
||||
description: |
|
||||
KV-cache utilization on {{ $labels.model }} is {{ $value | humanizePercentage }}
|
||||
(warning threshold: 92%).
|
||||
|
||||
The model's context cache is nearly full. Requests with large context windows
|
||||
may not fit and could be dropped from the queue. Consider:
|
||||
1. Reviewing incoming request context-window distribution
|
||||
2. Reducing n_ctx for non-critical models (if router mode is active)
|
||||
3. Routing long-context requests to a different model with more capacity
|
||||
4. Investigating whether concurrent requests are competing for KV space
|
||||
|
||||
Model: {{ $labels.model }}
|
||||
Instance: {{ $labels.instance }}
|
||||
|
||||
# ====================================================================
|
||||
# WARNING: Throughput degradation (possible throttling)
|
||||
# ====================================================================
|
||||
- alert: LlamaSwapThroughputDegradation
|
||||
expr: |
|
||||
(rate(llamacpp_tokens_predicted_total[5m]) * 60) < 40
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
component: llm-inference
|
||||
annotations:
|
||||
summary: "Token generation throughput low on {{ $labels.model }}"
|
||||
description: |
|
||||
Token generation rate is {{ $value | humanize }}tokens/min on {{ $labels.model }}
|
||||
(baseline threshold: ~50+ tokens/min).
|
||||
|
||||
This may indicate:
|
||||
1. Thermal throttling (GPU temperature limiting frequency)
|
||||
2. Memory pressure (even if VRAM not full, latency can increase)
|
||||
3. CPU contention (if models are CPU-offloaded)
|
||||
4. Incoming request rate exceeds model capacity (check queue depth)
|
||||
|
||||
Recommended actions:
|
||||
- Check nvidia-smi output for GPU temperature and throttle flags
|
||||
- Compare queue depth to baseline (alert if >5 sustained)
|
||||
- Check CPU usage and interrupt frequency (vmstat 1 1)
|
||||
- Review log tail for errors or warnings from llama-swap
|
||||
|
||||
Model: {{ $labels.model }}
|
||||
Instance: {{ $labels.instance }}
|
||||
|
||||
# ====================================================================
|
||||
# INFO: Scrape failures (monitoring health)
|
||||
# ====================================================================
|
||||
- alert: LlamaSwapScrapeFailed
|
||||
expr: up{job="llama-swap"} == 0
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
component: monitoring
|
||||
annotations:
|
||||
summary: "llama-swap Prometheus scrape failed"
|
||||
description: |
|
||||
Prometheus cannot scrape llama-swap's /metrics endpoint at
|
||||
http://{{ $labels.instance }}/metrics (HTTP {{ $value }} or timeout).
|
||||
|
||||
The monitoring pipeline is degraded. Check:
|
||||
1. llama-swap service status: systemctl status llama-swap
|
||||
2. Network reachability: curl http://{{ $labels.instance }}/metrics
|
||||
3. Prometheus scrape logs in Prometheus UI (Alerts -> llama-swap)
|
||||
|
||||
Instance: {{ $labels.instance }}
|
||||
@@ -0,0 +1,59 @@
|
||||
{#
|
||||
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 %}
|
||||
@@ -0,0 +1,534 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "MiB",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 10,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"tooltip": false,
|
||||
"viz": false,
|
||||
"legend": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"max": 24576,
|
||||
"min": 0,
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 23000
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 24000
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 1,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [
|
||||
"last",
|
||||
"max"
|
||||
],
|
||||
"displayMode": "table",
|
||||
"placement": "right"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "8.0.0",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "llamacpp_vram_used_mib{job=\"node\"}",
|
||||
"interval": "",
|
||||
"legendFormat": "VRAM Used",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "GPU VRAM Usage",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"mappings": [],
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 0.8
|
||||
},
|
||||
{
|
||||
"color": "orange",
|
||||
"value": 0.92
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 0.95
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"id": 2,
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"values": false,
|
||||
"fields": "",
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
]
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "8.0.0",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "llamacpp_kv_cache_usage_ratio",
|
||||
"interval": "",
|
||||
"legendFormat": "{{ model }}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "KV-Cache Utilization (Gauge)",
|
||||
"type": "gauge"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "ms/token",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"tooltip": false,
|
||||
"viz": false,
|
||||
"legend": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": true,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "ms"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 8
|
||||
},
|
||||
"id": 3,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [
|
||||
"mean",
|
||||
"max"
|
||||
],
|
||||
"displayMode": "table",
|
||||
"placement": "right"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "8.0.0",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "rate(llamacpp_time_predict_ms_sum[5m]) / rate(llamacpp_time_predict_ms_count[5m])",
|
||||
"interval": "",
|
||||
"legendFormat": "{{ model }}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Prediction Latency by Model",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "Queue Size",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"tooltip": false,
|
||||
"viz": false,
|
||||
"legend": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": true,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 8
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [
|
||||
"mean",
|
||||
"max"
|
||||
],
|
||||
"displayMode": "table",
|
||||
"placement": "right"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "8.0.0",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "llamacpp_queue_size",
|
||||
"interval": "",
|
||||
"legendFormat": "{{ model }}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Request Queue Depth",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "tokens/min",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"tooltip": false,
|
||||
"viz": false,
|
||||
"legend": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": true,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 16
|
||||
},
|
||||
"id": 5,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"displayMode": "table",
|
||||
"placement": "right"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "8.0.0",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "rate(llamacpp_tokens_predicted_total[1m]) * 60",
|
||||
"interval": "",
|
||||
"legendFormat": "{{ model }} (tokens/min)",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Token Generation Throughput",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": "Prometheus",
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "Tokens",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "bars",
|
||||
"fillOpacity": 100,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"tooltip": false,
|
||||
"viz": false,
|
||||
"legend": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": true,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "normal"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 16
|
||||
},
|
||||
"id": 6,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "8.0.0",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.95, rate(llamacpp_time_predict_ms_bucket[5m]))",
|
||||
"interval": "",
|
||||
"legendFormat": "p95 latency",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "histogram_quantile(0.99, rate(llamacpp_time_predict_ms_bucket[5m]))",
|
||||
"interval": "",
|
||||
"legendFormat": "p99 latency",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"title": "Latency Percentiles (p95, p99)",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"refresh": "30s",
|
||||
"schemaVersion": 27,
|
||||
"style": "dark",
|
||||
"tags": [
|
||||
"llm",
|
||||
"llama-swap",
|
||||
"gpu-monitoring",
|
||||
"ciro-luciotta"
|
||||
],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-24h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "llama-swap GPU/LLM Monitoring",
|
||||
"uid": "llama-swap-monitor",
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
# ==============================================================================
|
||||
# FILE: roles/llm-inference-multimodel/templates/llama-swap-prometheus-scrape.yml.j2
|
||||
# DESCRIPTION: Prometheus scrape job configuration for llama-swap's native
|
||||
# /metrics endpoint (OpenMetrics format).
|
||||
#
|
||||
# This template is rendered and deployed to the Prometheus
|
||||
# config via GitOps (cluster/applications/monitoring/values.yaml).
|
||||
# Does NOT include this file inline here; it is referenced and
|
||||
# rendered by Ansible roles/llm-inference-multimodel/tasks/*.yml.
|
||||
#
|
||||
# TARGET HOST: astro-orbiter ({{ llm_bind_address }}:{{ llm_swapmode_port }})
|
||||
# METRICS: llamacpp_tokens_predicted_total, llamacpp_kv_cache_usage_ratio,
|
||||
# llamacpp_time_predict_ms, llamacpp_queue_size, etc. (per llama.cpp)
|
||||
#
|
||||
# AUTHOR: Wong (Infrastructure Automation Specialist)
|
||||
# DATE: 2026-08-18
|
||||
# ==============================================================================
|
||||
|
||||
---
|
||||
- job_name: llama-swap
|
||||
static_configs:
|
||||
- targets: ["{{ llm_bind_address }}:{{ llm_swapmode_port }}"]
|
||||
labels:
|
||||
component: llm-inference
|
||||
service: llama-swap
|
||||
environment: homelab
|
||||
scrape_interval: 30s
|
||||
scrape_timeout: 10s
|
||||
honor_labels: true
|
||||
metrics_path: /metrics
|
||||
|
||||
# Relabeling: extract model name from metric labels for dashboard grouping
|
||||
metric_relabel_configs:
|
||||
- source_labels: [__name__]
|
||||
regex: 'llamacpp_.*'
|
||||
action: keep
|
||||
@@ -0,0 +1,53 @@
|
||||
{#
|
||||
FILE: roles/llm-inference-multimodel/templates/llama-swap.service.j2
|
||||
DESCRIPTION: llama-swap systemd unit template.
|
||||
Single Go binary, no subprocess management — just a /usr/local/bin/llama-swap
|
||||
process reading /etc/llama-swap/config.yaml.
|
||||
|
||||
Design:
|
||||
- Type=simple (no forking)
|
||||
- User={{ llm_swapmode_service_user }} (jarvis)
|
||||
- Restart=on-failure, RestartSec=10
|
||||
- Logs to journald (StandardOutput/StandardError=journal)
|
||||
- After nvidia-persistenced.service (NVIDIA driver dependency)
|
||||
|
||||
Config location: /etc/llama-swap/config.yaml (rendered by swapmode_config phase)
|
||||
Listen address: 127.0.0.1 inside the container (exposed by --listen flag)
|
||||
#}
|
||||
[Unit]
|
||||
Description=llama-swap — hot-swap model proxy (port {{ llm_swapmode_port }})
|
||||
Documentation=https://github.com/mostlygeek/llama-swap
|
||||
After=network.target nvidia-persistenced.service
|
||||
Wants=nvidia-persistenced.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ llm_swapmode_service_user }}
|
||||
Group={{ llm_swapmode_service_user }}
|
||||
Environment="HOME=/home/{{ llm_swapmode_service_user }}"
|
||||
|
||||
ExecStart=/usr/local/bin/llama-swap \
|
||||
--config {{ llm_swapmode_config_file }} \
|
||||
--listen {{ llm_swapmode_bind_address }}:{{ llm_swapmode_port }}
|
||||
|
||||
# LLAMA-SWAP NOTES (2026-08-18, t_c1e44190):
|
||||
# - Single Go binary, zero runtime dependencies (llama.cpp statically linked).
|
||||
# - Upstream servers (llama-server instances) are spawned on-demand per config.yaml model definitions.
|
||||
# - --listen can override config.yaml's listen key; this flag takes precedence.
|
||||
# Double-check consistency between ExecStart and config.yaml.
|
||||
# - CUDA_VISIBLE_DEVICES can be set via Environment= if GPU isolation is needed.
|
||||
# Default: inherit from parent (systemd likely has it unset, picks all GPUs).
|
||||
# - No jinja flag needed: llama.cpp model templates are embedded in each model's GGUF.
|
||||
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
TimeoutStartSec=600
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=llama-swap
|
||||
|
||||
# Resource limits (optional; adjust per VRAM budget)
|
||||
# MemoryMax=24G # Enforce hard limit; uncomment if runaway is a concern
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user