Files
ollama37/tests/testcases/inference/TC-INFERENCE-004.yml
Shang Chieh Tseng 2c5094db92 Add LogCollector for precise test log boundaries
Problem: Tests used `docker compose logs --since=5m` which caused:
- Log overlap between tests
- Logs from previous tests included
- Missing logs if test exceeded 5 minutes

Solution:
- New LogCollector class runs `docker compose logs --follow`
- Marks test start/end boundaries
- Writes test-specific logs to /tmp/test-{testId}-logs.txt
- Test steps access via TEST_ID environment variable

Changes:
- tests/src/log-collector.ts: New LogCollector class
- tests/src/executor.ts: Integrate LogCollector, set TEST_ID env
- tests/src/cli.ts: Start/stop LogCollector for runtime/inference
- All test cases: Use log collector with fallback to docker compose

Also updated docs/CICD.md with:
- Test runner CLI documentation
- Judge modes (simple, llm, dual)
- Log collector integration
- Updated test case list (12b, 27b models)
- Model unload strategy
- Troubleshooting guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 17:46:49 +08:00

122 lines
3.9 KiB
YAML

id: TC-INFERENCE-004
name: Medium Model (12b) Inference
suite: inference
priority: 4
timeout: 600000
dependencies:
- TC-INFERENCE-003
steps:
- name: Check if gemma3:12b model exists
command: docker exec ollama37 ollama list | grep -q "gemma3:12b" && echo "Model exists" || echo "Model not found"
- name: Pull gemma3:12b model if needed
command: docker exec ollama37 ollama list | grep -q "gemma3:12b" || docker exec ollama37 ollama pull gemma3:12b
timeout: 900000
- name: Verify model available
command: docker exec ollama37 ollama list | grep gemma3:12b
- name: Warmup model (preload into GPU)
command: |
curl -s http://localhost:11434/api/generate \
-d '{"model":"gemma3:12b","prompt":"hi","stream":false}' \
| jq -r '.response' | head -c 100
timeout: 300000
- name: Verify model loaded to GPU
command: |
# Use log collector file if available, fallback to docker compose logs
if [ -f "/tmp/test-${TEST_ID}-logs.txt" ]; then
LOGS=$(cat /tmp/test-${TEST_ID}-logs.txt)
else
LOGS=$(cd docker && docker compose logs --since=5m 2>&1)
fi
echo "=== Model Loading Check for gemma3:12b ==="
# Check for layer offloading to GPU
if echo "$LOGS" | grep -q "offloaded.*layers to GPU"; then
echo "SUCCESS: Model layers offloaded to GPU"
echo "$LOGS" | grep "offloaded.*layers to GPU" | tail -1
else
echo "ERROR: Model layers not offloaded to GPU"
exit 1
fi
# Check llama runner started
if echo "$LOGS" | grep -q "llama runner started"; then
echo "SUCCESS: Llama runner started"
else
echo "ERROR: Llama runner not started"
exit 1
fi
- name: Run inference test
command: docker exec ollama37 ollama run gemma3:12b "What is the capital of France? Answer in one word." 2>&1
timeout: 180000
- name: Check GPU memory usage
command: |
echo "=== GPU Memory Usage ==="
docker exec ollama37 nvidia-smi --query-gpu=index,memory.used,memory.total --format=csv
echo ""
echo "=== GPU Processes ==="
docker exec ollama37 nvidia-smi --query-compute-apps=pid,used_memory --format=csv 2>/dev/null || echo "No GPU processes listed"
- name: Check for inference errors
command: |
# Use log collector file if available, fallback to docker compose logs
if [ -f "/tmp/test-${TEST_ID}-logs.txt" ]; then
LOGS=$(cat /tmp/test-${TEST_ID}-logs.txt)
else
LOGS=$(cd docker && docker compose logs --since=5m 2>&1)
fi
echo "=== Inference Error Check ==="
if echo "$LOGS" | grep -qE "CUBLAS_STATUS_"; then
echo "CRITICAL: CUBLAS error during inference:"
echo "$LOGS" | grep -E "CUBLAS_STATUS_"
exit 1
fi
if echo "$LOGS" | grep -qE "CUDA error"; then
echo "CRITICAL: CUDA error during inference:"
echo "$LOGS" | grep -E "CUDA error"
exit 1
fi
if echo "$LOGS" | grep -qi "out of memory"; then
echo "ERROR: Out of memory"
echo "$LOGS" | grep -i "out of memory"
exit 1
fi
echo "SUCCESS: No inference errors"
- name: Unload model after test
command: |
echo "Unloading gemma3:12b from VRAM..."
curl -s http://localhost:11434/api/generate -d '{"model":"gemma3:12b","keep_alive":0}' || true
sleep 2
echo "Model unloaded"
criteria: |
The gemma3:12b model should run inference on Tesla K80.
Expected:
- Model downloads successfully (~8GB)
- Model loads into GPU (single GPU should be sufficient)
- Logs show "offloaded X/Y layers to GPU"
- Logs show "llama runner started"
- Inference returns a response mentioning "Paris"
- NO CUBLAS_STATUS_ errors
- NO CUDA errors
- NO out of memory errors
- GPU memory shows allocation (~10GB)
This is a medium-sized model that should fit in a single K80 GPU.
Accept any reasonable answer about France's capital.