mjolnir-kernel 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mjolnir/__init__.py +76 -0
- mjolnir/backend.py +934 -0
- mjolnir/banner.py +127 -0
- mjolnir/calibrate.py +182 -0
- mjolnir/draftvocab.py +150 -0
- mjolnir/kvfp6.py +326 -0
- mjolnir/kvscales.py +162 -0
- mjolnir/lmhead.py +379 -0
- mjolnir/qpack.py +132 -0
- mjolnir/runner.py +754 -0
- mjolnir/t5_decode.py +2990 -0
- mjolnir_kernel-0.1.0.dist-info/METADATA +222 -0
- mjolnir_kernel-0.1.0.dist-info/RECORD +17 -0
- mjolnir_kernel-0.1.0.dist-info/WHEEL +4 -0
- mjolnir_kernel-0.1.0.dist-info/entry_points.txt +2 -0
- mjolnir_kernel-0.1.0.dist-info/licenses/LICENSE +202 -0
- mjolnir_kernel-0.1.0.dist-info/licenses/NOTICE +64 -0
mjolnir/__init__.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Mjolnir — fp8 paged decode attention for vLLM on Jetson AGX Thor (sm_110).
|
|
2
|
+
|
|
3
|
+
The kernel (codename **T5**, ``mjolnir.t5_decode``) is a CuTe-DSL tcgen05 +
|
|
4
|
+
TMEM + TMA decode kernel; ``mjolnir.backend`` wraps it as a vLLM attention
|
|
5
|
+
backend and ``mjolnir.runner`` holds the plan buffers, compile cache and KV
|
|
6
|
+
views.
|
|
7
|
+
|
|
8
|
+
``register()`` is the vLLM general-plugin entry point
|
|
9
|
+
(``vllm.general_plugins`` → ``mjolnir = "mjolnir:register"``). It points the
|
|
10
|
+
backend enum at ``mjolnir.backend.MjolnirAttentionBackend``:
|
|
11
|
+
|
|
12
|
+
* ``AttentionBackendEnum.MJOLNIR`` — present in the Mjolnir image (the
|
|
13
|
+
``thor-mjolnir-attention-backend`` patch adds the member), so
|
|
14
|
+
``vllm serve <model> --attention-backend MJOLNIR`` works;
|
|
15
|
+
* ``AttentionBackendEnum.CUSTOM`` — always, so a stock vLLM can use
|
|
16
|
+
``--attention-backend CUSTOM``.
|
|
17
|
+
|
|
18
|
+
The backend module (and with it vLLM's attention stack and the CUTLASS DSL)
|
|
19
|
+
is imported lazily, only when vLLM resolves the backend.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import os
|
|
25
|
+
|
|
26
|
+
__all__ = ["register", "BACKEND_PATH", "BACKEND_NAME", "__version__"]
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
|
|
29
|
+
BACKEND_NAME = "MJOLNIR"
|
|
30
|
+
BACKEND_PATH = "mjolnir.backend.MjolnirAttentionBackend"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _disabled() -> bool:
|
|
34
|
+
for name in ("MJOLNIR_ATTN_DISABLE", "THOR_T5_DISABLE"):
|
|
35
|
+
if os.environ.get(name, "").strip().lower() in ("1", "true", "yes"):
|
|
36
|
+
return True
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _registry():
|
|
41
|
+
try:
|
|
42
|
+
from vllm.v1.attention.backends.registry import AttentionBackendEnum, register_backend
|
|
43
|
+
except ImportError: # older vLLM layout
|
|
44
|
+
from vllm.attention.backends.registry import ( # type: ignore
|
|
45
|
+
AttentionBackendEnum,
|
|
46
|
+
register_backend,
|
|
47
|
+
)
|
|
48
|
+
return AttentionBackendEnum, register_backend
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def has_native_member() -> bool:
|
|
52
|
+
"""True when this vLLM has the ``MJOLNIR`` enum member (patched vLLM)."""
|
|
53
|
+
try:
|
|
54
|
+
enum, _ = _registry()
|
|
55
|
+
except ImportError:
|
|
56
|
+
return False
|
|
57
|
+
return BACKEND_NAME in enum.__members__
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def register() -> None:
|
|
61
|
+
if _disabled():
|
|
62
|
+
return
|
|
63
|
+
enum, register_backend = _registry()
|
|
64
|
+
if BACKEND_NAME in enum.__members__:
|
|
65
|
+
register_backend(enum[BACKEND_NAME], BACKEND_PATH)
|
|
66
|
+
register_backend(enum.CUSTOM, BACKEND_PATH)
|
|
67
|
+
# opt-in lm_head experiments (fp8 head, trimmed draft vocabulary)
|
|
68
|
+
if os.environ.get("MJOLNIR_LM_HEAD", "").strip() or os.environ.get("MJOLNIR_DRAFT_VOCAB", "").strip():
|
|
69
|
+
try:
|
|
70
|
+
from .lmhead import install_hooks
|
|
71
|
+
|
|
72
|
+
install_hooks()
|
|
73
|
+
except Exception as e: # noqa: BLE001 - never break vLLM startup
|
|
74
|
+
import logging
|
|
75
|
+
|
|
76
|
+
logging.getLogger("vllm.mjolnir").warning("Mjolnir lm_head hooks not installed: %r", e)
|