Skip to content
Open
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
acce8d1
feat: add shared lib
simondanielsson Oct 13, 2026
99faf7e
Merge upstream/main into mono-library
simondanielsson Oct 13, 2026
53f595a
feat: port dsv41
simondanielsson Oct 13, 2026
88e92df
fix: remove unused envvars
simondanielsson Oct 13, 2026
7471e2a
fix: rename Packed to LaunchState
simondanielsson Oct 13, 2026
967ddd4
fix: my pr comments
simondanielsson Oct 13, 2026
549aa94
fix: rename pack->launch_steate and repack->reload_weights
simondanielsson Oct 13, 2026
b728e0a
fix: improve type annotations
simondanielsson Oct 13, 2026
78554c8
fix: rename
simondanielsson Oct 13, 2026
8f13e97
fix: rename to runtime
simondanielsson Oct 13, 2026
cbf4a56
fix: simplify
simondanielsson Oct 13, 2026
01dd055
fix: trim morre
simondanielsson Oct 13, 2026
d311c5e
chore: rename the shared layer kernel
simondanielsson Oct 13, 2026
4f9b3c4
fix: cleanup non-crucial code
simondanielsson Oct 13, 2026
fdecc85
fix: remove step_health
simondanielsson Oct 13, 2026
4f36839
fix: remove account/drain
simondanielsson Oct 13, 2026
524a46e
chore: remove reload_weights
simondanielsson Oct 13, 2026
aafcbd8
cleanup: remove monostep
simondanielsson Oct 13, 2026
2b1b190
chore: cleanup docstrings
simondanielsson Oct 13, 2026
0f474eb
fix: rename bind->refuse-caches
simondanielsson Oct 13, 2026
0681c31
chore: move refuse_caches
simondanielsson Oct 13, 2026
b97d5b6
chore: fix
simondanielsson Oct 13, 2026
7cf9683
fix: remove all duplicate functionality
simondanielsson Oct 13, 2026
14fdc8f
fix: reference kernel
simondanielsson Oct 14, 2026
5c54b69
fix: delete monocontext
simondanielsson Oct 14, 2026
43eb5e4
feat: parametrize the runtime on layerkernel
simondanielsson Oct 14, 2026
af9947e
fix: cleanup the runtime
simondanielsson Oct 14, 2026
255886a
fix: add layer indices to build
simondanielsson Oct 14, 2026
ee15046
return the selected monospec
simondanielsson Oct 14, 2026
d0aecb7
fix: call build() once per layer, andnot per layer*width
simondanielsson Oct 14, 2026
eb05ec8
parameterize the runtime also by launch state type
simondanielsson Oct 14, 2026
1bd3fd8
chore: ccleanup docstrings
simondanielsson Oct 14, 2026
06914f2
refactor: convert the monoruntime to one per model instead of one per…
simondanielsson Oct 15, 2026
14e468c
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 15, 2026
e7c2d3b
fix: remove lazy import of the spec
simondanielsson Oct 15, 2026
2b683ce
fix: move the layer loop to the monokernel itself
simondanielsson Oct 15, 2026
6b20e1e
fix: rename from 'mono' to 'SpecializedDecode'
simondanielsson Oct 15, 2026
9892ef0
fix: remove redundant ffn/whole layer distinction in the abstraction
simondanielsson Oct 15, 2026
9d4467d
chore: rename modelkernel to decodeimpl
simondanielsson Oct 15, 2026
2db600e
fix: remove the kernel_layesr check
simondanielsson Oct 15, 2026
09b5ce2
remove already made checks from skip_step
simondanielsson Oct 15, 2026
9eb416a
chore: cleanup
simondanielsson Oct 15, 2026
103bff2
chore: cleanup more
simondanielsson Oct 15, 2026
91228ba
fix: remove generic from the runtime
simondanielsson Oct 16, 2026
b3c8448
fix: remove last_reason attribute
simondanielsson Oct 16, 2026
5865b06
chore: rename runtime to dispatch
simondanielsson Oct 16, 2026
4bd6edf
feat: add --specialized-decode and deprecate --monokernel
simondanielsson Oct 16, 2026
9a80c3a
fix: add bind_caches hook
simondanielsson Oct 16, 2026
eb9e9e3
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 16, 2026
5bbeea4
fix: remove the common code tests for now
simondanielsson Oct 16, 2026
6b3d53e
feat: refactor kimi-k3 on nvidia
simondanielsson Oct 16, 2026
8256f68
fix: add generic param to the dsv41 implementation
simondanielsson Oct 16, 2026
36fecea
test: add unit tests
simondanielsson Oct 16, 2026
781963e
chore: remove comment
simondanielsson Oct 16, 2026
90a01c6
fix: finalize dsv41 weights after loading
simondanielsson Oct 16, 2026
0bc115f
fix: only create specializeddecode in global process_weights_after_lo…
simondanielsson Oct 16, 2026
f745d67
chore: cleanup docstrings
simondanielsson Oct 16, 2026
4cf46c8
fix: don't require automatic jit
simondanielsson Oct 16, 2026
c03165a
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 16, 2026
2b4eaee
fix: update directory structure
simondanielsson Oct 16, 2026
0d7f3e7
revert: move back common code to dsv41 dir
simondanielsson Oct 18, 2026
a45d50d
feat: allow kernel padding and sseparate width from kernel_width
simondanielsson Oct 18, 2026
cea9c9e
chore: resutrcture files for dsv41 to follow kimi
simondanielsson Oct 18, 2026
b0387ca
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 19, 2026
307e2e7
feat: port dspark monokernel
simondanielsson Oct 19, 2026
39502bc
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 19, 2026
747a96d
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 20, 2026
d667880
revert: rename files
simondanielsson Oct 20, 2026
f7fd7fe
chore: revert pure foramtting changes
simondanielsson Oct 20, 2026
84f458a
fix: failing tests after gfx942 merge
simondanielsson Oct 20, 2026
3284a1f
chore: revert redundant docstring changes
simondanielsson Oct 20, 2026
4adf124
fix: old import in test
simondanielsson Oct 20, 2026
8579703
fix: update the recipe
simondanielsson Oct 20, 2026
c927890
fix: bug in launching gfx942 mono
simondanielsson Oct 20, 2026
3765431
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 21, 2026
f96cb00
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 21, 2026
fa8c3dd
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 21, 2026
fb577dc
fix: things broken for minimax after this refactor
simondanielsson Oct 21, 2026
adbcbab
fix: ddrafter width bug
simondanielsson Oct 21, 2026
52cd25a
feat: add --no-monokernel
simondanielsson Oct 22, 2026
f020586
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 22, 2026
b62a69d
revert: all nvidia changes
simondanielsson Oct 22, 2026
73aaead
fix: mentions of monokernel in minimax
simondanielsson Oct 22, 2026
f9e8d8f
fix: tp_agree imports
simondanielsson Oct 22, 2026
b6ae90b
fix: revert monokernel rename and add '--specialized-decoded monokern…
simondanielsson Oct 22, 2026
3f657f2
fix: add kv cache stride assert
simondanielsson Oct 23, 2026
f3a851e
fix: failing tests
simondanielsson Oct 23, 2026
abb5d9d
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 23, 2026
8dd0844
docs: add design doc
simondanielsson Oct 23, 2026
39047ad
chore: refine docs
simondanielsson Oct 23, 2026
83ed7ce
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 26, 2026
0aad75b
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 27, 2026
e6db995
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 27, 2026
4a5bef7
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 27, 2026
60e9f9b
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 28, 2026
261fa31
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 28, 2026
86b8af3
Merge branch 'main' into feat/monokernel-abstractions
simondanielsson Oct 28, 2026
39ce04f
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 29, 2026
4704c72
Merge remote-tracking branch 'refs/remotes/upstream/main' into mono-l…
simondanielsson Oct 29, 2026
94e5522
Merge branch 'feat/monokernel-abstractions' of github.com:simondaniel…
simondanielsson Oct 29, 2026
b426bf7
fix: remove --specialized-decode option without specying variant or auto
simondanielsson Oct 29, 2026
d3a991b
Merge remote-tracking branch 'upstream/main' into mono-library
simondanielsson Oct 30, 2026
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
13 changes: 8 additions & 5 deletions .buildkite/test_areas/models_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ steps:
- tests/models/test_deepseek_v41_pipeline.py
- tests/models/transformers/test_layer_registry_e2e.py
- tests/models/test_deepseek_v41_replay_start.py
- tests/models/common/specialized_decode/
- tests/models/test_deepseek_v4_vl_stream_weights.py
- tests/models/test_muse_spark_rocm_loading.py
commands:
- pytest -v -s models/test_terratorch.py models/transformers/test_backend.py models/test_registry.py models/test_deepseek_v4_vl_rocm.py models/transformers/test_layer_registry_e2e.py models/test_deepseek_v41_replay_start.py models/test_deepseek_v41_decoder_replay_layers.py models/test_deepseek_v41_replay_batch.py models/test_deepseek_v41_pcp.py models/test_deepseek_v41_pipeline.py models/test_deepseek_v4_vl_stream_weights.py models/test_muse_spark_rocm_loading.py
- pytest -v -s models/test_terratorch.py models/transformers/test_backend.py models/test_registry.py models/test_deepseek_v4_vl_rocm.py models/transformers/test_layer_registry_e2e.py models/test_deepseek_v41_replay_start.py models/test_deepseek_v41_decoder_replay_layers.py models/test_deepseek_v41_replay_batch.py models/test_deepseek_v41_pcp.py models/test_deepseek_v41_pipeline.py models/test_deepseek_v4_vl_stream_weights.py models/test_muse_spark_rocm_loading.py models/common/specialized_decode
mirror:
amd:
label: ":amd: (MI355) Basic Models (Other)"
Expand All @@ -101,17 +102,19 @@ steps:
- tests/models/test_deepseek_v4_dspark_rocm.py
- tests/models/test_deepseek_v4_rocm_wo_a.py
- tests/models/test_deepseek_v4_rocm_compressor_gemm_fusion.py
- tests/models/test_dsv41_mono_decode.py
- tests/models/test_dsv41_specialized_decode.py
- tests/models/test_muse_spark_rocm_loading.py
- tests/models/test_deepseek_v4_vl_stream_weights.py
- tests/models/hy_v4/test_triton_ihc.py
- vllm/models/common/specialized_decode/
- tests/models/common/specialized_decode/
commands:
- pytest -v -s models/test_terratorch.py models/transformers/test_backend.py models/test_registry.py models/test_deepseek_v4_vl_rocm.py models/transformers/test_layer_registry_e2e.py models/test_deepseek_v41_replay_start.py models/test_deepseek_v41_decoder_replay_layers.py models/test_deepseek_v41_replay_batch.py models/test_deepseek_v41_amd_replay_forward.py models/test_deepseek_v4_dspark_rocm.py models/test_deepseek_v4_rocm_wo_a.py models/test_deepseek_v4_rocm_compressor_gemm_fusion.py models/test_dsv41_mono_decode.py models/test_muse_spark_rocm_loading.py models/test_deepseek_v4_vl_stream_weights.py
- pytest -v -s models/test_terratorch.py models/transformers/test_backend.py models/test_registry.py models/test_deepseek_v4_vl_rocm.py models/transformers/test_layer_registry_e2e.py models/test_deepseek_v41_replay_start.py models/test_deepseek_v41_decoder_replay_layers.py models/test_deepseek_v41_replay_batch.py models/test_deepseek_v41_amd_replay_forward.py models/test_deepseek_v4_dspark_rocm.py models/test_deepseek_v4_rocm_wo_a.py models/test_deepseek_v4_rocm_compressor_gemm_fusion.py models/test_dsv41_specialized_decode.py models/test_muse_spark_rocm_loading.py models/test_deepseek_v4_vl_stream_weights.py models/common/specialized_decode
- VLLM_ROCM_USE_AITER=1 pytest -v -s models/test_hyv4_rocm.py -m 'not distributed'
- pytest -v -s models/hy_v4/test_triton_ihc.py

