Skip to content

Testing is generally broken #604

Closed

Description

@frreiss

#416 made some changes to how tests are run. Specifically, this change set added a post-collection hook to the pytest configuration for Mellea. This hook looks for selected tests that are marked with the "requires_heavy_ram" tag. If it finds such tests, it runs these tests in separate processes, one process per Python source file. This change appears to be intended to prevent tests from running out of GPU memory.

This new way of doing testing created problems:

  • If any selected tests for the current session have the "requires_heavy_ram" marker, then tests that do not have this marker will not run. For example, the command uv run pytest test will only run 51 of the 451 tests in the project.
  • The collection hook breaks pytest's --discover option, which in turn breaks Visual Studio Code's pytest support. Because Visual Studio Code cannot enumerate tests in the project, the Visual Studio Code UI cannot run or debug individual tests.
  • The process isolation mechanism hides memory leaks. Mellea applications are supposed to be able to start and stop backends without leaking memory.
  • Ollama-based tests still leak GPU memory, even when run under the new process isolation. These tests do not tell Ollama to stop serving their target models.
  • Ollama eventually shuts down models several minutes after Ollama-based tests have completed. If a vLLM test is running while one of these Ollama shutdown events occurs, the vLLM server will detect that available GPU memory has changed and will fail the entire test suite with several pages of stack trace.
  • If a test in a subprocess fails, the main process will not tell you that it failed but will instead report, "Heavy GPU tests completed in isolated processes". To determine whether the tests in a given run succeeded, one needs to scroll through several screens of output, carefully checking for failed tests in each separate process's output.
  • The "requires_heavy_ram" marker does not appear to be intended to flag heavy GPU RAM usage, but instead is intended to flag CPU RAM requirements in excess of 48GB. Some tests that are not marked with "requires_heavy_ram" use just as much GPU memory as the tests that have the marker.
  • Occasionally one of the background processes will hang indefinitely for no apparent reason.

Activity

  1. planetf1 commented on Mar 7, 2026

    @planetf1
    Contributor

    Thanks @frreiss for spotting these issues.

    #446 was intended to address probems with the way the nvidia driver locks gpu memory at the os process level - so regular python/pytorch cleanup wasn't effective in achieving cleanup - so we had oom crashes when running multiple tests. - but of course these had these undesirable effects that we hadn't noticed :-

    I think the tests could be fixed with:

    • ensuring --collect-only bypasses the isolation code - which should ensure vscode collection works (I'd not tried the vscode plugin, cli seemed fine)
    • Removing the pytest.exit() and instead properly filter the test list (we lost tests here - not good)
    • Make the process opt-in - at least for now. So add something like ``--isolate-heavy` ? this gives an opportunity to some more verification without impacting non high-load sequential testing
    • consider if we can do any other additional cleanup - for example in ollama - to reduce the overall overhead for back to back tests
    • keep isolation distinct from gpu memory requirement. It can then be more targetted since this locking issue doesn't necessarily affect all the ways in which we run tests

    I'll give a go and create a PR - it would be great if you could give it a go. If you have other ideas too let's discuss!
    (I did consider some of the plugins, but I don't think they're flexible enough given the hardware limitations) (aside: what environment were you running it - I can test in bluevela or on a 32GB mac m1 easily. other configs harder)

    The objective is to reliably run as many tests as possible, with clear results, in many different configurations, with minimal developer workload....

  2. self-assigned this
    on Mar 7, 2026
  3. added 5 commits that reference this issue on Mar 7, 2026
    cee30ac
    32d57ec
    294f810
    46f90d7
    69dec33
  4. planetf1 commented on Mar 7, 2026

    @planetf1
    Contributor

    Added #605 - have done local tests. Would be great @frreiss if you could check/rerun. I'll do some more testing Mon.

  5. planetf1 commented on Mar 9, 2026

    @planetf1
    Contributor

    PR now ready for review/merge

  6. added 2 commits that reference this issue on Mar 12, 2026
    ca7b22b
    edfc99b
  7. added a commit that references this issue on Mar 12, 2026
    21746b1
  8. added a commit that references this issue on May 27, 2026
    6faaf70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions