perf(lingbot): decouple condition prefetch from control ingress#18
Open
ActivePeter wants to merge 2 commits into
Open
perf(lingbot): decouple condition prefetch from control ingress#18ActivePeter wants to merge 2 commits into
ActivePeter wants to merge 2 commits into
Conversation
- prefetch two bounded condition chunks before control arrival - refill conditions after denoise to overlap with decode - anchor scheduler latency at control acceptance - enforce ordered control submission and add regression tests - document the final pipeline and timing comparison Verified: - 1045 unit tests passed, 13 skipped - 4-GPU chunk mean improved from 1.8010s to 1.4476s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LingBot Condition Prefetch PR Description
Core design
/mnt/ceph/zyc/TeleFuser/docs/zh/design_lingbot_condition_prefetch.mdProposed PR Title
English
Description
Reduce LingBot-World-Fast control-to-output latency by moving condition encoding off the interactive control critical
path.
The runtime now prefetches a bounded number of condition chunks before control arrival and refills the window after
denoising. This preserves the original model computation, output ordering, and numerical path.
The PR also fixes two issues discovered by the example regression:
torch.inference_mode();examples/run_examples.pydid not explicitly close pipeline-owned workers.Motivation
Condition encoding depends on the session image and chunk position, but not on the interactive control input.
Previously, each condition request was submitted together with its control, serializing:
Prefetching conditions allows control processing to join an already prepared condition while retaining strict sequence
ordering and bounded memory usage.
Type of Change
Changes Made
latency_anchor_artifactso control latency starts at control acceptance rather than condition prefetch.torch.inference_mode().No model weights, diffusion steps, dtype, attention implementation, VAE numerical path, service schema, environment
variable, or user-facing configuration is changed.
Testing
Commands:
python -m ruff check \ examples/run_examples.py \ telefuser/pipelines/lingbot_world_fast/streaming.py \ tests/unit/pipelines/lingbot_world_fast/test_streaming.py \ tests/unit/test_run_examples.py python -m pytest -q \ tests/unit/pipelines/lingbot_world_fast \ tests/unit/test_run_examples.py python -m pytest -q tests/unit tests/server \ -m "not gpu and not distributed and not slow and not quant" CUDA_VISIBLE_DEVICES=4 \ python examples/run_examples.py \ --pipeline lingbot_world_fast_i2v \ --verboseResults:
103 passed813 passed, 2 skipped, 307 deselectedPASS9832x46450.38 GiBPSNR=inf,SSIM=1.0000The PSNR/SSIM comparison validates fixed-seed determinism against the first post-fix output; no historical example
baseline was available.
Plain
pytest tests/is not used as the completion criterion because the existingtests/integration/test_pp_forward_consistency.pyrequires two distributed ranks but initializes only rank 0 wheninvoked directly by pytest. The repository's CI marker scope shown above was used instead.
Performance Impact
Measured with 4x H100,
chunk_size=3, and SageAttention SM90:Mean chunk latency decreased by approximately
19.6%.AIPerf run ID:
Trade-offs
A session now allocates its runtime caches and up to two bounded condition slots before the first control arrives.
These resources remain session-owned and are released through the existing reverse-topological cleanup path.
Checklist
Related Issues
N/A
GPU Architecture Support
No kernel implementation is changed. Performance validation was performed on NVIDIA H100 (SM90).
中文
变更说明
本 PR 将 condition 编码移出交互控制的关键路径,以降低 LingBot-World-Fast 从控制输入到视频输出的延迟。
运行时会在 control 到达前有界预取 condition chunk,并在 denoise 完成后补充预取窗口。模型计算、输出顺序和数值
路径均保持不变。
本 PR 同时修复了 example 回归测试发现的两个问题:
torch.inference_mode();examples/run_examples.py未显式关闭 pipeline 持有的 worker。变更动机
Condition 编码仅依赖 session 图像和 chunk 位置,并不依赖用户的交互控制输入。
优化前,每个 condition 请求必须与 control 一起提交,导致以下阶段容易串行执行:
提前预取 condition 后,control 可以直接与已准备好的 condition 汇合,同时继续保证严格的 chunk 顺序和有界内存。
变更类型
主要改动
latency_anchor_artifact,从 control 被接受时开始计算控制延迟,而不是从 condition 预取开始计时。torch.inference_mode()中运行。本次改动不改变模型权重、扩散步数、dtype、attention 实现、VAE 数值路径、服务协议、环境变量或用户配置。
测试验证
执行命令:
python -m ruff check \ examples/run_examples.py \ telefuser/pipelines/lingbot_world_fast/streaming.py \ tests/unit/pipelines/lingbot_world_fast/test_streaming.py \ tests/unit/test_run_examples.py python -m pytest -q \ tests/unit/pipelines/lingbot_world_fast \ tests/unit/test_run_examples.py python -m pytest -q tests/unit tests/server \ -m "not gpu and not distributed and not slow and not quant" CUDA_VISIBLE_DEVICES=4 \ python examples/run_examples.py \ --pipeline lingbot_world_fast_i2v \ --verbose测试结果:
103 passed813 passed, 2 skipped, 307 deselectedPASS9832x46450.38 GiBPSNR=inf、SSIM=1.0000PSNR/SSIM 用于验证修复后固定 seed 重复运行的确定性;测试环境中没有可用的历史 example 基线,因此该结果不表示
与历史提交的画质对比。
未将直接执行
pytest tests/作为完成标准,因为仓库现有的tests/integration/test_pp_forward_consistency.py需要两个分布式 rank,但由 pytest 直接执行时只初始化 rank 0。因此采用了上面与仓库 CI 一致的 marker 范围。
性能影响
测试环境为 4x H100、
chunk_size=3、SageAttention SM90:Chunk 平均延迟降低约
19.6%。AIPerf Run ID:
代价与影响
Session 现在会在第一个 control 到达前分配 runtime cache,并持有最多两个有界 condition slot。这些资源仍属于各自
session,并通过现有的逆拓扑 cleanup 流程释放。
检查清单
关联 Issue
无。
GPU 架构支持
本 PR 未修改 kernel 实现,性能验证在 NVIDIA H100(SM90)上完成。
Suggested Commit Summary
The follow-up fix commit can use: