vllm.models.hy_v4.nvidia.vision
¶
Classes:
HYV4VisionPatchEmbed
¶
Bases: Module
Methods:
-
compute_pos_embeds–Interpolated position embedding per patch,
(num_patches, hidden). -
forward_with_pos_embeds–Packed path: patch conv plus precomputed position embeddings.
Source code in vllm/models/hy_v4/nvidia/vision.py
compute_pos_embeds(grid_thw, dtype)
¶
Interpolated position embedding per patch, (num_patches, hidden).
Source code in vllm/models/hy_v4/nvidia/vision.py
forward_with_pos_embeds(pixel_values, pos_embeds)
¶
Packed path: patch conv plus precomputed position embeddings.
Source code in vllm/models/hy_v4/nvidia/vision.py
HYV4VisionTransformer
¶
Bases: Module
Methods:
-
forward_packed–Static-shape packed ViT forward for encoder CUDA graph capture/replay.
-
prepare_encoder_cudagraph_metadata–Precompute the packed-forward inputs that depend only on grids.
Source code in vllm/models/hy_v4/nvidia/vision.py
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 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
_encode(pixel_values, grid_thw)
¶
Patch embedding plus ViT layers over the packed patch sequence.
Source code in vllm/models/hy_v4/nvidia/vision.py
_iter_item_states(hidden, grid_thw)
¶
Per-item (frames, h, w, hidden) slices with temporal padding.
Source code in vllm/models/hy_v4/nvidia/vision.py
forward_packed(patches, pos_embeds, rope_cos, rope_sin, cu_seqlens, max_seqlen)
¶
Static-shape packed ViT forward for encoder CUDA graph capture/replay.
patches holds the embedded patches (input norm + patch conv
applied eagerly at replay time): both conv2d kernels (patch embed and
merger) are cudnn calls whose results are not invariant to input
shape (measured on GB200), so they cannot run on padded buffers
without changing results bit-wise. Everything left in the graph —
pos-embed add, per-layer LayerNorm/GEMM/RoPE/FlashAttn-varlen — is
row-invariant and verified bitwise-identical to the eager path.
All grid-dependent host logic must be precomputed via
prepare_encoder_cudagraph_metadata. Returns the padded packed
hidden states (1, num_patch_slots, hidden_size); the per-item
merger then runs eagerly on the real rows (in
postprocess_encoder_output).
Source code in vllm/models/hy_v4/nvidia/vision.py
prepare_encoder_cudagraph_metadata(grid_thw, *, device, max_seqlen_override=None)
¶
Precompute the packed-forward inputs that depend only on grids.