Description
Environment
- Machine: Apple M1, 32 GB, macOS 25.4.0
- Python: 3.12.8
- Ollama: 0.17.5
Issues
1. test_generate_from_raw — intermittent hang
I was unable to get this test reliable initially - it may be a bug in ollama or machine limitations. With no timeout (we didn't have one in the test originally) it could hang indefinately. The test looks ok, but is dependent on parallel execution. Using the granite4:micro model should be ok at 4 in parallel (and default context of 32k).
Experimenting with enforcing timeouts.
This was the main issue leading to long execution runs or failures
2. test_generate_from_raw_with_format — stale @pytest.mark.xfail
This is marked as xfail, yet was consistently passing. I think we could remove the marker now. The current test seems reliable
3. test_format (ollama + openai_ollama) — MAX_NEW_TOKENS too small
This also failed intermittently....
MAX_NEW_TOKENS = 2**8 (256 tokens) insufficient for structured JSON output; causes
truncated responses and assertion failures. Raising to 2**10 (1024 tokens) seems to inject reliability ...
4. researcher.py — 84-second test not gated by slow
pyproject.toml described slow as ">5 minutes". researcher.py (~84s) ran in every
default suite pass, dominating duration.
I think we need to add slow to its # pytest: markers; ( and having a policy of ">1 minute" seems more reasonable )
5. asyncio_default_fixture_loop_scope=None — pytest-asyncio warning
A warning - suspect will ifgnore this for now
6. Unclosed aiohttp ClientSession / TCPConnector at suite teardown
Unclosed client session: <aiohttp.client.ClientSession object at 0x156d68950>
Similar - and only occurs at the end of the test suite
Activity
planetf1 commentedon Mar 4, 2026
Will propose a PR with fixes to address the important issues here that are preventing clean execution of a default test run on m1 32GB mac (ie
uv run pytest)planetf1 commentedon Mar 4, 2026
A little more on the ollama test:
Possible fixes include adding retry into the backend, but it would be good to understand what is going on first. Reducing parallelism may also avoid the issue, but that may not be helpful
Other thoughts include - is it load related? Do we need to reduce context window since for 4 threads we need 4x ... (but monitoring, memory load seemed ok with granite4:micro)
The best 'quick fix' for now would be
Seeing if I can determine underlying cause..
planetf1 commentedon Mar 4, 2026
Unreliability rate is around 20%. For example:
Note that runs 10-12 failed consecutively -- it does seem related to other load. This is with a httpx timeout of 120s (each test hit 134s). Note that before timeouts I saw runs like 35s + ... One other run (9) got close to failing. Good runs can be as low as 20s, but timing is very variable
Next check - this test uses a 32K context (default for ollama backend) but is doing trivial work. Trying with 2k context. (so overall context goes from 128K -> 8K ie massive K-V cache reduction)
planetf1 commentedon Mar 4, 2026
With a smaller context only marginally better (and probably down to small # samples)
This looks like a concurrency bug, not resource limitation
planetf1 commentedon Mar 4, 2026
The assertions used in the test are not valid. In the event of failure we get "" (which is not None) so assertion passes... (which isn't helpful)
Additionally ..the cause of "" ? - this is what we end up returning in the ollama backend if anything fails... the original exception is swallowed and not reported anywhere :-(
For now will add a log entry (to help to debug the issue). But we need to consider how to surface exceptions. Will open an issue
planetf1 commentedon Mar 4, 2026
Related: opened #574 as the initial problem I got was a missing model. No code change but required an action
jakelorocco commentedon Mar 4, 2026
I believe
is related to: BerriAI/litellm#11657.
psschwei commentedon Mar 4, 2026
I have also seen Ollama hang, but for me I don't think it was related to these tests... I had granite4:micro stopping, but it seems to have gotten stuck stopping. Manually killing it / restarting the ollama service fixed the problem (and next run went much quicker)
planetf1 commentedon Mar 5, 2026
@jakelorocco yes agreed - actually I hit a similar issue in another project
@paul different machine spec may be a factor - I'm sure it's some kind of concurrency issue. The more serious aspect is that any errors are masked. So probably where initial focus should be.
planetf1 commentedon Mar 6, 2026
Created a PR with the misc fixes I needed when running tests, and created a new issue specifically to track the Ollama concurrency issue as #599 . There have also been many misc fixes to tests recently, including in error handling - so it would make sense to work on this issue on top of those fixes.