You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Example tests leave Ollama models resident, starving subsequent tests #798
When running the full docs/examples/ suite, each example runs as a subprocess and loads its Ollama model. Ollama keeps models resident for the default 5-minute keep-alive timeout after each request. Heavyweight models (e.g. ibm/granite3.3-guardian:8b at ~11 GB) then sit in memory long after the example finishes, starving later tests of headroom.
This caused the SOFAI graph-colouring example to crash with a 500 from the model runner — not because the machine lacked memory in total, but because a guardian model from an earlier test was still resident.
Contrast with test/
test/conftest.py already handles this: it warms up CI models with keep_alive: -1 before the ollama group and evicts them with keep_alive: 0 afterwards. docs/examples/conftest.py has no equivalent.
Options
Set OLLAMA_KEEP_ALIVE=0 (or a short timeout) as an env var for example runs — models unload immediately after each example finishes
Add warm-up/eviction hooks to docs/examples/conftest.py, similar to test/conftest.py
Backend-level option — allow OllamaModelBackend to accept a keep_alive parameter passed through to the Ollama API
Worth noting: several examples use heavyweight or multi-model setups with no resource gating at all. The # pytest: comment syntax doesn't support predicates like require_ram, so there's currently no way for an example to declare its memory requirements.
Examples that would benefit from gating once the mechanism exists:
Example
Models loaded
Approx. total RAM
sofai/sofai_graph_coloring.py
phi:2.7b + pielee/qwen3-4b-thinking-2507_q8
~6.3 GB
safety/guardian_huggingface.py
deepseek-r1:8b + HF granite-guardian-3.3-8b
~16 GB
m_decompose/python/python_decompose_example.py
granite3.3:8b
~5 GB
image_text_models/vision_openai_examples.py
qwen2.5vl:7b
~6 GB
Proactive eviction (the main ask of this issue) would reduce the pressure, but a resource-gate mechanism for examples would let them skip gracefully on constrained machines rather than crashing mid-run.
Activity
planetf1 commentedon Apr 9, 2026
Worth noting: several examples use heavyweight or multi-model setups with no resource gating at all. The
# pytest:comment syntax doesn't support predicates likerequire_ram, so there's currently no way for an example to declare its memory requirements.Examples that would benefit from gating once the mechanism exists:
sofai/sofai_graph_coloring.pyphi:2.7b+pielee/qwen3-4b-thinking-2507_q8safety/guardian_huggingface.pydeepseek-r1:8b+ HFgranite-guardian-3.3-8bm_decompose/python/python_decompose_example.pygranite3.3:8bimage_text_models/vision_openai_examples.pyqwen2.5vl:7bProactive eviction (the main ask of this issue) would reduce the pressure, but a resource-gate mechanism for examples would let them skip gracefully on constrained machines rather than crashing mid-run.
fix: evict Ollama models between test modules to prevent memory starv…
fix: evict Ollama models between test modules to prevent memory starv…
fix: evict Ollama models after example tests (generative-computing#798)
psschwei commentedon Apr 9, 2026
making an assumption you're working this one @planetf1 😄
fix: evict Ollama models between test modules to prevent memory starv…
fix: evict Ollama models between test modules to prevent memory starv…