Skip to content

Migrate test infra to pytest#347

Merged
gmarkall merged 7 commits intoNVIDIA:mainfrom
ZzEeKkAa:yhavrylko/feature/pytest
Jul 24, 2025
Merged

Migrate test infra to pytest#347
gmarkall merged 7 commits intoNVIDIA:mainfrom
ZzEeKkAa:yhavrylko/feature/pytest

Conversation

@ZzEeKkAa
Copy link
Contributor

@ZzEeKkAa ZzEeKkAa commented Jul 23, 2025

Apparently pytest was already in dependencies but it was not working. There was no configuration and pytest could not recognize the layout. Now you can both run as file and as a package. Everything works:

pytest ./
pytest --pyargs numba.cuda.tests -v
pytest numba_cuda/numba/cuda/tests/cudapy/test_operator.py

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jul 23, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ZzEeKkAa
Copy link
Contributor Author

/ok to test

@ZzEeKkAa ZzEeKkAa requested review from gmarkall and leofang July 23, 2025 15:30
@kkraus14
Copy link
Contributor

Does everywhere that we're currently using unittest, i.e. https://github.com/NVIDIA/numba-cuda/blob/main/numba_cuda/numba/cuda/testing.py, need to be migrated to use pytest as well?

@ZzEeKkAa
Copy link
Contributor Author

Does everywhere that we're currently using unittest, i.e. https://github.com/NVIDIA/numba-cuda/blob/main/numba_cuda/numba/cuda/testing.py, need to be migrated to use pytest as well?

pytest supports running Python unittest-based tests out of the box. https://docs.pytest.org/en/stable/how-to/unittest.html . So we don't have to

@ZzEeKkAa
Copy link
Contributor Author

ZzEeKkAa commented Jul 23, 2025

For some reason wheel-test workflow does not see pytest as an executable, maybe some terminal settings, like user mode shell: bash -l {0}? Logs show that pytest was installed. Conda tests pass so.

UPD: decided to go with python -m pytest way.

@ZzEeKkAa
Copy link
Contributor Author

/ok to test

Copy link
Contributor

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

I have a concern about running in parallel, because of

class CUDATestCase(SerialMixin, TestCase):
"""
For tests that use a CUDA device. Test methods in a CUDATestCase must not
be run out of module order, because the ContextResettingTestCase may reset
the context and destroy resources used by a normal CUDATestCase if any of
its tests are run between tests from a CUDATestCase.
"""

When I run using pytest -n auto all the tests appear to run in parallel, whereas with Numba's runtests / unittest hardly any of the tests run in parallel. However, I was surprised to find this didn't result in segfaults due to the launch of kernels from a context that would have been deleted. One reason I might observe this would be if all the workers run their tests for a class serially, without interspersing tests from other classes in-between. I am wondering if it was only a "feature" of Numba's testing framework that interspersed runs of test methods from different test classes.

Whether or not we can safely run tests in parallel with pytest, I still think this change is a good thing - I notice the pytest serial run completes in about the same amount of time as the Numba runtests / unittest framework's parallel run, so I'll experiment with / investigate pytest parallel runs separately later.

@gmarkall gmarkall merged commit 202a996 into NVIDIA:main Jul 24, 2025
39 checks passed
@gmarkall
Copy link
Contributor

I'll experiment with / investigate pytest parallel runs separately later.

Followed up in #350.

