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
16 changes: 13 additions & 3 deletions src/tilegym/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@
triton = None # type: ignore

# Import CUDA Tile C++ backend if available
tilecpp = None # type: ignore
if is_backend_available("tilecpp"):
from . import tilecpp
try:
from . import tilecpp
except (ImportError, RuntimeError):
import warnings

warnings.warn(
"tilecpp backend import failed, tilecpp operations will not be available"
)
tilecpp = None # type: ignore

# Re-export key interfaces
from .attn_interface import attention_sink_interface
Expand All @@ -54,7 +63,6 @@
__all__ = [
# Export all operations from ops module
# Backend implementations
"tilecpp",
# Interface modules
"attn_interface",
"moe_interface",
Expand All @@ -70,6 +78,8 @@
"fused_moe",
]

# Add cutile to exports only if successfully imported
# Add backend submodules to exports only if successfully imported
if cutile is not None:
__all__.append("cutile")
if tilecpp is not None:
__all__.append("tilecpp")
11 changes: 11 additions & 0 deletions tests/test_ops_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Tests for the tilegym.ops package init."""


def test_tilecpp_not_exported_when_unavailable():
"""If tilecpp is not imported, it must not appear in __all__."""
import tilegym.ops as ops

if not hasattr(ops, "tilecpp") or ops.tilecpp is None:
assert "tilecpp" not in ops.__all__


Loading