Repository navigation
[Model] Remove native LongCat implementations - #53811
xianbaoqian wants to merge 2 commits into
Conversation
|
Documentation preview: https://vllm--53811.org.readthedocs.build/en/53811/ |
Route LongCat-Flash models through the Transformers backend and retain the compatibility handling needed by Chat and Lite. Assisted-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Xianbao QIAN <xianbao.qian@gmail.com>
41443b9 to
093ffab
Compare
|
I am concerned this will conflict with the WIP model PRs. Maybe wait for them to be merged first? |
#48553 Do you mean this one? |
|
No, I mean Qwen3.8-Next and GLM5.3-Next. They touch a lot of files |
|
This pull request has merge conflicts that must be resolved before it can be |
There was a problem hiding this comment.
Why is this necessary? This config is already registered in Transformers
| class LongCatModelArchConfigConvertor(ModelArchConfigConvertorBase): | ||
| def get_num_hidden_layers(self) -> int: | ||
| return self.hf_text_config.num_layers |
| hf_linear = ( | ||
| hf_gate.get_submodule(self.gate_linear_name) | ||
| if self.gate_linear_name | ||
| else hf_gate | ||
| ) |
There was a problem hiding this comment.
This could be unified to:
hf_gate_weight = hf_gate.get_submodule(self.gate_weight_location)In the case where the weight belongs directly to the gate self.gate_weight_location will be "" and get_submodule will just return hf_gate
There was a problem hiding this comment.
IMO the gate_linear_name -> gate_weight_location is playing a big part in clarity. I spent the first 5 minutes trying to figure out where another linear layer was coming from
| num_decoder_layers = ( | ||
| self.text_config.num_layers | ||
| if self.text_config.model_type | ||
| in ("longcat_flash", "longcat_flash_ngram") | ||
| else self.text_config.num_hidden_layers | ||
| ) |
There was a problem hiding this comment.
I would prefer to store the layers_name from pipeline_parallel rather than use model specific attributes like this
|
|
||
| # kv_lora_rank indicates that this is an MLA model | ||
| if getattr(text_config, "kv_lora_rank", None) is not None: | ||
| num_attn_module = ( |
There was a problem hiding this comment.
We can continue to use num_hidden_layers as the ground truth for "how many attention modules are in this model". Then we can infer this number from num_hidden_layers / len(layers)
Conflicts resolved:
- CMakeLists.txt, csrc/libtorch_stable/{ops.h,torch_bindings.cpp},
vllm/_custom_ops.py: keep main's vocab_parallel_embedding op, drop the
LongCat ngram_compute_n_gram_ids kernel along with its sources.
- docs/models/supported_models.md, vllm/model_executor/models/registry.py:
keep both sides (LongCat entries plus main's NanbeigeForCausalLM).
- tests/transformers_utils/test_config.py: keep both imports.
- vllm/model_executor/models/transformers/base.py: take main's side. Its
refactor keys attention by AttentionFuser.layer_index, which already
handles LongCat's two attention sublayers per decoder layer, so the
extract_layer_index(prefix, num_attn_module) workaround is superseded.
- vllm/model_executor/models/longcat_flash{,_mtp,_ngram}.py: stay deleted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
| ) -> tuple[str, torch.dtype | None, str] | None: | ||
| """Matches `topk(score(linear(x)))`, `score` being `softmax`/`sigmoid`. | ||
|
|
||
| Returns the scoring function and the dtype the router computes in.""" |
There was a problem hiding this comment.
This docstring should be updated
|
This pull request has merge conflicts that must be resolved before it can be |
Mutually agree with the LongCat team.
Depends on:
num_hidden_layerswhich might disagree withnum_layersmodel_typeso the Transformers code cannot load withAutoConfigPurpose
Remove the native LongCat-Flash Chat, Lite, and MTP implementations and route the supported causal-LM architectures through the Transformers modeling backend, following the migration pattern from #53608 and #53615.
This change:
LongcatFlashForCausalLMandLongcatFlashNgramForCausalLMtoTransformersMoEForCausalLM;model_typewithout executing its stale remote modeling code;--trust-remote-codefor its custom n-gram wrapper.Duplicate-work checks found no open PR for LongCat removal or migration to the Transformers backend. Open LongCat feature PRs are unrelated and the generic LongCat tool parser is intentionally retained.
This PR was prepared with AI assistance. The human submitter must review and understand every changed line before marking it ready for review.
Test Plan
.venv/bin/pre-commit run --from-ref origin/main --to-ref HEAD .venv/bin/python -m pytest tests/models/transformers/fusers/test_moe.py tests/transformers_utils/test_config.py -k 'moe_fuser or longcat' -q .venv/bin/python -m pytest tests/models/test_registry.py -k LongcatFlash -q .venv/bin/python -m pytest tests/config/test_model_arch_config.py -k LongCat -qBefore marking ready:
Test Result
TransformersMoEForCausalLM; meta-device construction matched all LongCat MoE and MLA blocks.--trust-remote-code.