Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ repos:
hooks:
- id: ruff-check
args: [--fix, --show-fixes]
exclude: ^cuda_bindings/cuda/bindings/_internal/_fast_enum\.py$
exclude: (^cuda_bindings/cuda/bindings/_internal/_fast_enum\.py$)|(.*\.pyi$)
- id: ruff-format
exclude: .*\.pyi$

- repo: local
hooks:
Expand All @@ -42,6 +43,16 @@ repos:
language: system
files: '^.*/docs/source/.*\.md$'

- id: stubgen-pyx-cuda-core
name: Generate .pyi stubs for cuda_core
entry: stubgen-pyx cuda_core/cuda --continue-on-error --include-private
language: python
files: ^cuda_core/cuda/.*\.(pyx|pxd)$
pass_filenames: false
additional_dependencies:
- stubgen-pyx==0.2.6
- Cython==3.2.4

# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "3e8a8703264a2f4a69428a0aa4dcb512790b2c8c" # frozen: v6.0.0
Expand All @@ -56,7 +67,7 @@ repos:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: &gen_exclude '^(?:cuda_python/README\.md|cuda_bindings/cuda/bindings/.*\.in?|cuda_bindings/docs/source/module/.*\.rst?)$'
exclude: &gen_exclude '^(?:cuda_python/README\.md|cuda_bindings/cuda/bindings/.*\.in?|cuda_bindings/docs/source/module/.*\.rst?|.*\.pyi)$'
- id: mixed-line-ending
- id: trailing-whitespace
exclude: |
Expand All @@ -79,9 +90,18 @@ repos:
rev: 8e5c80792e2ec0c87804d8ef915bf35e2caea6da # frozen: v1.20.0
hooks:
- id: mypy
alias: mypy-pathfinder
name: mypy-pathfinder
files: ^cuda_pathfinder/cuda/.*\.py$ # Exclude tests directory
args: [--config-file=cuda_pathfinder/pyproject.toml]
- id: mypy
alias: mypy-cuda-core
name: mypy-cuda-core
files: ^cuda_core/cuda/.*\.(py|pyi)$
pass_filenames: false
args: [--config-file=cuda_core/pyproject.toml, cuda_core/cuda/core]
additional_dependencies:
- numpy

- repo: https://github.com/rhysd/actionlint
rev: "914e7df21a07ef503a81201c76d2b11c789d3fca" # frozen: v1.7.12
Expand Down
3 changes: 3 additions & 0 deletions .spdx-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ cuda_core/cuda/core/_include/dlpack.h
cuda_core/cuda/core/_include/aoti_shim.h
cuda_core/cuda/core/_include/aoti_shim.def

# Generated by stubgen-pyx; regenerated on every commit so a header would be lost
cuda_core/cuda/**/*.pyi

qa/ctk-next.drawio.svg
3 changes: 2 additions & 1 deletion cuda_core/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

recursive-include cuda/core *.pyx *.pxd *.pxi
recursive-include cuda/core *.pyx *.pxd *.pxi *.pyi
recursive-include cuda/core/_cpp *.cpp *.hpp
recursive-include cuda/core/_include *.h *.hpp
include cuda/core/py.typed
86 changes: 86 additions & 0 deletions cuda_core/cuda/core/_context.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_context.pyx

from __future__ import annotations

from collections.abc import Sequence
from dataclasses import dataclass

from cuda.core._device_resources import (DeviceResources, SMResource,
WorkqueueResource)
from cuda.core._stream import StreamOptions


class Context:
"""CUDA context wrapper.

Context objects represent CUDA contexts and cannot be instantiated directly.
Use Device or Stream APIs to obtain context objects.
"""

def close(self):
"""Release this context wrapper's underlying CUDA handles."""

def __init__(self, *args, **kwargs):
...

@property
def handle(self):
"""Return the underlying CUcontext handle."""

@property
def _handle(self):
...

@property
def is_green(self) -> bool:
"""True if this context was created from device resources."""

@property
def resources(self) -> DeviceResources:
"""Query the hardware resources provisioned for this context.

For green contexts, returns the resources this context was created
with (SM partition, workqueue config). For primary contexts, returns
the full device resources.

Raises :class:`RuntimeError` if the context has been closed.
"""

def create_stream(self, options: StreamOptions | None=None):
"""Create a new stream bound to this green context.

This method is only available on green contexts. For primary
contexts, use :meth:`Device.create_stream` instead.

Parameters
----------
options : :obj:`~_stream.StreamOptions`, optional
Customizable dataclass for stream creation options.

Returns
-------
:obj:`~_stream.Stream`
Newly created stream object.
"""

def __eq__(self, other):
...

def __hash__(self) -> int:
...

def __repr__(self) -> str:
...

@dataclass
class ContextOptions:
"""Options for context creation.

Attributes
----------
resources : :obj:`~cuda.core.typing.DeviceResourcesType`
Device resources used to create a green context.
"""
resources: DeviceResourcesType
__all__ = ['Context', 'ContextOptions']
DeviceResourcesType = Sequence[SMResource | WorkqueueResource]
Loading
Loading