Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e0b4cdc
function hunyuan_t2v_tea, hunyuan_t2v_taylorseer, modify the fresh_th…
Linboyan-trc Apr 30, 2025
7e2c87e
hunyuan i2v,t2v + tea,tay; wan i2v,t2v + tea function, add log files
Linboyan-trc Apr 30, 2025
9fb4249
删除了TeaCace Scheduler的多余属性
Linboyan-trc May 12, 2025
3654dfc
Merge branch 'main' into 02_feature_caching, 修复了tea, taylor功能,可以正常运行
Linboyan-trc May 12, 2025
69e1377
删除了多余目录
Linboyan-trc May 12, 2025
7ecb387
修复了TeaCaching部分的bug,目前t2v, i2v feature caching均可跑通
Linboyan-trc May 12, 2025
8308361
Merge branch 'main' into 02_feature_caching
Linboyan-trc May 12, 2025
99283c7
Merge remote-tracking branch 'upstream/main' into 02_feature_caching
Linboyan-trc May 22, 2025
845e627
modify transformers
Linboyan-trc May 26, 2025
d47a6a9
hunyuan transformer can run, but the result is not correct
Linboyan-trc May 27, 2025
b5933f9
fix bug: infer double_block_2 should return img and txt
Linboyan-trc May 27, 2025
e8bbb5b
fix bug
Linboyan-trc May 27, 2025
b78363b
hunyuan can run transformer, transformerTea
Linboyan-trc May 27, 2025
3722103
hunyuan transformer, tea, taylor can run
Linboyan-trc May 29, 2025
49548e1
finish HunyuanAdaCache
Linboyan-trc May 29, 2025
339ce14
add ada.sh and ada.json
Linboyan-trc May 29, 2025
7b0d294
hunyuan ada can run
Linboyan-trc May 29, 2025
4a067a9
modify function distribution, and finish custom
Linboyan-trc May 29, 2025
5b1bc9b
add cpuoffload, rewriting offload for transformer_infer
Linboyan-trc Jun 4, 2025
eafea2b
add scripts and configs for hunyuan i2v caching
Linboyan-trc Jun 5, 2025
e3fa388
finish Wan2.1 TransformerInfer
Linboyan-trc Jun 9, 2025
f334970
Wan2.1 Transformer can run
Linboyan-trc Jun 9, 2025
9bb6811
finish Wan2.1 Tea
Linboyan-trc Jun 10, 2025
a09985b
finish Wan2.1 Tea and import
Linboyan-trc Jun 10, 2025
759626e
Wan2.1 Tea function
Linboyan-trc Jun 10, 2025
bf23919
finish Wan2.1 Taylor
Linboyan-trc Jun 10, 2025
7328c14
refactor directory structure
Linboyan-trc Jun 11, 2025
fc25210
add decision list for WanScheduler
Linboyan-trc Jun 11, 2025
9b666dc
finish modify Wan2.1 Tea
Linboyan-trc Jun 11, 2025
83f6222
modify Wan2.1 Taylor
Linboyan-trc Jun 11, 2025
d53eb19
modify Wan2.1 Taylor
Linboyan-trc Jun 11, 2025
8cf0df2
uniform scripts, configs, save_results, transformer_class name
Linboyan-trc Jun 11, 2025
901c197
uniform scripts, configs, save_results, transformer_class name
Linboyan-trc Jun 11, 2025
24fa356
remove duplicate uppercase folders Ada and Custom
Linboyan-trc Jun 11, 2025
7343621
uniform scripts, configs, save_results, transformer_class, in configs…
Linboyan-trc Jun 11, 2025
00c0385
bantch 1: after refactor, hunyuan t2v * 5 function
Linboyan-trc Jun 11, 2025
25be044
uniform scripts, configs, save_results, in configs for hunyuan i2v * 5
Linboyan-trc Jun 11, 2025
48234b8
remove redundant files
Linboyan-trc Jun 11, 2025
4fad181
remove redundant files
Linboyan-trc Jun 11, 2025
1bf2f1a
hunyuan t2v * 5, i2v * 5 can function
Linboyan-trc Jun 11, 2025
b5680c1
test Wan2.1 t2v * 3
Linboyan-trc Jun 11, 2025
36242bf
test Wan2.1 t2v * 3
Linboyan-trc Jun 11, 2025
ce8d9b2
Wan2.1 t2v * 3 can function
Linboyan-trc Jun 11, 2025
190136b
finish Wan2.1 Ada
Linboyan-trc Jun 11, 2025
87df0d1
finish Wan2.1 Ada
Linboyan-trc Jun 11, 2025
5f58bbe
finish Wan2.1 Ada
Linboyan-trc Jun 11, 2025
47a64b5
finish Wan2.1 Custom
Linboyan-trc Jun 11, 2025
3aa2592
finish Wan2.1 Custom
Linboyan-trc Jun 11, 2025
517ccac
finish Wan2.1 Custom
Linboyan-trc Jun 11, 2025
692c452
test: Wan2.1 i2v * 5
Linboyan-trc Jun 11, 2025
6756047
test Wan2.1 it2 * 5
Linboyan-trc Jun 11, 2025
67ac7e8
Wan2.1 i2v * 5 function, but taylor cant function because the memory …
Linboyan-trc Jun 11, 2025
1f90e2d
finish clear
Linboyan-trc Jun 11, 2025
af8007b
modify annotations
Linboyan-trc Jun 11, 2025
aec5007
lint for AdaCaching
Linboyan-trc Jun 11, 2025
5d39fb5
lint for AdaCaching
Linboyan-trc Jun 11, 2025
4fda2b0
for pylint
Linboyan-trc Jun 11, 2025
dfb6ecf
for pylint
Linboyan-trc Jun 11, 2025
854c598
finish Hunyuan transformer offload * 1
Linboyan-trc Jun 12, 2025
cfa2d1b
finish Wan2.1 transformer offload * 1
Linboyan-trc Jun 12, 2025
22890ea
prepare scripts for test
Linboyan-trc Jun 12, 2025
17bb458
fix bug
Linboyan-trc Jun 12, 2025
e2e8339
for merge
Linboyan-trc Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"mm_type": "W-int8-channel-sym-A-int8-channel-sym-dynamic-Vllm",
"weight_auto_quant": true
},
"feature_caching": "TaylorSeer"
"feature_caching": "Ada"
}
12 changes: 12 additions & 0 deletions configs/caching/hunyuan_i2v_custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"infer_steps": 20,
"target_video_length": 33,
"i2v_resolution": "720p",
"attention_type": "flash_attn3",
"seed": 0,
"mm_config": {
"mm_type": "W-int8-channel-sym-A-int8-channel-sym-dynamic-Vllm",
"weight_auto_quant": true
},
"feature_caching": "Custom"
}
12 changes: 12 additions & 0 deletions configs/caching/hunyuan_i2v_taylor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"infer_steps": 20,
"target_video_length": 33,
"i2v_resolution": "720p",
"attention_type": "flash_attn3",
"seed": 0,
"mm_config": {
"mm_type": "W-int8-channel-sym-A-int8-channel-sym-dynamic-Vllm",
"weight_auto_quant": true
},
"feature_caching": "Taylor"
}
13 changes: 13 additions & 0 deletions configs/caching/hunyuan_t2v_ada.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"infer_steps": 20,
"target_video_length": 33,
"target_height": 720,
"target_width": 1280,
"attention_type": "flash_attn3",
"seed": 42,
"mm_config": {
"mm_type": "W-int8-channel-sym-A-int8-channel-sym-dynamic-Vllm",
"weight_auto_quant": true
},
"feature_caching": "Ada"
}
13 changes: 13 additions & 0 deletions configs/caching/hunyuan_t2v_custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"infer_steps": 20,
"target_video_length": 33,
"target_height": 720,
"target_width": 1280,
"attention_type": "flash_attn3",
"seed": 42,
"mm_config": {
"mm_type": "W-int8-channel-sym-A-int8-channel-sym-dynamic-Vllm",
"weight_auto_quant": true
},
"feature_caching": "Custom"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"target_width": 1280,
"attention_type": "flash_attn3",
"seed": 42,
"feature_caching": "TaylorSeer"
"feature_caching": "Taylor"
}
17 changes: 17 additions & 0 deletions configs/caching/wan_i2v_ada.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"infer_steps": 40,
"target_video_length": 81,
"target_height": 480,
"target_width": 832,
"attention_type": "flash_attn3",
"seed": 42,
"sample_guide_scale": 5,
"sample_shift": 5,
"enable_cfg": true,
"cpu_offload": false,
"mm_config": {
"mm_type": "W-fp8-channel-sym-A-fp8-channel-sym-dynamic-Sgl",
"weight_auto_quant": true
},
"feature_caching": "Ada"
}
17 changes: 17 additions & 0 deletions configs/caching/wan_i2v_custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"infer_steps": 40,
"target_video_length": 81,
"target_height": 480,
"target_width": 832,
"attention_type": "flash_attn3",
"seed": 42,
"sample_guide_scale": 5,
"sample_shift": 5,
"enable_cfg": true,
"cpu_offload": false,
"mm_config": {
"mm_type": "W-fp8-channel-sym-A-fp8-channel-sym-dynamic-Sgl",
"weight_auto_quant": true
},
"feature_caching": "Custom"
}
17 changes: 17 additions & 0 deletions configs/caching/wan_i2v_taylor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"infer_steps": 40,
"target_video_length": 81,
"target_height": 480,
"target_width": 832,
"attention_type": "flash_attn3",
"seed": 42,
"sample_guide_scale": 5,
"sample_shift": 5,
"enable_cfg": true,
"cpu_offload": false,
"mm_config": {
"mm_type": "W-fp8-channel-sym-A-fp8-channel-sym-dynamic-Sgl",
"weight_auto_quant": true
},
"feature_caching": "Taylor"
}
File renamed without changes.
18 changes: 18 additions & 0 deletions configs/caching/wan_t2v_ada.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"infer_steps": 50,
"target_video_length": 81,
"text_len": 512,
"target_height": 480,
"target_width": 832,
"attention_type": "flash_attn3",
"seed": 42,
"sample_guide_scale": 6,
"sample_shift": 8,
"enable_cfg": true,
"cpu_offload": false,
"mm_config": {
"mm_type": "W-fp8-channel-sym-A-fp8-channel-sym-dynamic-Sgl",
"weight_auto_quant": true
},
"feature_caching": "Ada"
}
18 changes: 18 additions & 0 deletions configs/caching/wan_t2v_custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"infer_steps": 50,
"target_video_length": 81,
"text_len": 512,
"target_height": 480,
"target_width": 832,
"attention_type": "flash_attn3",
"seed": 42,
"sample_guide_scale": 6,
"sample_shift": 8,
"enable_cfg": true,
"cpu_offload": false,
"mm_config": {
"mm_type": "W-fp8-channel-sym-A-fp8-channel-sym-dynamic-Sgl",
"weight_auto_quant": true
},
"feature_caching": "Custom"
}
18 changes: 18 additions & 0 deletions configs/caching/wan_t2v_taylor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"infer_steps": 50,
"target_video_length": 81,
"text_len": 512,
"target_height": 480,
"target_width": 832,
"attention_type": "flash_attn3",
"seed": 42,
"sample_guide_scale": 6,
"sample_shift": 8,
"enable_cfg": true,
"cpu_offload": false,
"mm_config": {
"mm_type": "W-fp8-channel-sym-A-fp8-channel-sym-dynamic-Sgl",
"weight_auto_quant": true
},
"feature_caching": "Taylor"
}
File renamed without changes.
45 changes: 45 additions & 0 deletions lightx2v/common/transformer_infer/transformer_infer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from abc import ABC, abstractmethod
import torch
import math


class BaseTransformerInfer(ABC):
@abstractmethod
def infer(self):
pass

@abstractmethod
def infer_calculating(self):
pass

@abstractmethod
def infer_using_cache(self):
pass

@abstractmethod
def get_taylor_step_diff(self):
pass

def set_scheduler(self, scheduler):
self.scheduler = scheduler
self.scheduler.transformer_infer = self

# 1. when fully calcualted, stored in cache
def derivative_approximation(self, block_cache, module_name, out):
if module_name not in block_cache:
block_cache[module_name] = {0: out}
else:
step_diff = self.get_taylor_step_diff()

previous_out = block_cache[module_name][0]
block_cache[module_name][0] = out
block_cache[module_name][1] = (out - previous_out) / step_diff

def taylor_formula(self, tensor_dict):
x = self.get_taylor_step_diff()

output = 0
for i in range(len(tensor_dict)):
output += (1 / math.factorial(i)) * tensor_dict[i] * (x**i)

return output
Loading