vllm_gaudi.extension.utils
¶
B2BMatmul
¶
Bases: Matmul
Specialized alias for batch2block and block2batch matmul operations.
This class remains functionally identical to Matmul but is used to
semantically mark B2B-related matmuls. This enables the system to apply the
fix that uses the B2B output measurements as the input measurements during
calibration, avoiding corrupted scales from the KV‑cache.
Source code in vllm_gaudi/extension/utils.py
FP8Matmul
¶
Bases: Module
Source code in vllm_gaudi/extension/utils.py
__init__
¶
forward
¶
Source code in vllm_gaudi/extension/utils.py
matmul_fp8
¶
Source code in vllm_gaudi/extension/utils.py
ModuleFP8FusedSDPA
¶
Bases: Module
Source code in vllm_gaudi/extension/utils.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
__init__
¶
Source code in vllm_gaudi/extension/utils.py
forward
¶
forward(
query,
key,
value,
attn_mask,
dropout_p,
is_causal,
scale,
softmax_mode,
recompute_mode,
valid_sequence_lengths,
padding_side="left",
window_size=None,
)
Source code in vllm_gaudi/extension/utils.py
ModuleFusedSDPA
¶
Bases: Module
Source code in vllm_gaudi/extension/utils.py
__init__
¶
forward
¶
forward(
query,
key,
value,
attn_mask,
dropout_p,
is_causal,
scale,
softmax_mode,
recompute_mode,
valid_sequence_lengths,
padding_side="left",
window_size=None,
sinks=None,
)
Source code in vllm_gaudi/extension/utils.py
SlicedFP8FusedSDPA
¶
Bases: SlicedFusedSDPABase
Standalone module for FP8 sliced FusedSDPA.
Like :class:SlicedFusedSDPA, extracting the sliced path enables
wrapping with torch.compile or ht.hpu.wrap_in_hpu_graph.
Expects pre-quantized FP8 inputs; dequantises chunk outputs to
BF16/FP32 before the online-softmax rescaling merge.
Source code in vllm_gaudi/extension/utils.py
__init__
¶
_dequant_output
¶
_fp8_fsdpa_fwd
¶
Source code in vllm_gaudi/extension/utils.py
forward
¶
Source code in vllm_gaudi/extension/utils.py
SlicedFusedSDPA
¶
Bases: SlicedFusedSDPABase
Standalone module for BF16 sliced FusedSDPA.
Extracting the sliced attention path into its own nn.Module allows it
to be wrapped with torch.compile, ht.hpu.wrap_in_hpu_graph, or
any other module-level wrapper independently of the dispatch logic in
:class:ModuleFusedSDPA.
Source code in vllm_gaudi/extension/utils.py
forward
¶
Source code in vllm_gaudi/extension/utils.py
SlicedFusedSDPABase
¶
Bases: Module
Base class for sliced FusedSDPA modules.
Encapsulates the common slicing initialization (chunk size, padded chunk
counts, graph-break setup) shared by :class:SlicedFusedSDPA and
:class:SlicedFP8FusedSDPA.
Source code in vllm_gaudi/extension/utils.py
154 155 156 157 158 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 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 | |
__init__
¶
_chunked_attention
¶
Run chunked attention with online softmax rescaling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q, k, v
|
Query, key, value tensors (after GQA reshape if needed). |
required | |
attn_mask
|
Attention mask tensor. |
required | |
dropout_p
|
Dropout probability. |
required | |
scale
|
Attention scale factor. |
required | |
softmax_mode
|
Softmax mode string. |
required | |
chunk_kernel_fn
|
Callable
|
required |
Returns:
| Type | Description |
|---|---|
|
Concatenated output tensor in float32. |
Source code in vllm_gaudi/extension/utils.py
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 | |
_merge_chunk
staticmethod
¶
Online softmax rescaling merge of two attention chunks.
Source code in vllm_gaudi/extension/utils.py
_setup_slicing
¶
_setup_slicing() -> bool
Source code in vllm_gaudi/extension/utils.py
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 | |
VLLMFP8KVCache
¶
Bases: VLLMKVCache
Source code in vllm_gaudi/extension/utils.py
__init__
¶
dequant_output
¶
fetch_from_cache
¶
Source code in vllm_gaudi/extension/utils.py
forward
¶
VLLMKVCache
¶
Bases: Module