[Model] Remove BaiChuanForCausalLM and BaichuanForCausalLM (#46362)

Signed-off-by: Xianbao QIAN <xianbao.qian@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>

Tiezhen WANG committed Jun 24, 2026 at 16:13 UTC 4cd1a84c88895ed863d1e74ed413fcb159e53aec
10 files changed +2 -536
docs/models/hardware_supported_models/xpu.md
-2
@@ -27,14 +27,12 @@
27 | Qwen/QwQ-32B | QwenForCausalLM | ✅ | | |
28 | deepseek-ai/DeepSeek-V2-Lite | DeepSeekForCausalLM | ✅ | | |
29 | meta-llama/Llama-3.1-8B-Instruct | LlamaForCausalLM | ✅ | | |
30 -| baichuan-inc/Baichuan2-13B-Chat | BaichuanForCausalLM | ✅ | | |
30 | THUDM/GLM-4-9B-chat | GLMForCausalLM | ✅ | | |
31 | THUDM/CodeGeex4-All-9B | CodeGeexForCausalLM | ✅ | | |
32 | chuhac/TeleChat2-35B | LlamaForCausalLM (TeleChat2 based on Llama arch) | ✅ | | |
33 | 01-ai/Yi1.5-34B-Chat | YiForCausalLM | ✅ | | |
34 | THUDM/CodeGeex4-All-9B | CodeGeexForCausalLM | ✅ | | |
35 | deepseek-ai/DeepSeek-Coder-33B-base | DeepSeekCoderForCausalLM | ✅ | | |
37 -| baichuan-inc/Baichuan2-13B-Chat | BaichuanForCausalLM | ✅ | | |
36 | meta-llama/Llama-2-13b-chat-hf | LlamaForCausalLM | ✅ | | |
37 | THUDM/CodeGeex4-All-9B | CodeGeexForCausalLM | ✅ | | |
38 | Qwen/Qwen1.5-14B-Chat | QwenForCausalLM | ✅ | | |
docs/models/supported_models.md
-1
@@ -370,7 +370,6 @@ th {
370 | `ArceeForCausalLM` | Arcee (AFM) | `arcee-ai/AFM-4.5B-Base`, etc. | ✅︎ | ✅︎ |
371 | `ArcticForCausalLM` | Arctic | `Snowflake/snowflake-arctic-base`, `Snowflake/snowflake-arctic-instruct`, etc. | | ✅︎ |
372 | `AXK1ForCausalLM` | A.X-K1 | `skt/A.X-K1`, etc. | | ✅︎ |
373 -| `BaiChuanForCausalLM` | Baichuan2, Baichuan | `baichuan-inc/Baichuan2-13B-Chat`, `baichuan-inc/Baichuan-7B`, etc. | ✅︎ | ✅︎ |
373 | `BailingMoeForCausalLM` | Ling | `inclusionAI/Ling-lite-1.5`, `inclusionAI/Ling-plus`, etc. | ✅︎ | ✅︎ |
374 | `BailingMoeV2ForCausalLM` | Ling | `inclusionAI/Ling-mini-2.0`, etc. | ✅︎ | ✅︎ |
375 | `BailingMoeV2_5ForCausalLM` | Ling | `inclusionAI/Ling-2.5-1T`, `inclusionAI/Ring-2.5-1T` | | ✅︎ |
examples/template_baichuan.jinja deleted
-13
@@ -1,13 +0,0 @@
1 -{{ (messages|selectattr('role', 'equalto', 'system')|list|last).content|trim if (messages|selectattr('role', 'equalto', 'system')|list) else '' }}
2 -
3 -{%- for message in messages -%}
4 - {%- if message['role'] == 'user' -%}
5 - {{- '<reserved_106>' + message['content'] -}}
6 - {%- elif message['role'] == 'assistant' -%}
7 - {{- '<reserved_107>' + message['content'] -}}
8 - {%- endif -%}
9 -{%- endfor -%}
10 -
11 -{%- if add_generation_prompt and messages[-1]['role'] != 'assistant' -%}
12 - {{- '<reserved_107>' -}}
13 -{% endif %}
\ No newline at end of file
rust/src/chat/src/renderer/hf/format.rs
-1
@@ -361,7 +361,6 @@ mod tests {
361
362 expect![[r#"
363 template_alpaca.jinja => String
364 - template_baichuan.jinja => String
364 template_chatglm.jinja => String
365 template_chatglm2.jinja => String
366 template_chatml.jinja => String
rust/src/chat/tests/templates/vllm_examples/template_baichuan.jinja deleted
-13
@@ -1,13 +0,0 @@
1 -{{ (messages|selectattr('role', 'equalto', 'system')|list|last).content|trim if (messages|selectattr('role', 'equalto', 'system')|list) else '' }}
2 -
3 -{%- for message in messages -%}
4 - {%- if message['role'] == 'user' -%}
5 - {{- '<reserved_106>' + message['content'] -}}
6 - {%- elif message['role'] == 'assistant' -%}
7 - {{- '<reserved_107>' + message['content'] -}}
8 - {%- endif -%}
9 -{%- endfor -%}
10 -
11 -{%- if add_generation_prompt and messages[-1]['role'] != 'assistant' -%}
12 - {{- '<reserved_107>' -}}
13 -{% endif %}
\ No newline at end of file
tests/distributed/test_pipeline_parallel.py
-2
@@ -105,8 +105,6 @@ TEXT_GENERATION_MODELS = {
105 # Uses Llama
106 # "BAAI/AquilaChat-7B": PPTestSettings.fast(),
107 "Snowflake/snowflake-arctic-instruct": PPTestSettings.fast(load_format="dummy"),
108 - "baichuan-inc/Baichuan-7B": PPTestSettings.fast(),
109 - "baichuan-inc/Baichuan2-13B-Chat": PPTestSettings.fast(),
108 "bigscience/bloomz-1b1": PPTestSettings.fast(),
109 "zai-org/chatglm3-6b": PPTestSettings.fast(),
110 "CohereLabs/c4ai-command-r-v01": PPTestSettings.fast(load_format="dummy"),
tests/models/registry.py
-6
@@ -208,12 +208,6 @@ _TEXT_GENERATION_EXAMPLE_MODELS = {
208 "Snowflake/snowflake-arctic-instruct", trust_remote_code=True
209 ),
210 "AXK1ForCausalLM": _HfExamplesInfo("skt/A.X-K1", trust_remote_code=True),
211 - "BaiChuanForCausalLM": _HfExamplesInfo(
212 - "baichuan-inc/Baichuan-7B", trust_remote_code=True
213 - ),
214 - "BaichuanForCausalLM": _HfExamplesInfo(
215 - "baichuan-inc/Baichuan2-7B-chat", trust_remote_code=True
216 - ),
211 "BailingMoeForCausalLM": _HfExamplesInfo(
212 "inclusionAI/Ling-lite-1.5", trust_remote_code=True
213 ),
tests/renderers/test_hf.py
-1
@@ -482,7 +482,6 @@ def test_resolve_content_format_fallbacks(model, expected_format):
482 ("template_path", "expected_format"),
483 [
484 ("template_alpaca.jinja", "string"),
485 - ("template_baichuan.jinja", "string"),
485 ("template_chatglm.jinja", "string"),
486 ("template_chatglm2.jinja", "string"),
487 ("template_chatml.jinja", "string"),
vllm/model_executor/models/baichuan.py deleted
-493
@@ -1,493 +0,0 @@
1 -# SPDX-License-Identifier: Apache-2.0
2 -# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -
4 -# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
5 -#
6 -# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
7 -# and OPT implementations in this library. It has been modified from its
8 -# original forms to accommodate minor architectural differences compared
9 -# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
10 -#
11 -# Licensed under the Apache License, Version 2.0 (the "License");
12 -# you may not use this file except in compliance with the License.
13 -# You may obtain a copy of the License at
14 -#
15 -# http://www.apache.org/licenses/LICENSE-2.0
16 -#
17 -# Unless required by applicable law or agreed to in writing, software
18 -# distributed under the License is distributed on an "AS IS" BASIS,
19 -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 -# See the License for the specific language governing permissions and
21 -# limitations under the License.
22 -"""Inference-only BaiChuan model compatible with HuggingFace weights."""
23 -
24 -import math
25 -from collections.abc import Iterable
26 -from itertools import islice
27 -
28 -import torch
29 -from torch import nn
30 -from transformers import PretrainedConfig
31 -
32 -from vllm.compilation.decorators import support_torch_compile
33 -from vllm.config import CacheConfig, VllmConfig
34 -from vllm.distributed import (
35 - get_pp_group,
36 - get_tensor_model_parallel_rank,
37 - get_tensor_model_parallel_world_size,
38 -)
39 -from vllm.model_executor.layers.activation import SiluAndMul
40 -from vllm.model_executor.layers.attention import Attention
41 -from vllm.model_executor.layers.layernorm import RMSNorm
42 -from vllm.model_executor.layers.linear import (
43 - MergedColumnParallelLinear,
44 - QKVParallelLinear,
45 - RowParallelLinear,
46 -)
47 -from vllm.model_executor.layers.logits_processor import LogitsProcessor
48 -from vllm.model_executor.layers.quantization import QuantizationConfig
49 -from vllm.model_executor.layers.rotary_embedding import get_rope
50 -from vllm.model_executor.layers.vocab_parallel_embedding import (
51 - ParallelLMHead,
52 - VocabParallelEmbedding,
53 -)
54 -from vllm.model_executor.model_loader.weight_utils import (
55 - default_weight_loader,
56 - row_parallel_weight_loader,
57 -)
58 -from vllm.sequence import IntermediateTensors
59 -
60 -from .interfaces import SupportsLoRA, SupportsPP, SupportsQuant
61 -from .utils import (
62 - AutoWeightsLoader,
63 - is_pp_missing_parameter,
64 - make_empty_intermediate_tensors_factory,
65 - make_layers,
66 - maybe_prefix,
67 -)
68 -
69 -
70 -def _get_alibi_slopes(total_num_heads: int) -> torch.Tensor:
71 - closest_power_of_2 = 2 ** math.floor(math.log2(total_num_heads))
72 - base = torch.tensor(
73 - 2 ** (-(2 ** -(math.log2(closest_power_of_2) - 3))),
74 - dtype=torch.float32,
75 - )
76 - powers = torch.arange(1, 1 + closest_power_of_2, dtype=torch.int32)
77 - slopes = torch.pow(base, powers)
78 -
79 - if closest_power_of_2 != total_num_heads:
80 - extra_base = torch.tensor(
81 - 2 ** (-(2 ** -(math.log2(2 * closest_power_of_2) - 3))),
82 - dtype=torch.float32,
83 - )
84 - num_remaining_heads = min(
85 - closest_power_of_2, total_num_heads - closest_power_of_2
86 - )
87 - extra_powers = torch.arange(
88 - start=1, end=1 + 2 * num_remaining_heads, step=2, dtype=torch.int32
89 - )
90 - slopes = torch.cat([slopes, torch.pow(extra_base, extra_powers)], dim=0)
91 - return slopes
92 -
93 -
94 -class BaiChuanMLP(nn.Module):
95 - def __init__(
96 - self,
97 - hidden_size: int,
98 - intermediate_size: int,
99 - hidden_act: str,
100 - quant_config: QuantizationConfig | None = None,
101 - prefix: str = "",
102 - ):
103 - super().__init__()
104 - self.gate_up_proj = MergedColumnParallelLinear(
105 - hidden_size,
106 - [intermediate_size] * 2,
107 - bias=False,
108 - quant_config=quant_config,
109 - prefix=f"{prefix}.gate_up_proj",
110 - )
111 - self.down_proj = RowParallelLinear(
112 - intermediate_size,
113 - hidden_size,
114 - bias=False,
115 - quant_config=quant_config,
116 - prefix=f"{prefix}.down_proj",
117 - )
118 - if hidden_act != "silu":
119 - raise ValueError(
120 - f"Unsupported activation: {hidden_act}. Only silu is supported for now."
121 - )
122 - self.act_fn = SiluAndMul()
123 -
124 - def forward(self, x):
125 - gate_up, _ = self.gate_up_proj(x)
126 - x = self.act_fn(gate_up)
127 - x, _ = self.down_proj(x)
128 - return x
129 -
130 -
131 -class BaiChuanAttention(nn.Module):
132 - """Multi-headed attention from 'Attention Is All You Need' paper"""
133 -
134 - def __init__(
135 - self,
136 - hidden_size: int,
137 - num_heads: int,
138 - position_embedding: str,
139 - rope_parameters: dict,
140 - max_position_embeddings: int = 8192,
141 - cache_config: CacheConfig | None = None,
142 - quant_config: QuantizationConfig | None = None,
143 - prefix: str = "",
144 - ):
145 - super().__init__()
146 - self.hidden_size = hidden_size
147 - tensor_model_parallel_world_size = get_tensor_model_parallel_world_size()
148 - self.total_num_heads = num_heads
149 - assert self.total_num_heads % tensor_model_parallel_world_size == 0
150 - self.num_heads = self.total_num_heads // tensor_model_parallel_world_size
151 - self.head_dim = hidden_size // self.total_num_heads
152 - self.position_embedding = position_embedding
153 - self.max_position_embeddings = max_position_embeddings
154 -
155 - # pylint: disable=invalid-name
156 - self.W_pack = QKVParallelLinear(
157 - hidden_size,
158 - self.head_dim,
159 - self.total_num_heads,
160 - self.total_num_heads,
161 - bias=False,
162 - quant_config=quant_config,
163 - prefix=f"{prefix}.W_pack",
164 - )
165 - self.o_proj = RowParallelLinear(
166 - self.total_num_heads * self.head_dim,
167 - hidden_size,
168 - bias=False,
169 - quant_config=quant_config,
170 - prefix=f"{prefix}.o_proj",
171 - )
172 - # Create the alibi slopes and slice them.
173 - if self.position_embedding == "ALIBI":
174 - tp_rank = get_tensor_model_parallel_rank()
175 - head_start = tp_rank * self.num_heads
176 - head_end = (tp_rank + 1) * self.num_heads
177 - alibi_slopes = _get_alibi_slopes(self.total_num_heads)
178 - alibi_slopes = alibi_slopes[head_start:head_end].tolist()
179 -
180 - scaling = self.head_dim**-0.5
181 - self.attn = Attention(
182 - self.num_heads,
183 - self.head_dim,
184 - scaling,
185 - alibi_slopes=alibi_slopes,
186 - quant_config=quant_config,
187 - prefix=f"{prefix}.attn",
188 - )
189 - else:
190 - self.rotary_emb = get_rope(
191 - self.head_dim,
192 - max_position=self.max_position_embeddings,
193 - rope_parameters=rope_parameters,
194 - )
195 - self.scaling = self.head_dim**-0.5
196 - self.attn = Attention(
197 - self.num_heads,
198 - self.head_dim,
199 - self.scaling,
200 - cache_config=cache_config,
201 - quant_config=quant_config,
202 - prefix=f"{prefix}.attn",
203 - )
204 -
205 - def forward(
206 - self,
207 - positions: torch.Tensor,
208 - hidden_states: torch.Tensor,
209 - ) -> torch.Tensor:
210 - qkv, _ = self.W_pack(hidden_states)
211 - q, k, v = qkv.chunk(chunks=3, dim=-1)
212 - if self.position_embedding != "ALIBI":
213 - q, k = self.rotary_emb(positions, q, k)
214 - attn_output = self.attn(q, k, v)
215 - output, _ = self.o_proj(attn_output)
216 - return output
217 -
218 -
219 -class BaiChuanDecoderLayer(nn.Module):
220 - def __init__(
221 - self,
222 - config: PretrainedConfig,
223 - position_embedding: str,
224 - cache_config: CacheConfig | None = None,
225 - quant_config: QuantizationConfig | None = None,
226 - prefix: str = "",
227 - ):
228 - super().__init__()
229 - self.hidden_size = config.hidden_size
230 - max_position_embeddings = getattr(config, "max_position_embeddings", 8192)
231 - self.self_attn = BaiChuanAttention(
232 - hidden_size=self.hidden_size,
233 - num_heads=config.num_attention_heads,
234 - position_embedding=position_embedding,
235 - rope_parameters=getattr(config, "rope_parameters", None),
236 - max_position_embeddings=max_position_embeddings,
237 - cache_config=cache_config,
238 - quant_config=quant_config,
239 - prefix=f"{prefix}.self_attn",
240 - )
241 - self.mlp = BaiChuanMLP(
242 - hidden_size=self.hidden_size,
243 - intermediate_size=config.intermediate_size,
244 - hidden_act=config.hidden_act,
245 - quant_config=quant_config,
246 - prefix=f"{prefix}.mlp",
247 - )
248 - self.input_layernorm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
249 - self.post_attention_layernorm = RMSNorm(
250 - config.hidden_size, eps=config.rms_norm_eps
251 - )
252 -
253 - def forward(
254 - self,
255 - positions: torch.Tensor,
256 - hidden_states: torch.Tensor,
257 - residual: torch.Tensor | None,
258 - ) -> tuple[torch.Tensor, torch.Tensor]:
259 - # Self Attention
260 - if residual is None:
261 - residual = hidden_states
262 - hidden_states = self.input_layernorm(hidden_states)
263 - else:
264 - hidden_states, residual = self.input_layernorm(hidden_states, residual)
265 - hidden_states = self.self_attn(
266 - positions=positions,
267 - hidden_states=hidden_states,
268 - )
269 -
270 - # Fully Connected
271 - hidden_states, residual = self.post_attention_layernorm(hidden_states, residual)
272 - hidden_states = self.mlp(hidden_states)
273 - return hidden_states, residual
274 -
275 -
276 -@support_torch_compile
277 -class BaiChuanModel(nn.Module):
278 - def __init__(
279 - self,
280 - vllm_config: VllmConfig,
281 - prefix: str = "",
282 - position_embedding: str = "ROPE",
283 - ) -> None:
284 - super().__init__()
285 -
286 - config = vllm_config.model_config.hf_config
287 - cache_config = vllm_config.cache_config
288 - quant_config = vllm_config.quant_config
289 -
290 - self.config = config
291 - self.vocab_size = config.vocab_size
292 -
293 - self.embed_tokens = VocabParallelEmbedding(
294 - config.vocab_size,
295 - config.hidden_size,
296 - )
297 - self.start_layer, self.end_layer, self.layers = make_layers(
298 - config.num_hidden_layers,
299 - lambda prefix: BaiChuanDecoderLayer(
300 - config, position_embedding, cache_config, quant_config, prefix=prefix
301 - ),
302 - prefix=f"{prefix}.layers",
303 - )
304 - self.norm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
305 - self.make_empty_intermediate_tensors = make_empty_intermediate_tensors_factory(
306 - ["hidden_states", "residual"], config.hidden_size
307 - )
308 -
309 - def embed_input_ids(self, input_ids: torch.Tensor) -> torch.Tensor:
310 - return self.embed_tokens(input_ids)
311 -
312 - def forward(
313 - self,
314 - input_ids: torch.Tensor | None,
315 - positions: torch.Tensor,
316 - intermediate_tensors: IntermediateTensors | None,
317 - inputs_embeds: torch.Tensor | None = None,
318 - ) -> torch.Tensor | IntermediateTensors:
319 - if get_pp_group().is_first_rank:
320 - if inputs_embeds is not None:
321 - hidden_states = inputs_embeds
322 - else:
323 - hidden_states = self.embed_input_ids(input_ids)
324 - residual = None
325 - else:
326 - assert intermediate_tensors is not None
327 - hidden_states = intermediate_tensors["hidden_states"]
328 - residual = intermediate_tensors["residual"]
329 - for layer in islice(self.layers, self.start_layer, self.end_layer):
330 - hidden_states, residual = layer(
331 - positions,
332 - hidden_states,
333 - residual,
334 - )
335 - if not get_pp_group().is_last_rank:
336 - return IntermediateTensors(
337 - {
338 - "hidden_states": hidden_states,
339 - "residual": residual,
340 - }
341 - )
342 - hidden_states, _ = self.norm(hidden_states, residual)
343 - return hidden_states
344 -
345 - def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
346 - stacked_params_mapping = [
347 - # (param_name, shard_name, shard_id)
348 - ("gate_up_proj", "gate_proj", 0),
349 - ("gate_up_proj", "up_proj", 1),
350 - ]
351 - params_dict = dict(self.named_parameters())
352 - loaded_params: set[str] = set()
353 - for name, loaded_weight in weights:
354 - if "rotary_emb.inv_freq" in name:
355 - continue
356 -
357 - for param_name, weight_name, shard_id in stacked_params_mapping:
358 - if weight_name not in name:
359 - continue
360 - name = name.replace(weight_name, param_name)
361 - # Skip loading extra bias for GPTQ models.
362 - if name.endswith(".bias") and name not in params_dict:
363 - continue
364 - if is_pp_missing_parameter(name, self):
365 - continue
366 - param = params_dict[name]
367 - weight_loader = param.weight_loader
368 - weight_loader(param, loaded_weight, shard_id)
369 - break
370 - else:
371 - # Skip loading extra bias for GPTQ models.
372 - if name.endswith(".bias") and name not in params_dict:
373 - continue
374 - if is_pp_missing_parameter(name, self):
375 - continue
376 - param = params_dict[name]
377 - weight_loader = getattr(param, "weight_loader", default_weight_loader)
378 - weight_loader(param, loaded_weight)
379 - loaded_params.add(name)
380 - return loaded_params
381 -
382 -
383 -class BaiChuanBaseForCausalLM(nn.Module, SupportsLoRA, SupportsPP, SupportsQuant):
384 - packed_modules_mapping = {
385 - "W_pack": ["W_pack"],
386 - "gate_up_proj": [
387 - "gate_proj",
388 - "up_proj",
389 - ],
390 - }
391 -
392 - def __init__(
393 - self,
394 - *,
395 - vllm_config: VllmConfig,
396 - prefix: str = "",
397 - position_embedding: str = "ROPE",
398 - ):
399 - super().__init__()
400 - config = vllm_config.model_config.hf_config
401 - quant_config = vllm_config.quant_config
402 -
403 - self.config = config
404 -
405 - self.tp_size = get_tensor_model_parallel_world_size()
406 - self.quant_config = quant_config
407 - self.model = BaiChuanModel(
408 - vllm_config=vllm_config,
409 - prefix=prefix,
410 - position_embedding=position_embedding,
411 - )
412 - self.lm_head = ParallelLMHead(
413 - config.vocab_size,
414 - config.hidden_size,
415 - quant_config=quant_config,
416 - prefix=maybe_prefix(prefix, "lm_head"),
417 - )
418 - self.lm_head.weight.weight_loader = self.lm_head_weight_loader
419 - if self.config.tie_word_embeddings:
420 - self.lm_head.weight = self.model.embed_tokens.weight
421 - self.logits_processor = LogitsProcessor(config.vocab_size)
422 - self.make_empty_intermediate_tensors = (
423 - self.model.make_empty_intermediate_tensors
424 - )
425 -
426 - def embed_input_ids(self, input_ids: torch.Tensor) -> torch.Tensor:
427 - return self.model.embed_input_ids(input_ids)
428 -
429 - def forward(
430 - self,
431 - input_ids: torch.Tensor | None,
432 - positions: torch.Tensor,
433 - intermediate_tensors: IntermediateTensors | None = None,
434 - inputs_embeds: torch.Tensor | None = None,
435 - ) -> torch.Tensor | IntermediateTensors:
436 - hidden_states = self.model(
437 - input_ids, positions, intermediate_tensors, inputs_embeds
438 - )
439 - return hidden_states
440 -
441 - def compute_logits(
442 - self,
443 - hidden_states: torch.Tensor,
444 - ) -> torch.Tensor | None:
445 - logits = self.logits_processor(self.lm_head, hidden_states)
446 - return logits
447 -
448 - def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
449 - loader = AutoWeightsLoader(self)
450 - return loader.load_weights(weights)
451 -
452 - def lm_head_weight_loader(self, param: nn.Parameter, loaded_weight: torch.Tensor):
453 - # Unlike Baichuan, Baichuan2 normalizes the head weights.
454 - # Refer to:
455 - # https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat/blob/84603cde5ebffb6084e476cfaeceaf0b8b91fe54/modeling_baichuan.py#L508
456 - # Distinguish between Baichuan and Baichuan2 by checking the
457 - # vocab size. This is suggested by
458 - # https://github.com/vllm-project/vllm/pull/1022#discussion_r1325652704
459 - is_baichuan2 = self.config.vocab_size == 125696
460 - if is_baichuan2:
461 - loaded_weight = torch.nn.functional.normalize(loaded_weight)
462 - if self.tp_size > 1:
463 - row_parallel_weight_loader(param, loaded_weight)
464 - else:
465 - default_weight_loader(param, loaded_weight)
466 -
467 -
468 -class BaichuanForCausalLM(BaiChuanBaseForCausalLM):
469 - """Baichuan 13B and Baichuan2 7B/13B.
470 - NOTE: the class name has a lower case 'c'.
471 - """
472 -
473 - def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
474 - config = vllm_config.model_config.hf_config
475 - if config.hidden_size == 4096: # baichuan2 7b
476 - super().__init__(
477 - vllm_config=vllm_config, prefix=prefix, position_embedding="ROPE"
478 - )
479 - else: # baichuan 13b, baichuan2 13b
480 - super().__init__(
481 - vllm_config=vllm_config, prefix=prefix, position_embedding="ALIBI"
482 - )
483 -
484 -
485 -class BaiChuanForCausalLM(BaiChuanBaseForCausalLM):
486 - """Baichuan 7B.
487 - NOTE: the class name has an upper case 'C'.
488 - """
489 -
490 - def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
491 - super().__init__(
492 - vllm_config=vllm_config, prefix=prefix, position_embedding="ROPE"
493 - )
vllm/model_executor/models/registry.py
+2 -4
@@ -77,10 +77,6 @@ _TEXT_GENERATION_MODELS = {
77 "ArceeForCausalLM": ("arcee", "ArceeForCausalLM"),
78 "ArcticForCausalLM": ("arctic", "ArcticForCausalLM"),
79 "AXK1ForCausalLM": ("AXK1", "AXK1ForCausalLM"),
80 - # baichuan-7b, upper case 'C' in the class name
81 - "BaiChuanForCausalLM": ("baichuan", "BaiChuanForCausalLM"),
82 - # baichuan-13b, lower case 'c' in the class name
83 - "BaichuanForCausalLM": ("baichuan", "BaichuanForCausalLM"),
80 "BailingMoeForCausalLM": ("bailing_moe", "BailingMoeForCausalLM"),
81 "BailingMoeV2ForCausalLM": ("bailing_moe", "BailingMoeV2ForCausalLM"),
82 "BailingMoeV2_5ForCausalLM": ("bailing_moe_linear", "BailingMoeV25ForCausalLM"),
@@ -733,6 +729,8 @@ _PREVIOUSLY_SUPPORTED_MODELS = {
729 "MiniMaxText01ForCausalLM": "0.23.0",
730 "MiniMaxM1ForCausalLM": "0.23.0",
731 "MiniMaxVL01ForConditionalGeneration": "0.23.0",
732 + "BaiChuanForCausalLM": "0.23.0",
733 + "BaichuanForCausalLM": "0.23.0",
734 }
735
736 _OOT_SUPPORTED_MODELS = {