Objetivo
Section titled “Objetivo”Operar el SLO enforcement runtime de AI-LAB: verificar estado, interpretar degradaciones, activar/desactivar enforcement, y diagnosticar metricas flatlineadas o transiciones incorrectas.
Vista rapida
Section titled “Vista rapida”# Estado SLO completocurl -s http://192.168.1.30:8008/slo/health | jq .
# Metricas clavecurl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_slo"curl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_degradation"curl -s http://192.168.1.30:8008/metrics | grep "ailab_slo_violations"
# Dashboard# https://192.168.1.40:3000/d/ailab-runtime-protectionEstados SLO
Section titled “Estados SLO”| Codigo | Nombre | Color | Significado |
|---|---|---|---|
| 0 | GREEN | Verde | Todos los SLOs dentro de target. Operacion normal. |
| 1 | YELLOW | Amarillo | 1+ SLO en warning. Degradacion LIGHT activa (si enforcement ON). |
| 2 | RED | Rojo | 1+ SLO en critical. Degradacion HEAVY/EMERGENCY (si enforcement ON). |
Que hacer en cada estado
Section titled “Que hacer en cada estado”GREEN: monitoreo normal. No requiere accion.
YELLOW: revisar que SLO esta en warning:
curl -s http://192.168.1.30:8008/slo/health | jq '.violations[] | select(.level=="warning")'Causas tipicas: GPU>85% temporal, TTFB p50>800ms por cold start, pico de requests.
RED: identificar que SLO esta en critical:
curl -s http://192.168.1.30:8008/slo/health | jq '.violations[] | select(.level=="critical")'Causas tipicas: GPU>95% sostenido, timeout rate>5%, VRAM>97%, gateway crash o orphan stream.
Niveles de Degradacion
Section titled “Niveles de Degradacion”| Level | Nombre | Que protege | Como diagnosticar |
|---|---|---|---|
| 0 | NORMAL | — | ailab_runtime_degradation_level == 0 |
| 1 | LIGHT | qwen, TTFB | ailab_runtime_degradation_level == 1. Forced llama activo. |
| 2 | HEAVY | VRAM, estabilidad | No auto-activo. Observable via metrica. |
| 3 | EMERGENCY | gateway, streams | No auto-activo. Observable via metrica. |
Ver protecciones activas
Section titled “Ver protecciones activas”# Forced llama routing eventscurl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_llama_fastpath_forced_total"
# Qwen protection eventscurl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_qwen_protection_total"
# Emergency activationscurl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_emergency_mode_total"
# Concurrencia dinamica actualcurl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_qwen_parallel"curl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_concurrent_streams"Feature Flags
Section titled “Feature Flags”# Ver estado actualecho "SLO_DRY_RUN=${AI_LAB_SLO_DRY_RUN:-true}"echo "SLO_ENFORCEMENT=${AI_LAB_ENABLE_SLO_ENFORCEMENT:-false}"
# Para activar enforcement real (tras validar dry-run):export AI_LAB_SLO_DRY_RUN=falseexport AI_LAB_ENABLE_SLO_ENFORCEMENT=true# Requiere reinicio del gateway: sudo systemctl restart ailab-gateway
# Para desactivar (rollback inmediato):export AI_LAB_ENABLE_SLO_ENFORCEMENT=false# Sin reinicio: solo afecta a nuevos requests, no requiere restartProcedimiento: Pasar de DRY RUN a ENFORCEMENT
Section titled “Procedimiento: Pasar de DRY RUN a ENFORCEMENT”-
Verificar metricas en dry-run (15 min minimo):
Terminal window curl -s http://192.168.1.30:8008/slo/health | jq .Confirmar que
ailab_runtime_slo_state,ailab_runtime_degradation_levelaparecen en/metricscon valores correctos. -
Validar dashboard: abrir AI-LAB Runtime Protection en Grafana. Confirmar que los 14 paneles muestran datos.
-
Forzar transicion YELLOW (opcional, para validar): Generar suficiente carga para que GPU suba >85%. Verificar que
ailab_runtime_slo_statecambia a 1. -
Activar enforcement:
Terminal window sudo systemctl set-environment AI_LAB_SLO_DRY_RUN=falsesudo systemctl set-environment AI_LAB_ENABLE_SLO_ENFORCEMENT=truesudo systemctl restart ailab-gateway -
Verificar enforcement activo:
Terminal window curl -s http://192.168.1.30:8008/slo/health | jq '{dry_run, enabled, slo_state, degradation_level}'dry_rundebe serfalse,enableddebe sertrue. -
Burn-in 30 min: ejecutar 3 workers concurrentes, verificar:
- Degradacion LEVEL 1 se activa/desactiva segun carga
- 0 crashes, 0 orphan streams
- TTFB se mantiene dentro de SLO targets
Procedimiento: Rollback
Section titled “Procedimiento: Rollback”Si el enforcement causa problemas:
-
Desactivar enforcement (no requiere restart):
Terminal window export AI_LAB_ENABLE_SLO_ENFORCEMENT=falseEsto solo afecta a nuevos requests. Las conexiones activas no se interrumpen.
-
Rollback completo a dry-run:
Terminal window sudo systemctl set-environment AI_LAB_SLO_DRY_RUN=truesudo systemctl set-environment AI_LAB_ENABLE_SLO_ENFORCEMENT=falsesudo systemctl restart ailab-gateway -
Verificar rollback:
Terminal window curl -s http://192.168.1.30:8008/slo/health | jq '{dry_run, enabled, degradation_level}'dry_run=true,enabled=false,degradation_level=0.
Troubleshooting
Section titled “Troubleshooting”Problema: ailab_runtime_* metricas no aparecen en /metrics
Section titled “Problema: ailab_runtime_* metricas no aparecen en /metrics”Causa: runtime/slo/ no se importa correctamente.
Diagnostico:
curl -s http://192.168.1.30:8008/slo/healthSi devuelve {"error": "slo_module_unavailable"}, el modulo no cargo.
Causas posibles:
prometheus_clientno instalado en el venv- Error de import en
runtime/slo/metrics.py runtime/slo/__init__.pylanza excepcion
Fix: verificar el venv:
/opt/ai-lab/.venv/bin/pip list | grep prometheus_clientpython3 -c "from runtime.slo import RuntimeSLOManager; print('OK')"Problema: degradation_level siempre 0 incluso con GPU>95%
Section titled “Problema: degradation_level siempre 0 incluso con GPU>95%”Causa: dry-run mode activo o SLO enforcement desactivado.
Verificar:
curl -s http://192.168.1.30:8008/slo/health | jq '{dry_run, enabled}'Si dry_run=true, el DegradationManager evalua y logea pero NO cambia metrica ni actua. Esperado.
Si enabled=false, el enforcement entero esta desactivado. Esperado hasta activacion manual.
Problema: Transiciones SLO demasiado rapidas (flapping)
Section titled “Problema: Transiciones SLO demasiado rapidas (flapping)”El DegradationManager tiene anti-flapping explicito: minimo 30s entre transiciones de nivel. Si ves transiciones rapidas (>1 cada 30s), hay un bug.
Diagnostico:
# Ver cambios en degradation_levelcurl -s http://192.168.1.30:8008/metrics | grep "ailab_runtime_degradation_level"Si cambia mas de una vez cada 30s, revisar runtime/slo/degradation.py → MIN_TRANSITION_INTERVAL.
Problema: Circuit breaker se abre pero requests siguen yendo al modelo
Section titled “Problema: Circuit breaker se abre pero requests siguen yendo al modelo”Esperado. En esta fase los circuit breakers son observables solamente. No bloquean requests. La metrica ailab_circuit_breaker_state expone el estado (0=closed, 1=half, 2=open) pero should_allow() siempre retorna True.
Si se requiere bloqueo real en una emergencia, usar el degradation manager (LEVEL 3) que fuerza llama-only via gateway.
Problema: Concurrencia dinamica no cambia
Section titled “Problema: Concurrencia dinamica no cambia”Verificar que AdaptiveConcurrency.update() se llama en cada request. Si el gateway no reporta GPU util (siempre 0.0), el concurrency no se adapta.
curl -s http://192.168.1.30:8008/slo/health | jq '.snapshot.gpu_util'Si es 0.0 constantemente, el gateway no esta reportando GPU state. Revisar GPU_ACTIVE_REQUESTS en el gateway.
Problema: Priority lanes no funcionan (Lane 1 no tiene prioridad)
Section titled “Problema: Priority lanes no funcionan (Lane 1 no tiene prioridad)”Los priority lanes actualmente son slots reservados en stream_sanitizer.py, no una cola de prioridad real. Lane 1 tiene 2 slots dedicados, pero si esos slots estan libres y hay requests de Lane 2, estos pueden ocuparlos.
Para que Lane 1 tenga prioridad real, PrioritySlotManager.acquire_slot("critical") debe ser llamado explicitamente desde el gateway antes de iniciar el stream. Verificar que el gateway lo usa.
PromQL Queries Rapidas
Section titled “PromQL Queries Rapidas”Estado SLO actual
Section titled “Estado SLO actual”ailab_runtime_slo_stateNivel de degradacion
Section titled “Nivel de degradacion”ailab_runtime_degradation_levelTasa de violaciones SLO
Section titled “Tasa de violaciones SLO”rate(ailab_slo_violations_total[5m])Presion GPU (ultimos 5 min)
Section titled “Presion GPU (ultimos 5 min)”avg_over_time(ailab_runtime_gpu_pressure[5m])Eventos de proteccion a qwen
Section titled “Eventos de proteccion a qwen”rate(ailab_runtime_qwen_protection_total[5m])Llama forzado por degradacion
Section titled “Llama forzado por degradacion”rate(ailab_runtime_llama_fastpath_forced_total[5m])Distribucion de priority lanes
Section titled “Distribucion de priority lanes”rate(ailab_runtime_priority_lane_total[5m])Circuit breaker state actual
Section titled “Circuit breaker state actual”ailab_circuit_breaker_stateStream backlog actual
Section titled “Stream backlog actual”ailab_runtime_stream_backlogAlertas Sugeridas
Section titled “Alertas Sugeridas”SLO State RED
Section titled “SLO State RED”ailab_runtime_slo_state >= 2Severidad: critical. El runtime esta degradado. Revisar dashboard AI-LAB Runtime Protection.
Degradation Level > 0
Section titled “Degradation Level > 0”ailab_runtime_degradation_level > 0Severidad: warning. El enforcement esta activo. Revisar causas en ailab_slo_violations_total.
Emergency Mode
Section titled “Emergency Mode”increase(ailab_runtime_emergency_mode_total[5m]) > 0Severidad: critical. Emergency mode se activo. Revisar ailab_runtime_emergency_mode_total{reason=~".*"}.
Qwen Protection Spam
Section titled “Qwen Protection Spam”rate(ailab_runtime_qwen_protection_total[5m]) > 1Severidad: warning. Mas de 1 proteccion a qwen por segundo — posible escalation loop.
SLO Violations Acumuladas
Section titled “SLO Violations Acumuladas”increase(ailab_slo_violations_total[10m]) > 10Severidad: warning. Muchas violaciones de SLO en ventana de 10 min.
Referencias
Section titled “Referencias”- Codigo:
/opt/ai-lab/runtime/slo/ - Dashboard:
/opt/ai-lab/dashboards/ailab-runtime-protection.json - Documentacion:
historical/phases/fase-29.4-slo-enforcement.md - Gateway:
/opt/ai-lab/runtime/gateway/openai_gateway.py(buscar_HAVE_SLOyFASE 29.4) - Stream sanitizer:
/opt/ai-lab/runtime/gateway/stream_sanitizer.py(buscarset_max_streams)