- label: ":amd: (MI355) MiniMax M3 MonoKernel"
key: minimax-m3-monokernel-mi355
- label: ":amd: (MI355) MiniMax M3 Specialized Decode"
key: minimax-m3-specialized-decode-mi355
dind: false
timeout_in_minutes: 20
device: mi355_4
Expand Down
49 changes: 49 additions & 0 deletions tests/engine/test_arg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,55 @@ def test_ir_op_priority():
).create_engine_config()


@pytest.mark.parametrize(
("argv", "expected"),
[
([], None),
(["--specialized-decode"], "auto"),
(["--specialized-decode", "auto"], "auto"),
(["--specialized-decode", "monokernel"], "monokernel"),
(["--monokernel"], "monokernel"),
(["--no-monokernel"], None),
# The named backend wins over the shorthand, whatever the order.
(["--monokernel", "--specialized-decode", "auto"], "auto"),
(["--specialized-decode", "auto", "--monokernel"], "auto"),
],
)
def test_specialized_decode_cli(argv, expected):
"""``--monokernel`` is shorthand for ``--specialized-decode monokernel``,
and a bare ``--specialized-decode`` means ``auto``."""
parser = EngineArgs.add_cli_args(FlexibleArgumentParser())
args = EngineArgs.from_cli_args(parser.parse_args(argv))
config = args.create_engine_config()
assert config.kernel_config.specialized_decode == expected


