main
py 45 lines 1.17 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Inkling kernels (NVIDIA).
4
5 ``rmsnorm`` / ``sconv`` import eagerly. The SwiGLU kernels and the FA4
6 relative-attention wrapper are exposed lazily to keep this package's
7 import path lightweight.
8 """
9
10 from typing import TYPE_CHECKING
11
12 from .norm import add_rmsnorm, rmsnorm
13 from .sconv import fused_sconv
14
15 _LAZY_EXPORTS = {
16 "silu_and_mul_triton": "silu_and_mul",
17 "sink_silu_mul_epilogue": "silu_and_mul",
18 "_INKLING_FA4_REL_ATTENTION_KERNEL": "fa4_rel_attention",
19 }
20
21 if TYPE_CHECKING:
22 from .fa4_rel_attention import ( # noqa: F401
23 _INKLING_FA4_REL_ATTENTION_KERNEL,
24 )
25 from .silu_and_mul import ( # noqa: F401
26 silu_and_mul_triton,
27 sink_silu_mul_epilogue,
28 )
29
30 __all__ = [
31 "add_rmsnorm",
32 "rmsnorm",
33 "fused_sconv",
34 *sorted(_LAZY_EXPORTS),
35 ]
36
37
38 def __getattr__(name: str):
39 module = _LAZY_EXPORTS.get(name)
40 if module is not None:
41 import importlib
42
43 mod = importlib.import_module(f".{module}", __name__)
44 return getattr(mod, name)
45 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")