@ZzEeKkAa ZzEeKkAa deleted the yhavrylko/feature/pytest branch July 24, 2025 13:12
gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request Jul 31, 2025
- [NFC] FileCheck tests check all overloads (NVIDIA#354)
- [REVIEW][NFC] Vendor in serialize to allow for future CUDA-specific refactoring and changes (NVIDIA#349)
- Vendor in usecases used in testing (NVIDIA#359)
- Add thirdparty tests of numba extensions (NVIDIA#348)
- Support running tests in parallel (NVIDIA#350)
- Add more debuginfo tests (NVIDIA#358)
- [REVIEW][NFC] Vendor in the Cache, CacheImpl used by CUDACache and CUDACacheImpl to allow for future CUDA-specific refactoring and changes (NVIDIA#334)
- [NFC] Vendor in Dispatcher as CUDADispatcher to allow for future CUDA-specific customization (NVIDIA#338)
- Vendor in BaseNativeLowering and BaseLower for CUDA-specific customizations (NVIDIA#329)
- [REVIEW] Vendor in the CompilerBase used by CUDACompiler to allow for future CUDA-specific refactoring and changes (NVIDIA#322)
- Vendor in Codegen and CodeLibrary for CUDA-specific customization (NVIDIA#327)
- Disable tests that deadlock due to NVIDIA#317 (NVIDIA#356)
- FIX: Add type check for shape elements in DeviceNDArrayBase constructor (NVIDIA#352)
- Merge pull request NVIDIA#265 from lakshayg/fp16-support
- Add performance warning
- Fix tests
- Create and register low++ bindings for float16
- Create typing/target registries for float16
- Replace Numbast generated lower_casts
- Replace Numbast generated operators
- Alias __half to numba.core.types.float16
- Generate fp16 bindings using numbast
- Remove existing fp16 logic
- [REVIEW][NFC] Vendor in the utils and cgutils to allow for future CUDA-specific refactoring and changes (NVIDIA#340)
- [RFC,TESTING] Add filecheck test infrastructure (NVIDIA#342)
- Migrate test infra to pytest (NVIDIA#347)
- Add .vscode to gitignore (NVIDIA#344)
- [NFC] Add dev dependencies to project config (NVIDIA#341)
- Allow Inspection of Link-Time Optimized PTX (NVIDIA#326)
- [NFC] Vendor in DIBuilder used by CUDADIBuilder (NVIDIA#332)
- Add guidance on setting up pre-commit (NVIDIA#339)
- [Refactor][NFC] Vendor in MinimalCallConv (NVIDIA#333)
- [Refactor][NFC] Vendor in BaseCallConv (NVIDIA#324)
- [REVIEW] Vendor in CompileResult as CUDACompileResult to allow for future CUDA-specific customizations (NVIDIA#325)
@gmarkall gmarkall mentioned this pull request Jul 31, 2025
gmarkall added a commit that referenced this pull request Jul 31, 2025
- [NFC] FileCheck tests check all overloads (#354)
- [REVIEW][NFC] Vendor in serialize to allow for future CUDA-specific
refactoring and changes (#349)
- Vendor in usecases used in testing (#359)
- Add thirdparty tests of numba extensions (#348)
- Support running tests in parallel (#350)
- Add more debuginfo tests (#358)
- [REVIEW][NFC] Vendor in the Cache, CacheImpl used by CUDACache and
CUDACacheImpl to allow for future CUDA-specific refactoring and changes
(#334)
- [NFC] Vendor in Dispatcher as CUDADispatcher to allow for future
CUDA-specific customization (#338)
- Vendor in BaseNativeLowering and BaseLower for CUDA-specific
customizations (#329)
- [REVIEW] Vendor in the CompilerBase used by CUDACompiler to allow for
future CUDA-specific refactoring and changes (#322)
- Vendor in Codegen and CodeLibrary for CUDA-specific customization
(#327)
- Disable tests that deadlock due to #317 (#356)
- FIX: Add type check for shape elements in DeviceNDArrayBase
constructor (#352)
- Merge pull request #265 from lakshayg/fp16-support
- Add performance warning
- Fix tests
- Create and register low++ bindings for float16
- Create typing/target registries for float16
- Replace Numbast generated lower_casts
- Replace Numbast generated operators
- Alias __half to numba.core.types.float16
- Generate fp16 bindings using numbast
- Remove existing fp16 logic
- [REVIEW][NFC] Vendor in the utils and cgutils to allow for future
CUDA-specific refactoring and changes (#340)
- [RFC,TESTING] Add filecheck test infrastructure (#342)
- Migrate test infra to pytest (#347)
- Add .vscode to gitignore (#344)
- [NFC] Add dev dependencies to project config (#341)
- Allow Inspection of Link-Time Optimized PTX (#326)
- [NFC] Vendor in DIBuilder used by CUDADIBuilder (#332)
- Add guidance on setting up pre-commit (#339)
- [Refactor][NFC] Vendor in MinimalCallConv (#333)
- [Refactor][NFC] Vendor in BaseCallConv (#324)
- [REVIEW] Vendor in CompileResult as CUDACompileResult to allow for
future CUDA-specific customizations (#325)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants