vllm_gaudi.models.qwen3_vl
¶
HPUQwen3_VisionBlock
¶
Bases: Qwen3_VisionBlock
Source code in vllm_gaudi/models/qwen3_vl.py
attn
instance-attribute
¶
attn = HPUQwen2_5_VisionAttention(
embed_dim=dim,
num_heads=num_heads,
projection_size=dim,
quant_config=quant_config,
multimodal_config=multimodal_config,
prefix=f"{prefix}.attn",
)
__init__
¶
__init__(
*,
dim: int,
num_heads: int,
mlp_hidden_dim: int,
act_fn,
norm_layer,
quant_config=None,
multimodal_config=None,
prefix: str = "",
)
Source code in vllm_gaudi/models/qwen3_vl.py
forward
¶
forward(
x: Tensor,
cu_seqlens: Tensor,
rotary_pos_emb_cos: Tensor,
rotary_pos_emb_sin: Tensor,
max_seqlen: Tensor,
attn_mask=None,
) -> Tensor
Source code in vllm_gaudi/models/qwen3_vl.py
HPUQwen3_VisionTransformer
¶
Bases: Qwen3_VisionTransformer
Source code in vllm_gaudi/models/qwen3_vl.py
blocks
instance-attribute
¶
blocks = ModuleList(
[
(
HPUQwen3_VisionBlock(
dim=hidden_size,
num_heads=num_heads,
mlp_hidden_dim=intermediate_size,
act_fn=get_act_fn(hidden_act),
norm_layer=norm_layer,
quant_config=quant_config,
multimodal_config=multimodal_config,
prefix=f"{prefix}.blocks.{layer_idx}",
)
)
for layer_idx in (range(depth))
]
)
__init__
¶
__init__(
vision_config,
norm_eps: float = 1e-06,
quant_config=None,
multimodal_config=None,
prefix: str = "",
)
Source code in vllm_gaudi/models/qwen3_vl.py
forward
¶
forward(
x: Tensor,
grid_thw: Tensor | list[list[int]],
attn_mask: Tensor | None = None,
) -> Tensor
Source code in vllm_gaudi/models/qwen3_vl.py
HpuQwen3_VLForConditionalGeneration
¶
Bases: Qwen3VLForConditionalGeneration
Source code in vllm_gaudi/models/qwen3_vl.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 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 | |
visual
instance-attribute
¶
visual = HPUQwen3_VisionTransformer(
vision_config,
norm_eps=getattr(config, "rms_norm_eps", 1e-06),
quant_config=quant_config,
multimodal_config=multimodal_config,
prefix=maybe_prefix(prefix, "visual"),
)
__init__
¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm_gaudi/models/qwen3_vl.py
_compute_deepstack_embeds
¶
_compute_deepstack_embeds(
inputs_embeds: Tensor,
multimodal_embeddings: MultiModalEmbeddings,
is_multimodal: Tensor,
) -> tuple[Tensor, MultiModalEmbeddings]
Source code in vllm_gaudi/models/qwen3_vl.py
_process_image_input
¶
Source code in vllm_gaudi/models/qwen3_vl.py
create_block_diagonal_mask
¶
create_block_diagonal_mask(
cu_seqlens: Tensor,
grid_thw: list[int],
device: device = None,
dtype: dtype = bool,
) -> Tensor
Create block diagonal mask that excludes padded tokens for Qwen3VL attention. Args: cu_seqlens: Cumulative sequence lengths from grid dimensions grid_thw: The grid dimensions with merge_size=2 compatibility device: Target device for the mask dtype: Data type for the mask (typically torch.bool)
Returns:
| Type | Description |
|---|---|
Tensor
|
Block diagonal attention mask with shape [total_seq_len, total_seq_len] |
Source code in vllm_gaudi/models/qwen3_vl.py
embed_input_ids
¶
embed_input_ids(
input_ids: Tensor,
multimodal_embeddings: MultiModalEmbeddings
| None = None,
*,
is_multimodal: Tensor | None = None,
handle_oov_mm_token: bool = False,
) -> Tensor