hunyuanvideo ¶
Classes¶
fastvideo.models.dits.hunyuanvideo.FinalLayer ¶
FinalLayer(hidden_size, patch_size, out_channels, dtype=None, prefix: str = '')
Bases: Module
The final layer of DiT that projects features to pixel space.
Source code in fastvideo/models/dits/hunyuanvideo.py
fastvideo.models.dits.hunyuanvideo.HunyuanRMSNorm ¶
Bases: Module
Initialize the RMSNorm normalization layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim | int | The dimension of the input tensor. | required |
eps | float | A small value added to the denominator for numerical stability. Default is 1e-6. | 1e-06 |
Attributes:
| Name | Type | Description |
|---|---|---|
eps | float | A small value added to the denominator for numerical stability. |
weight | Parameter | Learnable scaling parameter. |
Source code in fastvideo/models/dits/hunyuanvideo.py
Methods:¶
fastvideo.models.dits.hunyuanvideo.HunyuanRMSNorm.forward ¶
Forward pass through the RMSNorm layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | Tensor | The input tensor. | required |
Returns:
| Type | Description |
|---|---|
| torch.Tensor: The output tensor after applying RMSNorm. |
Source code in fastvideo/models/dits/hunyuanvideo.py
fastvideo.models.dits.hunyuanvideo.HunyuanVideoTransformer3DModel ¶
Bases: BaseDiT
HunyuanVideo Transformer backbone adapted for distributed training.
This implementation uses distributed attention and linear layers for efficient parallel processing across multiple GPUs.
Based on the architecture from: - Flux.1: https://github.com/black-forest-labs/flux - MMDiT: http://arxiv.org/abs/2403.03206
Source code in fastvideo/models/dits/hunyuanvideo.py
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 494 495 496 497 498 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 | |
Methods:¶
fastvideo.models.dits.hunyuanvideo.HunyuanVideoTransformer3DModel.forward ¶
forward(hidden_states: Tensor, encoder_hidden_states: Tensor | list[Tensor], timestep: LongTensor, encoder_hidden_states_image: Tensor | list[Tensor] | None = None, guidance=None, **kwargs)
Forward pass of the HunyuanDiT model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input image/video latents [B, C, T, H, W] | required |
encoder_hidden_states | Tensor | list[Tensor] | Text embeddings [B, L, D] | required |
timestep | LongTensor | Diffusion timestep | required |
guidance | Guidance scale for CFG | None |
Returns:
| Type | Description |
|---|---|
| Tuple of (output) |
Source code in fastvideo/models/dits/hunyuanvideo.py
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 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
fastvideo.models.dits.hunyuanvideo.IndividualTokenRefinerBlock ¶
IndividualTokenRefinerBlock(hidden_size, num_attention_heads, mlp_ratio=4.0, qkv_bias=True, dtype=None, prefix: str = '')
Bases: Module
A transformer block for refining individual tokens with self-attention.
Source code in fastvideo/models/dits/hunyuanvideo.py
fastvideo.models.dits.hunyuanvideo.MMDoubleStreamBlock ¶
MMDoubleStreamBlock(hidden_size: int, num_attention_heads: int, mlp_ratio: float, dtype: dtype | None = None, supported_attention_backends: tuple[AttentionBackendEnum, ...] | None = None, prefix: str = '')
Bases: Module
A multimodal DiT block with separate modulation for text and image/video, using distributed attention and linear layers.
Source code in fastvideo/models/dits/hunyuanvideo.py
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 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 | |
fastvideo.models.dits.hunyuanvideo.MMSingleStreamBlock ¶
MMSingleStreamBlock(hidden_size: int, num_attention_heads: int, mlp_ratio: float = 4.0, dtype: dtype | None = None, supported_attention_backends: tuple[AttentionBackendEnum, ...] | None = None, prefix: str = '')
Bases: Module
A DiT block with parallel linear layers using distributed attention and tensor parallelism.
Source code in fastvideo/models/dits/hunyuanvideo.py
fastvideo.models.dits.hunyuanvideo.SingleTokenRefiner ¶
SingleTokenRefiner(in_channels, hidden_size, num_attention_heads, depth=2, qkv_bias=True, dtype=None, prefix: str = '')
Bases: Module
A token refiner that processes text embeddings with attention to improve their representation for cross-attention with image features.