def test_specialized_decode_rejects_an_unknown_backend():
parser = EngineArgs.add_cli_args(FlexibleArgumentParser())
with pytest.raises(SystemExit):
parser.parse_args(["--specialized-decode", "flydsl"])


@pytest.mark.parametrize(
("flags", "expected"),
[
({}, "monokernel"),
({"monokernel": False}, None),
({"specialized_decode": "auto"}, "auto"),
],
)
def test_specialized_decode_overrides_the_kernel_config(flags, expected):
"""``--no-monokernel`` turns off a specialized decode that a config file or
the Python API asked for, and absent flags leave it alone."""
from vllm.config.kernel import KernelConfig

config = EngineArgs(
kernel_config=KernelConfig(specialized_decode="monokernel"),
**flags,
).create_engine_config()
assert config.kernel_config.specialized_decode == expected


@pytest.mark.parametrize(
("input_json", "expected_json"),
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _set_gate(monkeypatch, on: bool):

# The model records --monokernel when it is created. These tests have no
# model, so they set the recorded flag themselves.
monkeypatch.setattr(ops, "_monokernel", on)
monkeypatch.setattr(ops, "_specialized_decode", on)
ops.enabled.cache_clear()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _set_gate(monkeypatch, on: bool):

# The model records --monokernel when it is created. These tests have no
# model, so they set the recorded flag themselves.
monkeypatch.setattr(ops, "_monokernel", on)
monkeypatch.setattr(ops, "_specialized_decode", on)
ops.enabled.cache_clear()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def gfx942_step(monkeypatch):
if paged_mqa_logits_module() is None:
pytest.skip("AITER's paged MQA logits module is not installed")
monkeypatch.setattr(rocm_aiter_ops, "_AITER_ENABLED", True)
monkeypatch.setattr(ops, "_monokernel", True)
monkeypatch.setattr(ops, "_specialized_decode", True)
ops.enabled.cache_clear()
if not is_workspace_manager_initialized():
init_workspace_manager(torch.device("cuda"))
Expand Down
2 changes: 1 addition & 1 deletion tests/kernels/models/amd/test_dsv41_gfx942_topk.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def gfx942_decode(monkeypatch):
the recorded flag itself."""
from vllm.models.deepseek_v41.amd import ops

monkeypatch.setattr(ops, "_monokernel", True)
monkeypatch.setattr(ops, "_specialized_decode", True)
ops.enabled.cache_clear()
yield
ops.enabled.cache_clear()
Expand Down
2 changes: 2 additions & 0 deletions tests/models/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
2 changes: 2 additions & 0 deletions tests/models/common/specialized_decode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
115 changes: 115 additions & 0 deletions tests/models/common/specialized_decode/kit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""What a model's ``DecodeSpec`` must satisfy."""

import subprocess
import sys
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Any

import pytest

from vllm.config.compilation import CUDAGraphMode
from vllm.forward_context import ForwardContext, override_forward_context
from vllm.models.common.specialized_decode.dispatch import SpecializedDecode
from vllm.models.common.specialized_decode.guards import select_decode_spec

KERNEL_BACKENDS = ("aiter", "flydsl")
"""Backends a spec module must not pull in of its own: it is imported at config
time, before anything has decided the spec can run. The package holding it is
the model's own hardware entry point, which already pulls its platform's
backend, so only what the spec module adds on top of that package counts."""


@contextmanager
def forward(config, mode: CUDAGraphMode, attn_metadata: Any) -> Iterator[None]:
"""One forward pass's context, as a runner would set it."""
context = ForwardContext(
no_compile_layers=config.compilation_config.static_forward_context,
attn_metadata=attn_metadata,
slot_mapping={},
cudagraph_runtime_mode=mode,
)
with override_forward_context(context):
yield


class DecodeConformance:
"""What every model's ``DecodeSpec`` must satisfy. Subclass it in the
model's test module and fill in the hooks below."""

specs: tuple[Any, ...]
"""The model's variants, as it passes them to ``select_decode_spec``."""

specs_module: str
"""Where ``specs`` is defined, for the import test to load on its own."""

def make_config(self, **overrides) -> Any:
"""A config this spec serves, with ``overrides`` applied on top."""
raise NotImplementedError

def make_model(self, config) -> Any:
"""A loaded model this spec serves, with its KV caches bound into
``config.compilation_config.static_forward_context``."""
raise NotImplementedError

def bad_caches(self, config, model) -> dict[str, Any]:
"""Caches that break at least two of ``refuse_caches``'s checks."""
raise NotImplementedError

@pytest.fixture
def config(self):
return self.make_config()

@pytest.fixture
def model(self, config):
return self.make_model(config)

@pytest.fixture
def decode(self, config, model):
return self.make_decode(config, model)

def make_decode(self, config, model=None, bind: bool = True):
"""This rank's ``SpecializedDecode``, built the way a model builds it:
the variant picked once by ``select_decode_spec``, then the dispatch
over the loaded model, then the caches the runner binds."""
model = self.make_model(config) if model is None else model
spec = select_decode_spec(config, self.specs)
assert spec is not None
decode = SpecializedDecode(model, config, spec)
if bind:
decode.bind_caches()
return decode

def test_spec_module_imports_no_kernel_backend(self):
module = self.specs_module
package = module.rpartition(".")[0]
source = (
"import sys; sys.path.insert(0, '.'); import importlib;"
f"importlib.import_module({package!r});"
"loaded = set(sys.modules);"
f"importlib.import_module({module!r});"
"print('\\n'.join(set(sys.modules) - loaded))"
)
loaded = subprocess.run(
[sys.executable, "-c", source],
capture_output=True,
text=True,
check=True,
).stdout.split()
pulled = {n.split(".")[0] for n in loaded} & set(KERNEL_BACKENDS)
assert not pulled, f"{module} imports {sorted(pulled)}"

def test_refuse_caches_reports_every_reason(self, config, model, decode):
reasons = decode.spec.refuse_caches(
decode.vllm_config, decode.kernel, self.bad_caches(config, model)
)
assert len(reasons) >= 2, reasons

def test_build_does_not_move_weights(self, config):
model = self.make_model(config)
before = {n: p.data_ptr() for n, p in model.named_parameters()}
self.make_decode(config, model)
after = {n: p.data_ptr() for n, p in model.named_parameters()}
assert before == after
Loading
Loading