vllm.model_executor.models.olmo2
Inference-only OLMo2 model compatible with HuggingFace weights.
Olmo2Attention ¶
Bases: Module
This is the attention block where the output is computed as Attention(LN(x))
in MLP(LN(x + Attention(LN(x))))
(plus another skip connection).
Source code in vllm/model_executor/models/olmo2.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
attn instance-attribute
¶
attn = Attention(
num_heads,
head_dim,
scaling,
num_kv_heads=num_kv_heads,
cache_config=cache_config,
quant_config=quant_config,
prefix=prefix,
)
o_proj instance-attribute
¶
o_proj = RowParallelLinear(
total_num_heads * head_dim,
hidden_size,
bias=False,
quant_config=quant_config,
prefix=f"{prefix}.o_proj",
)
qkv_proj instance-attribute
¶
qkv_proj = QKVParallelLinear(
hidden_size,
head_dim,
total_num_heads,
total_num_kv_heads,
bias=False,
quant_config=quant_config,
prefix=f"{prefix}.qkv_proj",
)
rotary_emb instance-attribute
¶
rotary_emb = get_rope(
head_dim,
rotary_dim=head_dim,
max_position=max_position_embeddings,
base=rope_theta,
)
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/olmo2.py
_apply_qk_norm ¶
Source code in vllm/model_executor/models/olmo2.py
forward ¶
Source code in vllm/model_executor/models/olmo2.py
Olmo2DecoderLayer ¶
Bases: Module
This is a typical transformer block where the output is computed as MLP(LN(x + Attention(LN(x))))
(plus another skip connection).
Source code in vllm/model_executor/models/olmo2.py
post_attention_layernorm instance-attribute
¶
post_attention_layernorm = RMSNorm(
hidden_size, eps=rms_norm_eps
)
post_feedforward_layernorm instance-attribute
¶
post_feedforward_layernorm = RMSNorm(
hidden_size, eps=rms_norm_eps
)
self_attn instance-attribute
¶
self_attn = Olmo2Attention(
vllm_config=vllm_config, prefix=f"{prefix}.self_attn"
)
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/olmo2.py
forward ¶
Source code in vllm/model_executor/models/olmo2.py
Olmo2ForCausalLM ¶
Bases: Module
, SupportsPP
, SupportsLoRA
Extremely barebones HF model wrapper.
Source code in vllm/model_executor/models/olmo2.py
make_empty_intermediate_tensors instance-attribute
¶
model instance-attribute
¶
model = Olmo2Model(
vllm_config=vllm_config,
prefix=maybe_prefix(prefix, "model"),
)
packed_modules_mapping class-attribute
instance-attribute
¶
packed_modules_mapping = {
"qkv_proj": ["q_proj", "k_proj", "v_proj"],
"gate_up_proj": ["gate_proj", "up_proj"],
}
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/olmo2.py
compute_logits ¶
compute_logits(
hidden_states: Tensor,
sampling_metadata: SamplingMetadata,
) -> Optional[Tensor]
forward ¶
forward(
input_ids: Tensor,
positions: Tensor,
intermediate_tensors: Optional[
IntermediateTensors
] = None,
inputs_embeds: Optional[Tensor] = None,
) -> Union[Tensor, IntermediateTensors]
Source code in vllm/model_executor/models/olmo2.py
load_weights ¶
Olmo2MLP ¶
Bases: Module
This is the MLP block where the output is computed as MLP(x)
in LN(MLP(x + LN(Attention(x))))
(plus another skip connection).
Source code in vllm/model_executor/models/olmo2.py
down_proj instance-attribute
¶
down_proj = RowParallelLinear(
intermediate_size,
hidden_size,
bias=False,
quant_config=quant_config,
prefix=f"{prefix}.down_proj",
)
gate_up_proj instance-attribute
¶
gate_up_proj = MergedColumnParallelLinear(
hidden_size,
[intermediate_size] * 2,
bias=False,
quant_config=quant_config,
prefix=f"{prefix}.gate_up_proj",
)
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/olmo2.py
Olmo2Model ¶
Bases: Module
Source code in vllm/model_executor/models/olmo2.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
embed_tokens instance-attribute
¶
embed_tokens = VocabParallelEmbedding(
vocab_size, hidden_size, prefix=f"{prefix}.embed_tokens"
)
make_empty_intermediate_tensors instance-attribute
¶
make_empty_intermediate_tensors = (
make_empty_intermediate_tensors_factory(
["hidden_states"], hidden_size
)
)
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/olmo2.py
forward ¶
forward(
input_ids: Tensor,
positions: Tensor,
intermediate_tensors: Optional[IntermediateTensors],
inputs_embeds: Optional[Tensor] = None,
) -> Union[Tensor, IntermediateTensors]
:param input_ids: A tensor of shape (batch_size, seq_len)
.