Skip to content

Use pytest-run-parallel to test thread safety #2114

Closed

Description

@leofang

Activity

  1. added
    P1Medium priority - Should do
    CI/CDCI/CD infrastructure
    on May 19, 2026
  2. added
    testImprovements or additions to tests
    cuda.bindingsEverything related to the cuda.bindings module
    cuda.coreEverything related to the cuda.core module
    on May 19, 2026
  3. kkraus14 commented on May 20, 2026

    @kkraus14
    Collaborator

    I suspect this would need a non-trivial amount of test refactoring to avoid teardowns that interact with the CUDA driver in a stateful way? There's so much state in the CUDA driver that it's hard to imagine doing this in an automated way safely.

  4. leofang commented on May 20, 2026

    @leofang
    MemberAuthor

    Maybe, maybe not. @seberg has invested a lot of efforts in CuPy and we're generally happy with us gaining more thread safety, following community standard, and having a CUDA project reaching FT-readiness. I am hopeful.

  5. seberg commented on May 20, 2026

    @seberg
    Contributor

    Yeah, I would propose to try it, after the CuPy release maybe I can have a look as well. CuPy had fun caches, the memory manager, and an awful lot of legacy unittest-style tests that were painful... I would think this is all much easier for cuda-python.

    I am not sure what might be problematic, e.g. graph capture related tests, seems like one that one may need to just mark as thread-unsafe in a first iteration. (In CuPy they are largely fine, but not fully e.g. because module loading/unloading in multiple threads can be problematic.)

    EDIT: I started to have a bit of a look.

    I suspect this would need a non-trivial amount of test refactoring to avoid teardowns that interact with the CUDA driver in a stateful way?

    Yeah, I now see what you mean. cuda-pathfinder tests seem fine with a few small thread-unsafe markers. But cuda-bindings/cuda-core would skip almost all tests without larger re-factor since it's fixtures need to run per-thread (e.g. due to cuInit()).
    It may work to convert these to normal decorators, but without that the pytest-run-parallel run wouldn't add much.

  6. added this to the cuda.core 1.2.0 milestone on Jul 16, 2026
  7. seberg commented on Sep 2, 2026

    @seberg
    Contributor

    This is implemented now running on the FT, CI jobs. A follow-up here may be to see if we can run this with TSAN to find more things and also to make it easier for downstream to use TSAN.

    If we worry about missing with nogil: leading to possible deadlocks, then it could also make sense to expand it to a non-FT job.

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

Metadata

Metadata

Assignees

Labels

CI/CDCI/CD infrastructureP1Medium priority - Should docuda.bindingsEverything related to the cuda.bindings modulecuda.coreEverything related to the cuda.core moduletestImprovements or additions to tests

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions