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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ if(VLLM_GPU_LANG STREQUAL "CUDA" OR VLLM_GPU_LANG STREQUAL "HIP")
"csrc/libtorch_stable/cuda_view.cu"
"csrc/libtorch_stable/cuda_utils_kernels.cu"
"csrc/libtorch_stable/activation_kernels.cu"
"csrc/libtorch_stable/ngram_embedding_kernels.cu"
"csrc/libtorch_stable/vocab_parallel_embedding_kernels.cu"
"csrc/libtorch_stable/quantization/activation_kernels.cu"
"csrc/libtorch_stable/quantization/w8a8/int8/scaled_quant.cu"
Expand Down
96 changes: 0 additions & 96 deletions csrc/libtorch_stable/ngram_embedding_kernels.cu

This file was deleted.

9 changes: 0 additions & 9 deletions csrc/libtorch_stable/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,3 @@ void vocab_parallel_embedding(
const torch::stable::Tensor& weight, int64_t org_vocab_start_index,
int64_t org_vocab_end_index, int64_t num_org_vocab_padding,
int64_t added_vocab_start_index, int64_t added_vocab_end_index);

// LongCat n-gram embedding index kernel (see ngram_embedding_kernels.cu).
void ngram_compute_n_gram_ids(
int64_t ne_n, int64_t ne_k, torch::stable::Tensor& ne_weights,
torch::stable::Tensor& ne_mods,
torch::stable::Tensor& exclusive_ne_embedder_size_sums,
torch::stable::Tensor& exclusive_req_len_sums,
torch::stable::Tensor& ne_token_table, torch::stable::Tensor& row_indices,
torch::stable::Tensor& column_starts, torch::stable::Tensor& n_gram_ids);
11 changes: 0 additions & 11 deletions csrc/libtorch_stable/torch_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,6 @@ STABLE_TORCH_LIBRARY_FRAGMENT(_C, ops) {
"Tensor? cu_chunk_seqlen,"
"Tensor? last_chunk_indices) -> ()");

// LongCat n-gram embedding index kernel. All tensor args are marked mutable
// to match the (non-const) stable-Tensor& C++ signature; only ne_token_table
// and n_gram_ids are actually written in place.
// Fused vocab-parallel embedding: gather the rows this rank owns and write
// zeros for the rest, so the following all-reduce reconstructs the full
// embedding.
Expand All @@ -746,17 +743,9 @@ STABLE_TORCH_LIBRARY_FRAGMENT(_C, ops) {
"int org_vocab_start_index, int org_vocab_end_index, "
"int num_org_vocab_padding, int added_vocab_start_index, "
"int added_vocab_end_index) -> ()");
ops.def(
"ngram_compute_n_gram_ids(int ne_n, int ne_k, Tensor(a!) ne_weights, "
"Tensor(b!) ne_mods, Tensor(c!) exclusive_ne_embedder_size_sums, "
"Tensor(d!) exclusive_req_len_sums, Tensor(e!) ne_token_table, "
"Tensor(f!) row_indices, Tensor(g!) column_starts, "
"Tensor(h!) n_gram_ids) -> ()");
}

STABLE_TORCH_LIBRARY_IMPL(_C, CUDA, ops) {
// LongCat n-gram embedding index kernel.
ops.impl("ngram_compute_n_gram_ids", TORCH_BOX(&ngram_compute_n_gram_ids));
ops.impl("vocab_parallel_embedding", TORCH_BOX(&vocab_parallel_embedding));

// Per-token group quantization
Expand Down
5 changes: 4 additions & 1 deletion docs/models/supported_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ th {
| `Lfm2ForCausalLM` | LFM2 | `LiquidAI/LFM2-1.2B`, `LiquidAI/LFM2-700M`, `LiquidAI/LFM2-350M`, etc. | ✅︎ | ✅︎ |
| `Lfm2MoeForCausalLM` | LFM2MoE | `LiquidAI/LFM2-8B-A1B-preview`, etc. | ✅︎ | ✅︎ |
| `LlamaForCausalLM` | Llama 3.1, Llama 3, Llama 2, LLaMA, Yi | `meta-llama/Meta-Llama-3.1-405B-Instruct`, `meta-llama/Meta-Llama-3.1-70B`, `meta-llama/Meta-Llama-3-70B-Instruct`, `meta-llama/Llama-2-70b-hf`, `01-ai/Yi-34B`, etc. | ✅︎ | ✅︎ |
| `LongcatFlashForCausalLM` | LongCat-Flash | `meituan-longcat/LongCat-Flash-Chat`, `meituan-longcat/LongCat-Flash-Chat-FP8` | ✅︎ | ✅︎ |
| `MambaForCausalLM` | Mamba | `state-spaces/mamba-130m-hf`, `state-spaces/mamba-790m-hf`, `state-spaces/mamba-2.8b-hf`, etc. | | ✅︎ |
| `Mamba2ForCausalLM` | Mamba2 | `mistralai/Mamba-Codestral-7B-v0.1`, etc. | | ✅︎ |
| `MellumForCausalLM` | Mellum 2 | `JetBrains/Mellum2-12B-A2.5B-Base`, etc. | | ✅︎ |
Expand Down Expand Up @@ -490,6 +489,8 @@ Some models are supported only via the [Transformers modeling backend](#transfor
| `GPTBigCodeForCausalLM` | StarCoder, SantaCoder, WizardCoder | `bigcode/starcoder`, `bigcode/gpt_bigcode-santacoder`, `WizardLM/WizardCoder-15B-V1.0`, etc. | ✅︎ | |
| `HunYuanDenseV1ForCausalLM` | Hunyuan Dense | `tencent/Hunyuan-7B-Instruct` | ✅︎ | ✅︎ |
| `HunYuanMoEV1ForCausalLM` | Hunyuan-A13B | `tencent/Hunyuan-A13B-Instruct`, `tencent/Hunyuan-A13B-Pretrain`, `tencent/Hunyuan-A13B-Instruct-FP8`, etc. | ✅︎ | ✅︎ |
| `LongcatFlashForCausalLM` | LongCat-Flash | `meituan-longcat/LongCat-Flash-Chat`, `meituan-longcat/LongCat-Flash-Chat-FP8` | ✅︎ | ✅︎ |
| `LongcatFlashNgramForCausalLM` | LongCat-Flash-Lite | `meituan-longcat/LongCat-Flash-Lite` | ✅︎ | ✅︎ |
| `NanbeigeForCausalLM` | Nanbeige4.2 | `Nanbeige/Nanbeige4.2-3B`, etc. | ✅︎ | ✅︎ |
| `OlmoForCausalLM` | OLMo | `allenai/OLMo-1B-hf`, `allenai/OLMo-7B-hf`, etc. | ✅︎ | ✅︎ |
| `Olmo2ForCausalLM` | OLMo2 | `allenai/OLMo-2-0425-1B`, etc. | ✅︎ | ✅︎ |
Expand All @@ -498,6 +499,8 @@ Some models are supported only via the [Transformers modeling backend](#transfor
| `Starcoder2ForCausalLM` | Starcoder2 | `bigcode/starcoder2-3b`, `bigcode/starcoder2-7b`, `bigcode/starcoder2-15b`, etc. | ✅︎ | ✅︎ |
| `VaultGemmaForCausalLM` | VaultGemma | `google/vaultgemma-1b` | ✅︎ | ✅︎ |

LongCat-Flash-Lite requires `--trust-remote-code` for its custom n-gram model.

!!! note
Currently, the ROCm version of vLLM supports Mistral and Mixtral only for context lengths up to 4096.

Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_model_arch_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"stepfun-ai/Step-3.5-Flash",
# Excluded: Not available online right now
# "FreedomIntelligence/openPangu-Ultra-MoE-718B-V1.1",
"meituan-longcat/LongCat-Flash-Chat",
}

BASE_MODELS_TO_TEST = [
Expand All @@ -51,6 +50,7 @@
"lmsys/gpt-oss-20b-bf16",
"deepseek-ai/DeepSeek-V3.2-Exp",
"meta-llama/Llama-4-Scout-17B-16E-Instruct",
"meituan-longcat/LongCat-Flash-Chat",
] + list(BASE_TRUST_REMOTE_CODE_MODELS)

# (target_model, draft_model, trust_remote_code)
Expand Down
9 changes: 3 additions & 6 deletions tests/models/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,13 @@ def check_available_online(
"meta-llama/Llama-4-Scout-17B-16E-Instruct",
),
"LongcatFlashForCausalLM": _HfExamplesInfo(
"meituan-longcat/LongCat-Flash-Chat", trust_remote_code=True
"meituan-longcat/LongCat-Flash-Chat",
min_transformers_version="5.15.0",
),
"LongcatFlashNgramForCausalLM": _HfExamplesInfo(
"meituan-longcat/LongCat-Flash-Lite",
trust_remote_code=True,
min_transformers_version="5.15.0",
# Shrink the ~62GB n-gram tables (ngram_vocab_size_ratio * vocab_size)
# so the dummy-weight init test fits in CI memory.
hf_overrides={"ngram_vocab_size_ratio": 1},
Expand Down Expand Up @@ -1795,11 +1797,6 @@ def check_available_online(
trust_remote_code=True,
is_available_online=False,
),
"LongCatFlashMTPModel": _HfExamplesInfo(
"meituan-longcat/LongCat-Flash-Chat",
trust_remote_code=True,
speculative_model="meituan-longcat/LongCat-Flash-Chat",
),
"MiMoMTPModel": _HfExamplesInfo(
"XiaomiMiMo/MiMo-7B-RL",
trust_remote_code=True,
Expand Down
28 changes: 28 additions & 0 deletions tests/models/transformers/fusers/test_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ def forward(self, hidden_states):
return logits, scores, index


class NestedRouter(nn.Module):
"""LongCat-style router with its projection under `classifier`."""

def __init__(self, num_experts=8, hidden=16, top_k=2):
super().__init__()
self.top_k = top_k
self.classifier = nn.Linear(hidden, num_experts, bias=False)
self.register_buffer("e_score_correction_bias", torch.zeros(num_experts))

def forward(self, hidden_states):
logits = F.linear(hidden_states.float(), self.classifier.weight.float())
scores = F.softmax(logits, dim=-1)
_, index = torch.topk(scores + self.e_score_correction_bias, self.top_k, dim=-1)
weights = scores.gather(1, index)
return weights.to(hidden_states.dtype), index


class BiasedRouter(TopKRouter):
"""A valid top-k router but not `weight`-only (extra `bias` param) -> declined."""

Expand Down Expand Up @@ -295,6 +312,17 @@ def test_moe_fuser_matches_correction_router():
assert fuser.scoring_func == "sigmoid"


def test_moe_fuser_matches_nested_router_projection():
with torch.device("meta"):
block = MoEBlock(NestedRouter)
fuser = MoEBlockFuser.match(block, "experts")
assert isinstance(fuser, MoEBlockFuser)
assert fuser.gate_name == "gate"
assert fuser.gate_linear_name == "classifier"
assert fuser.scoring_func == "softmax"
assert fuser.router_dtype == torch.float32


def test_moe_fuser_reads_router_dtype_from_the_gate():
"""A router that computes its logits in fp32 must keep routing in fp32 when
rebuilt, even though no config field names the dtype. The cast back to the
Expand Down
1 change: 0 additions & 1 deletion tests/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ def _supports_multimodal_for_mm_prefix() -> bool:
# from num_layers for its dual-attention layers).
if model_arch not in (
"LongcatFlashForCausalLM",
"LongCatFlashMTPModel",
"LongcatFlashNgramForCausalLM",
):
update_dict["num_hidden_layers"] = num_hidden_layers
Expand Down
29 changes: 29 additions & 0 deletions tests/transformers_utils/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
`BaseRenderer.get_eos_token_id`.
"""

import json
import math
from types import SimpleNamespace
from typing import cast
Expand All @@ -17,6 +18,7 @@
from vllm.tokenizers import get_tokenizer
from vllm.transformers_utils import config as config_module
from vllm.transformers_utils.config import (
get_config,
get_safetensors_params_metadata,
mrope_num_dims,
patch_legacy_rope_type,
Expand Down Expand Up @@ -125,6 +127,33 @@ def test_glm5_next_rejects_unimplemented_config_options(kwargs, option):
Glm5NextTextConfig(**kwargs)


def test_longcat_config_without_model_type_uses_builtin_transformers(tmp_path):
config_path = tmp_path / "config.json"
config_path.write_text(
json.dumps(
{
"architectures": ["LongcatFlashForCausalLM"],
"expert_ffn_hidden_size": 1024,
"num_hidden_layers": 56,
"num_layers": 14,
"auto_map": {
"AutoConfig": "configuration_longcat_flash.LongcatFlashConfig",
"AutoModel": "modeling_longcat_flash.LongcatFlashModel",
},
}
),
encoding="utf-8",
)

config = get_config(tmp_path, trust_remote_code=False)

assert type(config).__name__ == "LongcatFlashConfig"
assert config.model_type == "longcat_flash"
assert config.auto_map == {}
assert config.num_hidden_layers == 28
assert config.moe_intermediate_size == 1024


def test_get_llama3_eos_token():
model_name = "meta-llama/Llama-3.2-1B-Instruct"

Expand Down
31 changes: 0 additions & 31 deletions vllm/_custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,37 +295,6 @@ def vocab_parallel_embedding(
return out


# LongCat n-gram embedding index kernel (see csrc/.../ngram_embedding_kernels.cu).
def ngram_compute_n_gram_ids(
ne_n: int,
ne_k: int,
ne_weights: torch.Tensor,
ne_mods: torch.Tensor,
exclusive_ne_embedder_size_sums: torch.Tensor,
exclusive_req_len_sums: torch.Tensor,
ne_token_table: torch.Tensor,
row_indices: torch.Tensor,
column_starts: torch.Tensor,
n_gram_ids: torch.Tensor,
) -> None:
"""Compute concatenated (offset) n-gram ids for a ragged prefill batch.

Writes ``n_gram_ids`` of shape ``[token_num, (ne_n-1)*ne_k]``.
"""
torch.ops._C.ngram_compute_n_gram_ids(
ne_n,
ne_k,
ne_weights,
ne_mods,
exclusive_ne_embedder_size_sums,
exclusive_req_len_sums,
ne_token_table,
row_indices,
column_starts,
n_gram_ids,
)


def fused_add_rms_norm(
input: torch.Tensor,
residual: torch.Tensor,
Expand Down
8 changes: 0 additions & 8 deletions vllm/config/speculative.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"qwen3_next_mtp",
"qwen4_exp_mtp",
"qwen3_5_mtp",
"longcat_flash_mtp",
"bailing_hybrid_v3_mtp",
"minimax_m3_mtp",
"bailing_hybrid_mtp",
Expand Down Expand Up @@ -945,13 +944,6 @@ def hf_config_override(hf_config: PretrainedConfig) -> PretrainedConfig:
"architectures": [architecture],
}
)
if hf_config.model_type in ("longcat_flash", "longcat_flash_ngram"):
hf_config.model_type = "longcat_flash_mtp"
n_predict = getattr(hf_config, "num_nextn_predict_layers", 1)
hf_config.update(
{"n_predict": n_predict, "architectures": ["LongCatFlashMTPModel"]}
)

if hf_config.model_type in ("step3p5", "step3p7") or hf_config.architectures[
0
] in ("Step3p5ForCausalLM", "Step3p7ForConditionalGeneration"):
Expand Down
Loading
Loading