Skip to content

fix: sofai_graph_coloring example fails — Ollama model runner crash with phi:2.7b #806

Closed

Description

@planetf1

Description

docs/examples/sofai/sofai_graph_coloring.py fails consistently, including when run standalone:

uv run pytest docs/examples/sofai/sofai_graph_coloring.py -s -v

Error

ollama._types.ResponseError: model runner has unexpectedly stopped, this may be
due to resource limitations or an internal error, check ollama server logs for
details (status code: 500)

The crash occurs during the S1 solver's first attempt (phi:2.7b), before any iteration completes:

S1 Solver:   0%|          | 0/3 [00:01<?, ?it/s]

Reproduction

Fails on macOS Apple Silicon (32 GB), not memory-related — phi:2.7b is ~1.7 GB and no other models are loaded. Reproduces both standalone and within the full test suite.

Possible causes

  • phi:2.7b model incompatibility with current Ollama version
  • The model ID may need updating (e.g. to phi3:mini or another small model)
  • Ollama server-side bug with this specific model

Environment

  • macOS 26.5 (Apple Silicon)
  • Python 3.12.8
  • Ollama (latest)

Activity

  1. added
    bug
    on Apr 9, 2026
  2. added theissue type on Apr 9, 2026
  3. planetf1 commented on Apr 9, 2026

    @planetf1
    ContributorAuthor

    Ran ollama 0.20.4 with debug.

    Assertion failed: (found), function llama_sampler_dist_apply, file llama-sampling.cpp, line 660.
    SIGABRT: abort
    PC=0x1816cd5e8 m=3 sigcode=0
    signal arrived during cgo execution
    
    goroutine 66 gp=0x73743ef24b40 m=3 mp=0x73743eb5f008 [syscall]:
    runtime.cgocall(0x1011d59d4, 0x73743ee6bc48)
            runtime/cgocall.go:167 +0x44 fp=0x73743ee6bc00 sp=0x73743ee6bbc0 pc=0x1003b4544
    github.com/ollama/ollama/llama._Cfunc_common_sampler_csample(0x1050009d0, 0x104ff75b0, 0xaf)
            _cgo_gotypes.go:417 +0x30 fp=0x73743ee6bc40 sp=0x73743ee6bc00 pc=0x1007d3ed0
    github.com/ollama/ollama/runner/llamarunner.(*Server).processBatch.(*SamplingContext).Sample.func1(...)
            github.com/ollama/ollama/llama/llama.go:679
    github.com/ollama/ollama/llama.(*SamplingContext).Sample(...)
            github.com/ollama/ollama/llama/llama.go:679
    github.com/ollama/ollama/runner/llamarunner.(*Server).processBatch(0x73743edb2140, 0x73743f12c0a0, 0x73743ef8d718)
            github.com/ollama/ollama/runner/llamarunner/runner.go:539 +0x500 fp=0x73743ee6bed0 sp=0x73743ee6bc40 pc=0x10086f7a0
    github.com/ollama/ollama/runner/llamarunner.(*Server).run(0x73743edb2140, {0x102340fc0, 0x73743eb2a0f0})
            github.com/ollama/ollama/runner/llamarunner/runner.go:387 +0x158 fp=0x73743ee6bfa0 sp=0x73743ee6bed0 pc=0x10086f178
    github.com/ollama/ollama/runner/llamarunner.Execute.gowrap1()
            github.com/ollama/ollama/runner/llamarunner/runner.go:981 +0x24 fp=0x73743ee6bfd0 sp=0x73743ee6bfa0 pc=0x100873284
    runtime.goexit({})
            runtime/asm_arm64.s:1447 +0x4 fp=0x73743ee6bfd0 sp=0x73743ee6bfd0 pc=0x1003bf784
    created by github.com/ollama/ollama/runner/llamarunner.Execute in goroutine 1
            github.com/ollama/ollama/runner/llamarunner/runner.go:981 +0x414
    

    The model phi:2.7b is very old (2023) -- and the error relates to an issue with the quantization. This has also been seen with very new models, but may be indicative of this old model also no longer being supported with current ollama

  4. self-assigned this
    on Apr 9, 2026
  5. planetf1 commented on Apr 9, 2026

    @planetf1
    ContributorAuthor

    Investigation findings

    Crash root cause

    OLLAMA_DEBUG=1 shows the crash is an assertion failure in the GGUF sampler:

    Assertion failed: (found), function llama_sampler_dist_apply, file llama-sampling.cpp, line 660.
    

    This is a known incompatibility between phi:2.7b (older GGUF quant) and current Ollama versions — not a memory or resource issue.

    Pre-existing test bug

    The example also had an incorrect problem definition:

    • graph dict defined a path (A—B—C): {"A": ["B"], "B": ["A", "C"], "C": ["B"]}
    • graph_description string described a triangle (A—B—C—A): "A is adjacent to B and C; B is adjacent to A and C; C is adjacent to A and B"
    • Only 2 colors offered (Red, Blue) — insufficient for the triangle the LLM reads in the prompt

    The LLM correctly determines the prompted triangle needs 3 colors, introduces "Green", and the validator rejects it. The SOFAI loop never demonstrated what it was supposed to.

    Fix

    Model replacement: phi:2.7b → granite4:micro (S1), pielee/qwen3-4b-thinking-2507_q8:latest → granite4:latest (S2). Both already pulled for other tests.

    Problem fix — simple option considered but rejected: Making graph and description consistent as K₃ + 3 colors fixes correctness, but the problem is trivial — the LLM solves it first try and the SOFAI retry loop is never exercised.

    Problem fix — adopted: Changed to an odd 5-cycle (A—B—C—D—E—A) with 3 colors. This is non-trivial enough that granite4:micro consistently fails (wraps JSON in markdown, gets adjacency wrong), triggering S1→S2 escalation. Deterministic with seed=42, temperature=0.1. Verified passing twice standalone.

  6. pinned and unpinned a comment on Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugtesting

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions