| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | """Inference-only Jurassic model.""" |
| 4 | |
| 5 | from collections.abc import Iterable |
| 6 | from itertools import islice |
| 7 | from typing import Any |
| 8 | |
| 9 | import torch |
| 10 | from torch import nn |
| 11 | |
| 12 | from vllm.compilation.decorators import support_torch_compile |
| 13 | from vllm.config import CacheConfig, VllmConfig |
| 14 | from vllm.distributed import ( |
| 15 | get_pp_group, |
| 16 | get_tensor_model_parallel_world_size, |
| 17 | ) |
| 18 | from vllm.logger import init_logger |
| 19 | from vllm.model_executor.layers.activation import SiluAndMul |
| 20 | from vllm.model_executor.layers.attention import Attention |
| 21 | from vllm.model_executor.layers.fused_moe import ( |
| 22 | FusedMoEFactory, |
| 23 | GateLinear, |
| 24 | ) |
| 25 | from vllm.model_executor.layers.layernorm import RMSNorm |
| 26 | from vllm.model_executor.layers.linear import ( |
| 27 | ColumnParallelLinear, |
| 28 | MergedColumnParallelLinear, |
| 29 | ReplicatedLinear, |
| 30 | RowParallelLinear, |
| 31 | ) |
| 32 | from vllm.model_executor.layers.logits_processor import LogitsProcessor |
| 33 | from vllm.model_executor.layers.quantization import QuantizationConfig |
| 34 | from vllm.model_executor.layers.rotary_embedding import get_rope |
| 35 | from vllm.model_executor.layers.vocab_parallel_embedding import ( |
| 36 | ParallelLMHead, |
| 37 | VocabParallelEmbedding, |
| 38 | ) |
| 39 | from vllm.model_executor.model_loader.weight_utils import default_weight_loader |
| 40 | from vllm.sequence import IntermediateTensors |
| 41 | from vllm.transformers_utils.configs.step3_vl import Step3TextConfig |
| 42 | |
| 43 | from .interfaces import SupportsPP |
| 44 | from .utils import ( |
| 45 | AutoWeightsLoader, |
| 46 | PPMissingLayer, |
| 47 | is_pp_missing_parameter, |
| 48 | make_empty_intermediate_tensors_factory, |
| 49 | make_layers, |
| 50 | maybe_prefix, |
| 51 | ) |
| 52 | |
| 53 | logger = init_logger(__name__) |
| 54 | |
| 55 | |
| 56 | class FusedMoEBlock(nn.Module): |
| 57 | def __init__( |
| 58 | self, |
| 59 | config: Step3TextConfig, |
| 60 | quant_config: QuantizationConfig | None = None, |
| 61 | prefix: str = "", |
| 62 | ): |
| 63 | super().__init__() |
| 64 | self.tp_size = get_tensor_model_parallel_world_size() |
| 65 | |
| 66 | if self.tp_size > config.moe_num_experts: |
| 67 | raise ValueError( |
| 68 | f"Tensor parallel size {self.tp_size} is greater than " |
| 69 | f"the number of experts {config.moe_num_experts}." |
| 70 | ) |
| 71 | |
| 72 | self.experts = FusedMoEFactory( |
| 73 | num_experts=config.moe_num_experts, |
| 74 | top_k=config.moe_top_k, |
| 75 | hidden_size=config.hidden_size, |
| 76 | intermediate_size=config.moe_intermediate_size, |
| 77 | renormalize=config.norm_expert_weight, |
| 78 | quant_config=quant_config, |
| 79 | prefix=f"{prefix}.experts", |
| 80 | ) |
| 81 | self.gate = GateLinear( |
| 82 | config.hidden_size, |
| 83 | config.moe_num_experts, |
| 84 | prefix=f"{prefix}.gate", |
| 85 | ) |
| 86 | |
| 87 | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: |
| 88 | orig_shape = hidden_states.shape |
| 89 | hidden_dim = hidden_states.shape[-1] |
| 90 | hidden_states = hidden_states.view(-1, hidden_dim) |
| 91 | |
| 92 | router_logits, _ = self.gate(hidden_states) |
| 93 | |
| 94 | final_hidden_states = self.experts( |
| 95 | hidden_states=hidden_states, router_logits=router_logits |
| 96 | ) |
| 97 | |
| 98 | return final_hidden_states.view(orig_shape) |
| 99 | |
| 100 | |
| 101 | class Step3TextMLP(nn.Module): |
| 102 | def __init__( |
| 103 | self, |
| 104 | hidden_size: int, |
| 105 | intermediate_size: int, |
| 106 | hidden_act: str, |
| 107 | quant_config: QuantizationConfig | None = None, |
| 108 | prefix: str = "", |
| 109 | ) -> None: |
| 110 | super().__init__() |
| 111 | self.gate_up_proj = MergedColumnParallelLinear( |
| 112 | hidden_size, |
| 113 | [intermediate_size] * 2, |
| 114 | bias=False, |
| 115 | quant_config=quant_config, |
| 116 | prefix=f"{prefix}.gate_up_proj", |
| 117 | ) |
| 118 | self.down_proj = RowParallelLinear( |
| 119 | intermediate_size, |
| 120 | hidden_size, |
| 121 | bias=False, |
| 122 | quant_config=quant_config, |
| 123 | prefix=f"{prefix}.down_proj", |
| 124 | ) |
| 125 | if hidden_act != "silu": |
| 126 | raise ValueError( |
| 127 | f"Unsupported activation: {hidden_act}. Only silu is supported for now." |
| 128 | ) |
| 129 | self.act_fn = SiluAndMul() |
| 130 | self.hidden_size = hidden_size |
| 131 | |
| 132 | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: |
| 133 | gate_up, _ = self.gate_up_proj(hidden_states) |
| 134 | intermediate_act = self.act_fn(gate_up) |
| 135 | output, _ = self.down_proj(intermediate_act) |
| 136 | return output |
| 137 | |
| 138 | |
| 139 | class Step3TextAttention(nn.Module): |
| 140 | def __init__( |
| 141 | self, |
| 142 | hidden_size: int, |
| 143 | num_heads: int, |
| 144 | num_kv_heads: int, |
| 145 | norm_eps: float, |
| 146 | rope_parameters: dict[str, Any], |
| 147 | share_q_dim: int | None = None, |
| 148 | max_position_embedding: int = 8192, |
| 149 | head_dim: int = 256, |
| 150 | cache_config: CacheConfig | None = None, |
| 151 | quant_config: QuantizationConfig | None = None, |
| 152 | prefix: str = "", |
| 153 | ): |
| 154 | super().__init__() |
| 155 | self.hidden_size = hidden_size |
| 156 | tp_size = get_tensor_model_parallel_world_size() |
| 157 | |
| 158 | self.total_num_heads = num_heads |
| 159 | assert self.total_num_heads % tp_size == 0 |
| 160 | self.num_heads = self.total_num_heads // tp_size |
| 161 | |
| 162 | if num_kv_heads != 1: |
| 163 | raise ValueError( |
| 164 | f"Step3TextAttention num_kv_heads must be 1, but got {num_kv_heads}." |
| 165 | ) |
| 166 | self.num_kv_heads = num_kv_heads |
| 167 | |
| 168 | self.head_dim = head_dim |
| 169 | self.kv_size = self.num_kv_heads * self.head_dim |
| 170 | self.q_size = share_q_dim if share_q_dim else self.head_dim |
| 171 | |
| 172 | self.qkv_proj = ReplicatedLinear( |
| 173 | hidden_size, |
| 174 | self.q_size + self.kv_size * 2, |
| 175 | bias=False, |
| 176 | quant_config=quant_config, |
| 177 | prefix=f"{prefix}.qkv_proj", |
| 178 | ) |
| 179 | |
| 180 | self.o_proj = RowParallelLinear( |
| 181 | self.total_num_heads * self.head_dim, |
| 182 | hidden_size, |
| 183 | bias=False, |
| 184 | quant_config=quant_config, |
| 185 | prefix=f"{prefix}.o_proj", |
| 186 | ) |
| 187 | self.inter_norm = RMSNorm(self.q_size, eps=norm_eps) |
| 188 | self.wq = ColumnParallelLinear( |
| 189 | self.q_size, |
| 190 | self.head_dim * self.total_num_heads, |
| 191 | bias=False, |
| 192 | quant_config=quant_config, |
| 193 | prefix=f"{prefix}.wq", |
| 194 | ) |
| 195 | self.rotary_emb = get_rope( |
| 196 | self.head_dim, |
| 197 | max_position=max_position_embedding, |
| 198 | rope_parameters=rope_parameters, |
| 199 | ) |
| 200 | scaling = self.head_dim**-0.5 |
| 201 | self.attn = Attention( |
| 202 | self.num_heads, |
| 203 | self.head_dim, |
| 204 | scaling, |
| 205 | self.num_kv_heads, |
| 206 | cache_config=cache_config, |
| 207 | prefix=f"{prefix}.attn", |
| 208 | ) |
| 209 | |
| 210 | def forward( |
| 211 | self, positions: torch.Tensor, hidden_states: torch.Tensor |
| 212 | ) -> torch.Tensor: |
| 213 | qkv, _ = self.qkv_proj(hidden_states) |
| 214 | q, k, v = qkv.split([self.q_size, self.kv_size, self.kv_size], dim=-1) |
| 215 | q = self.inter_norm(q) |
| 216 | q = self.wq(q)[0] |
| 217 | q, k = self.rotary_emb(positions, q, k) |
| 218 | attn_output = self.attn(q, k, v) |
| 219 | residual, _ = self.o_proj(attn_output) |
| 220 | return residual |
| 221 | |
| 222 | |
| 223 | class Step3TextDecoderLayer(nn.Module): |
| 224 | def __init__( |
| 225 | self, |
| 226 | config: Step3TextConfig, |
| 227 | cache_config: CacheConfig | None = None, |
| 228 | quant_config: QuantizationConfig | None = None, |
| 229 | prefix: str = "", |
| 230 | ) -> None: |
| 231 | super().__init__() |
| 232 | self.hidden_size = config.hidden_size |
| 233 | |
| 234 | self.self_attn = Step3TextAttention( |
| 235 | hidden_size=self.hidden_size, |
| 236 | num_heads=config.num_attention_heads, |
| 237 | num_kv_heads=1, |
| 238 | cache_config=cache_config, |
| 239 | quant_config=quant_config, |
| 240 | norm_eps=config.rms_norm_eps, |
| 241 | max_position_embedding=config.max_position_embedding, |
| 242 | head_dim=config.head_dim, |
| 243 | share_q_dim=config.share_q_dim, |
| 244 | rope_parameters=config.rope_parameters, |
| 245 | prefix=f"{prefix}.self_attn", |
| 246 | ) |
| 247 | |
| 248 | layer_idx = int(prefix.split("layers.")[1].split(".")[0]) |
| 249 | moe_layers_enum = getattr(config, "moe_layers_enum", None) |
| 250 | if moe_layers_enum is not None: |
| 251 | moe_layers_idx = [int(i) for i in moe_layers_enum.strip().split(",")] |
| 252 | else: |
| 253 | # Default to 1dense. |
| 254 | moe_layers_idx = [i for i in range(1, config.num_hidden_layers)] |
| 255 | |
| 256 | if layer_idx in moe_layers_idx: |
| 257 | self.moe = FusedMoEBlock( |
| 258 | config=config, quant_config=quant_config, prefix=f"{prefix}.moe" |
| 259 | ) |
| 260 | self.share_expert = Step3TextMLP( |
| 261 | hidden_size=self.hidden_size, |
| 262 | intermediate_size=config.share_expert_dim, |
| 263 | hidden_act="silu", |
| 264 | quant_config=quant_config, |
| 265 | prefix=f"{prefix}.share_expert", |
| 266 | ) |
| 267 | self.use_moe = True |
| 268 | else: |
| 269 | self.mlp = Step3TextMLP( |
| 270 | hidden_size=config.hidden_size, |
| 271 | intermediate_size=config.intermediate_size, |
| 272 | hidden_act="silu", |
| 273 | quant_config=quant_config, |
| 274 | prefix=f"{prefix}.mlp", |
| 275 | ) |
| 276 | self.use_moe = False |
| 277 | self.input_layernorm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps) |
| 278 | self.post_attention_layernorm = RMSNorm( |
| 279 | config.hidden_size, eps=config.rms_norm_eps |
| 280 | ) |
| 281 | |
| 282 | def forward( |
| 283 | self, |
| 284 | positions: torch.Tensor, |
| 285 | hidden_states: torch.Tensor, |
| 286 | residual: torch.Tensor | None, |
| 287 | ) -> tuple[torch.Tensor, torch.Tensor]: |
| 288 | if residual is None: |
| 289 | residual = hidden_states |
| 290 | hidden_states = self.input_layernorm(hidden_states) |
| 291 | else: |
| 292 | hidden_states, residual = self.input_layernorm(hidden_states, residual) |
| 293 | |
| 294 | hidden_states = self.self_attn( |
| 295 | positions=positions, |
| 296 | hidden_states=hidden_states, |
| 297 | ) |
| 298 | |
| 299 | hidden_states, residual = self.post_attention_layernorm(hidden_states, residual) |
| 300 | |
| 301 | if self.use_moe: |
| 302 | share_output = self.share_expert(hidden_states) |
| 303 | moe_output = self.moe(hidden_states) |
| 304 | hidden_states = share_output + moe_output |
| 305 | else: |
| 306 | hidden_states = self.mlp(hidden_states) |
| 307 | |
| 308 | return hidden_states, residual |
| 309 | |
| 310 | |
| 311 | @support_torch_compile |
| 312 | class Step3TextModel(nn.Module): |
| 313 | def __init__(self, vllm_config: VllmConfig, prefix: str = "") -> None: |
| 314 | super().__init__() |
| 315 | config = vllm_config.model_config.hf_config |
| 316 | cache_config = vllm_config.cache_config |
| 317 | quant_config = vllm_config.quant_config |
| 318 | self.vocab_size = config.vocab_size |
| 319 | self.config = config |
| 320 | |
| 321 | if get_pp_group().is_first_rank or ( |
| 322 | config.tie_word_embeddings and get_pp_group().is_last_rank |
| 323 | ): |
| 324 | self.embed_tokens = VocabParallelEmbedding( |
| 325 | self.vocab_size, |
| 326 | config.hidden_size, |
| 327 | ) |
| 328 | else: |
| 329 | self.embed_tokens = PPMissingLayer() |
| 330 | |
| 331 | self.start_layer, self.end_layer, self.layers = make_layers( |
| 332 | config.num_hidden_layers, |
| 333 | lambda prefix: Step3TextDecoderLayer( |
| 334 | config=config, |
| 335 | cache_config=cache_config, |
| 336 | quant_config=quant_config, |
| 337 | prefix=prefix, |
| 338 | ), |
| 339 | prefix=f"{prefix}.layers", |
| 340 | ) |
| 341 | if get_pp_group().is_last_rank: |
| 342 | self.norm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps) |
| 343 | else: |
| 344 | self.norm = PPMissingLayer() |
| 345 | |
| 346 | self.make_empty_intermediate_tensors = make_empty_intermediate_tensors_factory( |
| 347 | ["hidden_states", "residual"], config.hidden_size |
| 348 | ) |
| 349 | |
| 350 | def embed_input_ids(self, input_ids: torch.Tensor) -> torch.Tensor: |
| 351 | return self.embed_tokens(input_ids) |
| 352 | |
| 353 | def forward( |
| 354 | self, |
| 355 | input_ids: torch.Tensor | None, |
| 356 | positions: torch.Tensor, |
| 357 | intermediate_tensors: IntermediateTensors | None = None, |
| 358 | inputs_embeds: torch.Tensor | None = None, |
| 359 | ) -> torch.Tensor: |
| 360 | if get_pp_group().is_first_rank: |
| 361 | if inputs_embeds is not None: |
| 362 | hidden_states = inputs_embeds |
| 363 | else: |
| 364 | hidden_states = self.embed_input_ids(input_ids) |
| 365 | residual = None |
| 366 | else: |
| 367 | assert intermediate_tensors is not None |
| 368 | hidden_states = intermediate_tensors["hidden_states"] |
| 369 | residual = intermediate_tensors["residual"] |
| 370 | |
| 371 | for layer in islice(self.layers, self.start_layer, self.end_layer): |
| 372 | hidden_states, residual = layer(positions, hidden_states, residual) |
| 373 | |
| 374 | if not get_pp_group().is_last_rank: |
| 375 | return IntermediateTensors( |
| 376 | { |
| 377 | "hidden_states": hidden_states, |
| 378 | "residual": residual, |
| 379 | } |
| 380 | ) |
| 381 | |
| 382 | hidden_states, _ = self.norm(hidden_states, residual) |
| 383 | return hidden_states |
| 384 | |
| 385 | def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]: |
| 386 | qkv_params_mapping: list[tuple[str, str, float, float]] = [ |
| 387 | # (param_name, shard_name, relative_start_idx, relative_end_idx) |
| 388 | ( |
| 389 | ".qkv_proj", |
| 390 | ".q_proj", |
| 391 | 0, |
| 392 | self.config.share_q_dim |
| 393 | / (self.config.share_q_dim + self.config.head_dim * 2), |
| 394 | ), |
| 395 | ( |
| 396 | ".qkv_proj", |
| 397 | ".k_proj", |
| 398 | self.config.share_q_dim |
| 399 | / (self.config.share_q_dim + self.config.head_dim * 2), |
| 400 | (self.config.share_q_dim + self.config.head_dim) |
| 401 | / (self.config.share_q_dim + self.config.head_dim * 2), |
| 402 | ), |
| 403 | ( |
| 404 | ".qkv_proj", |
| 405 | ".v_proj", |
| 406 | (self.config.share_q_dim + self.config.head_dim) |
| 407 | / (self.config.share_q_dim + self.config.head_dim * 2), |
| 408 | (self.config.share_q_dim + self.config.head_dim * 2) |
| 409 | / (self.config.share_q_dim + self.config.head_dim * 2), |
| 410 | ), |
| 411 | ] |
| 412 | stacked_params_mapping: list[tuple[str, str, int]] = [ |
| 413 | # (param_name, shard_name, shard_id) |
| 414 | (".gate_up_proj", ".gate_proj", 0), |
| 415 | (".gate_up_proj", ".up_proj", 1), |
| 416 | ] |
| 417 | params_dict = dict(self.named_parameters()) |
| 418 | loaded_params: set[str] = set() |
| 419 | base_layer = ( |
| 420 | "base_layer." if any(".base_layer." in name for name in params_dict) else "" |
| 421 | ) |
| 422 | |
| 423 | expert_params_mapping: list[tuple[str, str, str]] = [ |
| 424 | ( |
| 425 | f".moe.experts.routed_experts.{base_layer}w13_weight", |
| 426 | ".moe.gate_proj.weight", |
| 427 | "w1", |
| 428 | ), |
| 429 | ( |
| 430 | f".moe.experts.routed_experts.{base_layer}w13_weight", |
| 431 | ".moe.up_proj.weight", |
| 432 | "w3", |
| 433 | ), |
| 434 | ( |
| 435 | f".moe.experts.routed_experts.{base_layer}w2_weight", |
| 436 | ".moe.down_proj.weight", |
| 437 | "w2", |
| 438 | ), |
| 439 | ] |
| 440 | |
| 441 | disable_moe_stacked_params = [data[1] for data in expert_params_mapping] |
| 442 | |
| 443 | for name, loaded_weight in weights: |
| 444 | for param_name, weight_name, shard_id in stacked_params_mapping: |
| 445 | if weight_name not in name: |
| 446 | continue |
| 447 | if any( |
| 448 | disable_moe_stacked_param in name |
| 449 | for disable_moe_stacked_param in disable_moe_stacked_params |
| 450 | ): |
| 451 | continue |
| 452 | name = name.replace(weight_name, param_name) |
| 453 | if is_pp_missing_parameter(name, self): |
| 454 | continue |
| 455 | param = params_dict[name] |
| 456 | weight_loader = param.weight_loader |
| 457 | weight_loader(param, loaded_weight, shard_id) |
| 458 | loaded_params.add(name) |
| 459 | break |
| 460 | else: |
| 461 | for mapping in expert_params_mapping: |
| 462 | param_name, weight_name, expert_shard_id = mapping |
| 463 | if weight_name not in name: |
| 464 | continue |
| 465 | name = name.replace(weight_name, param_name) |
| 466 | # Skip layers on other devices. |
| 467 | if is_pp_missing_parameter(name, self): |
| 468 | continue |
| 469 | # Skip loading extra bias for GPTQ models. |
| 470 | if ( |
| 471 | name.endswith(".bias") or name.endswith("_bias") |
| 472 | ) and name not in params_dict: |
| 473 | continue |
| 474 | param = params_dict[name] |
| 475 | weight_loader = param.weight_loader |
| 476 | for expert_id in range(loaded_weight.shape[0]): |
| 477 | loaded_weight_expert = loaded_weight[expert_id] |
| 478 | weight_loader( |
| 479 | param, |
| 480 | loaded_weight_expert, |
| 481 | name, |
| 482 | shard_id=expert_shard_id, |
| 483 | expert_id=expert_id, |
| 484 | ) |
| 485 | loaded_params.add(name) |
| 486 | break |
| 487 | else: |
| 488 | for ( |
| 489 | param_name, |
| 490 | weight_name, |
| 491 | start_idx, |
| 492 | end_idx, |
| 493 | ) in qkv_params_mapping: |
| 494 | if weight_name not in name: |
| 495 | continue |
| 496 | name = name.replace(weight_name, param_name) |
| 497 | if is_pp_missing_parameter(name, self): |
| 498 | continue |
| 499 | param = params_dict[name] |
| 500 | dim = param.shape[param.output_dim] |
| 501 | begin_idx = int(start_idx * dim) |
| 502 | end_idx = int(end_idx * dim) |
| 503 | param_slice = param.narrow( |
| 504 | param.output_dim, begin_idx, end_idx - begin_idx |
| 505 | ) |
| 506 | param_slice.copy_(loaded_weight) |
| 507 | loaded_params.add(name) |
| 508 | break |
| 509 | else: |
| 510 | if is_pp_missing_parameter(name, self): |
| 511 | continue |
| 512 | param = params_dict[name] |
| 513 | weight_loader = getattr( |
| 514 | param, "weight_loader", default_weight_loader |
| 515 | ) |
| 516 | weight_loader(param, loaded_weight) |
| 517 | loaded_params.add(name) |
| 518 | return loaded_params |
| 519 | |
| 520 | |
| 521 | class Step3TextForCausalLM(nn.Module, SupportsPP): |
| 522 | def __init__( |
| 523 | self, |
| 524 | *, |
| 525 | vllm_config: VllmConfig, |
| 526 | prefix: str = "", |
| 527 | ): |
| 528 | super().__init__() |
| 529 | config = vllm_config.model_config.hf_config |
| 530 | |
| 531 | self.config = config |
| 532 | self.vllm_config = vllm_config |
| 533 | |
| 534 | self.model = Step3TextModel(vllm_config=vllm_config, prefix=prefix) |
| 535 | |
| 536 | if get_pp_group().is_last_rank: |
| 537 | self.lm_head = ParallelLMHead( |
| 538 | config.vocab_size, |
| 539 | config.hidden_size, |
| 540 | prefix=maybe_prefix(prefix, "lm_head"), |
| 541 | ) |
| 542 | self.logits_processor = LogitsProcessor(config.vocab_size) |
| 543 | else: |
| 544 | self.lm_head = PPMissingLayer() |
| 545 | |
| 546 | self.make_empty_intermediate_tensors = ( |
| 547 | self.model.make_empty_intermediate_tensors |
| 548 | ) |
| 549 | |
| 550 | def embed_input_ids(self, input_ids: torch.Tensor) -> torch.Tensor: |
| 551 | return self.model.embed_input_ids(input_ids) |
| 552 | |
| 553 | def forward( |
| 554 | self, |
| 555 | input_ids: torch.Tensor | None, |
| 556 | positions: torch.Tensor, |
| 557 | intermediate_tensors: IntermediateTensors | None = None, |
| 558 | inputs_embeds: torch.Tensor | None = None, |
| 559 | ): |
| 560 | hidden_states = self.model( |
| 561 | input_ids, positions, intermediate_tensors, inputs_embeds |
| 562 | ) |
| 563 | return hidden_states |
| 564 | |
| 565 | def compute_logits(self, hidden_states: torch.Tensor) -> torch.Tensor: |
| 566 | logits = self.logits_processor(self.lm_head, hidden_states) |
| 567 | return logits |
| 568 | |
| 569 | def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]: |
| 570 | loader = AutoWeightsLoader(self) |
| 571 | return loader.load_weights(weights) |