diff --git a/MindIE/MultiModal/CogVideoX/README.md b/MindIE/MultiModal/CogVideoX/README.md index e949cdc6913c6ce7028af55d859a32e1e601a83b..669b87d1551bca73b3b0c3d95c823a6f069f9d9e 100644 --- a/MindIE/MultiModal/CogVideoX/README.md +++ b/MindIE/MultiModal/CogVideoX/README.md @@ -217,7 +217,7 @@ TASK_QUEUE_ENABLE=2 ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 torchrun --master_ ### CogVideoX-5b | 硬件形态 | cpu规格 | batch size | 迭代次数 | 数据类型 | 卡数 | 平均耗时 | | :------: | :------: | :------: |:----:| :------: | :------: | :------: | -| Atlas 800I A2(8*64G) | 64核(arm) | 1 | 50 | bfloat16 | 1 | 210s | +| Atlas 800I A2(8*64G) | 64核(arm) | 1 | 50 | bfloat16 | 1 | 224s | | Atlas 800I A2(8*64G) | 64核(arm) | 1 | 50 | bfloat16 | 8 | 58s | ### CogVideoX-2b diff --git a/MindIE/MultiModal/CogVideoX/inference.py b/MindIE/MultiModal/CogVideoX/inference.py index 76db866f4cec6b6299ab96b1b7d5e5f29229b153..a5d878ac1a2f147c9b3eeeaef2766f588a367c4e 100644 --- a/MindIE/MultiModal/CogVideoX/inference.py +++ b/MindIE/MultiModal/CogVideoX/inference.py @@ -129,6 +129,22 @@ def generate_video( skip_strategy = AdaStep(skip_thr=0.009, max_skip_steps=1, decay_ratio=0.99, device="npu") pipe.skip_strategy = skip_strategy + if cache_algorithm == "attention": + steps_count = num_inference_steps + blocks_count = pipe.transformer.num_layers + config = CacheConfig( + method="attention_cache", + blocks_count=blocks_count, + steps_count=steps_count, + step_start=15, + step_end=45, + step_interval=3 + ) + agent = CacheAgent(config) + pipe.transformer.use_cache = True + for block in pipe.transformer.transformer_blocks: + block.cache = agent + video_path = f'{output_path}/generated_video_{i}_{prompt[:10]}.mp4' export_to_video(video_generate, video_path, fps=fps) result[os.path.abspath(video_path)] = prompt