Skip to content

Unstable test suite when running locally #1314

Closed

Description

@exequeryphil

Summary

This issue tracks a set of reliability and contributor-experience problems found while running the full test suite locally (not slow and slow).
The work includes test/doc/example hardening so the suite is stable across common local environments (Ollama/HF/Apple Silicon).

Problems Observed

1) Missing prerequisite not clearly documented

  • Unit/test runs failed due to missing NLTK tokenizer resource (punkt_tab).
  • Contributor docs did not clearly call this out.

2) Docling crash/hang behavior on Macbook

  • Rich document processing fails or behaves inconsistently on MPS.
  • Needed a safer default path for Docling acceleration on Apple Silicon.

3) Slow/timeout-prone test/example behavior

  • Some tests/examples took excessively long or timed out in broad runs.
  • Slow-heavy paths were not consistently isolated from default fast loops.

4) Flaky intrinsic formatter slow tests (Transformers 5)

  • Known intermittent failures in specific intrinsic combinations caused hard failures.
  • These are environment/version-sensitive and non-deterministic.

5) Example robustness issues in local environments

  • m_serve tool-calling example failed if a specific model (granite4:micro-h) was unavailable.
  • GSM8K example failed when dataset loading/URI path failed.
  • Python decompose example failed on output-shape assumptions (KeyError).
  • Session example did heavyweight execution on import path, increasing hang risk.

6) Plugin example API misuse

  • Several plugin examples passed a list to plugin_scope where varargs were expected.

7) Brittle assertion in sampling preset example

  • Assertion depended on specific numeric tokens rather than stable semantic output.

Proposed Fixes

Documentation

  • Add explicit prerequisite guidance for NLTK punkt_tab in contributor/testing docs.

Runtime stability

  • Force Docling CPU accelerator path on Apple Silicon/MPS to avoid crashes.

Test/marker hygiene

  • Ensure slow-heavy tests are marked/isolated appropriately.
  • Add targeted xfail handling for known flaky intrinsic formatter cases under Transformers 5:
    • context_relevance_alora
    • context-attribution
    • uncertainty_alora

Example hardening

  • m_serve tool-calling example: add model fallback candidates and graceful skip behavior.
  • GSM8K example: fail-soft when dataset loading fails (clean skip/exit).
  • Decompose example: handle pipeline output variability defensively.
  • Session example: move runtime execution behind __main__, set bounded timeout, avoid heavy import-time work.

API correctness in examples

  • Fix plugin_scope usage to pass varargs instead of a list.

Assertion resilience

  • Relax brittle sampling preset assertion to validate stable expected behavior.

Validation

Broad test runs after fixes

  • uv run pytest -m "not slow" -vv --durations=40
  • uv run pytest -m slow -vv --durations=40

No remaining hard failures in either broad run.

Acceptance Criteria

  • Contributor docs clearly list required NLTK resource (punkt_tab) for test runs.
  • Apple Silicon Docling path is stable (no MPS-related crash in affected workflows).
  • Default non-slow suite passes consistently.
  • Slow suite passes with only expected xfail/skip outcomes.
  • Examples do not fail hard due to common local environment variability (model availability, dataset load issues).
  • Plugin examples use plugin_scope API correctly.
  • Known flaky intrinsic formatter combos are tracked and do not fail suite unexpectedly.

Activity

  1. planetf1 commented on Jun 23, 2026

    @planetf1
    Contributor

    PR #1292 covers the aLoRA-related items in this issue (Problems 3 & 4)

    The proposed fixes called for xfail markers on context_relevance_alora, context-attribution, and uncertainty_alora. PR #1292 goes further:

    Additionally, PR #1269 (Epic #929 Phase 1) fixes _find_adapter ordering so aLoRA is consistently preferred over LoRA, improving context-attribution and groundedness_e2e pass rates as a side effect.

    The acceptance criterion "Slow suite passes with only expected xfail/skip outcomes" should be met once #1292 merges. The remaining open items in this issue (NLTK docs, Docling MPS, example hardening, plugin_scope API, sampling assertion) are not touched by either PR.

  2. planetf1 commented on Jun 23, 2026

    @planetf1
    Contributor

    Issue #1318 also contributes to Problem 3 (slow/timeout-prone tests)

    The five test_tracing_backend.py tests (test_span_duration_captures_async_operation, test_context_propagation_parent_child, test_token_usage_recorded_after_completion, test_span_not_closed_prematurely, test_multiple_generations_separate_spans) are all e2e + ollama but not marked slow, so they run in the standard not slow suite. When Ollama is under load locally — the same condition as a saturated CI runner — they hit httpx.ReadTimeout and appear as hard failures.

    #1318 proposes applying the same split-and-mock treatment used in PR #1302: fast mocked equivalents run on every push; real-Ollama variants marked slow. Once that lands, the acceptance criterion "Default non-slow suite passes consistently" should be met for this failure class too.

  3. planetf1 commented on Jun 23, 2026

    @planetf1
    Contributor

    A few thoughts on the approach.

    xfail handling for intrinsic tests

    As noted in my earlier comment, #1292 takes a different route to the proposed xfail-all approach — two of the three failures turned out to be fixable with better-calibrated assertions. Worth carrying that pattern forward: reach for a tighter assertion before reaching for xfail, and save xfail for cases where the root cause is genuinely upstream.

    Fail-soft in examples

    Silent catches will just make CI pass quietly for the wrong reasons. The pattern already in the test suite — explicit skipif with a reason string — is more honest about what was skipped and why.

    plugin_scope API misuse

    Fixing the examples is necessary but the trap will catch the next person too. Might be worth a follow-on issue to add a guard in plugin_scope itself with a clear error message.

    Docling on Apple Silicon

    What's the intended fix here? The issue mentions "safer default path" but the options have fairly different trade-offs. Forcing CPU is the bluntest approach and will make Docling noticeably slower on the machines most likely to have the problem. Pinning a Docling version that's known-good on MPS is cleaner if the crash is version-specific. Skipping the test on Apple Silicon with an explicit reason is honest but loses coverage. And if the crash is inside Docling itself rather than in how we call it, the real fix may be upstream. Worth being clear about which of these is actually being proposed.

  4. planetf1 commented on Jun 23, 2026

    @planetf1
    Contributor

    I should also say … I 100% agree we need to get these tests stable across different hardware configurations - else how can we know the code works, or whether we broke it when fixing something else…. !

  5. exequeryphil commented on Jun 23, 2026

    @exequeryphil
    ContributorAuthor

    Yes, for Apple Silicon, I was thinking something like AcceleratorOptions(device=AcceleratorDevice.CPU). Trading speed for stability, but it seems tolerable on my machine.

    Agree with on your thoughts re xfail handling.

    I guess we can consider 3/4 in progress then.

    In the meantime, I can create a small PR for the NLTK prerequisite docs.

    And yes, after a making a small change locally, it was a little disconcerting to run the tests and see all the failures. It would be good to either add a proviso that 'only limited tests work in your local environment' or ensure that some reasonable regression is possible.

  6. added
    p2
    on Jun 23, 2026
  7. assigned and unassigned on Nov 9, 2026
  8. rafvasq commented on Nov 10, 2026

    @rafvasq
    Contributor

    Ran the test suite and the handful of failures I found are not due to instability. I'll close this issue since I believe the core concern (reliability and contributor-experience when running the tests) has been addressed.

    Feel free to reopen/open a new issue if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions