Skip to content

[PERF] Unify distributed communication for real-time LingBot-World v2 - #22

Merged
lzx1413 merged 11 commits into
mainfrom
optimize_lingbotv2
Aug 3, 2026
Merged

[PERF] Unify distributed communication for real-time LingBot-World v2#22
lzx1413 merged 11 commits into
mainfrom
optimize_lingbotv2

Conversation

@lzx1413

@lzx1413 lzx1413 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR optimizes TeleFuser's multi-GPU communication and LingBot-World v2 streaming pipeline to support real-time
four-H100 generation.

It introduces direct tensor channels between worker groups, centralizes distributed collectives, adds spatially
sharded VAE decoding, keeps bounded session data resident on GPU, and removes redundant work from the streaming DiT
path. It also improves CPU-only CI coverage and documents the validated four-GPU performance envelope.

Motivation

Large intermediate tensors previously crossed worker and orchestration boundaries through paths that introduced
avoidable synchronization, copies, and CPU involvement. LingBot-World v2 also repeated condition preparation,
device transfers, and cache-related work across chunks.

These costs prevented the four-GPU pipeline from consistently meeting its 16 FPS target. The new communication and
residency design keeps large tensors on their producer/consumer devices, overlaps independent communication where
possible, and reduces per-chunk computation without changing the public pipeline contract.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement
  • Code refactoring
  • Documentation update
  • Other (please describe):

Changes Made

  • Added WorkerTensorChannel for direct worker-to-worker tensor transfer using pooled CUDA IPC/P2P buffers or shared
    CPU storage, including lifecycle, cancellation, acknowledgement, sharding, and fallback handling.
  • Centralized high-throughput collectives under telefuser.distributed, submitting independent communication before
    synchronization and reusing the same primitives across sequence-parallel paths.
  • Added four-GPU spatial VAE decoding with height sharding and halo exchange, colocated with DiT workers to avoid
    orchestrator-mediated latent transfers.
  • Kept reference-image conditions, RoPE tables, scheduler inputs, KV state, and reusable output buffers resident for
    the bounded session lifetime.
  • Optimized LingBot normalization, modulation, attention dispatch, denoising, cache updates, and streaming lifecycle.
  • Hardened tensor handoff and deterministic SDPA regression paths, and added focused unit/integration coverage.
  • Updated local CI to enforce CPU-only execution without requiring installation of a separate CPU PyTorch build.
  • Added reproducible direct and one-minute AIPerf benchmark workflows and bilingual communication/performance docs.

Testing

  • Full test suite executed with exactly pytest tests/
  • Manual testing performed
  • Benchmarks added/updated

Test commands:

# GitHub-compatible CPU CI
bash scripts/run_ci_tests.sh --skip-install
# Result: 940 passed, 3 skipped, 95 deselected; server suite: 62 passed

# Focused communication and LingBot tests
python -m pytest <focused communication and LingBot test selection>
# Result: 58 passed

# Four-GPU direct real-time gate
CUDA_VISIBLE_DEVICES=0,1,2,3 \
python tools/validation/benchmark_lingbot_world_v2_direct.py \
  --pipeline examples/lingbot/lingbot_world_v2_image_to_video_h100.py \
  --image examples/data/lingbot_world_fast/image.jpg \
  --control-trace benchmarks/telefuser_aiperf/data/stream_lingbot_controls.json \
  --output work_dirs/lingbot_world_v2_4gpu_77frames.json \
  --gpu-num 4 --frame-num 77 --fps 16 --chunk-size 4

# One-minute LiveKit/AIPerf replay
bash benchmarks/telefuser_aiperf/scripts/run_stream_bench.sh
# Result: 1/1 session succeeded; 957 target frames in 60 chunks

# Documentation
python -m mkdocs build --strict
git diff --check

GPU regression coverage also exercised the previously failing example cases. Wan pipeline-parallel behavior is
unchanged and remains outside this PR's scope.

Checklist

  • Code follows the project's coding standards (ruff)
  • pre-commit run --all-files executed on the final HEAD
  • Full pytest tests/ suite executed
  • New tests added for new functionality
  • Documentation updated
  • Commit messages are clear and descriptive
  • PR title follows the convention: [TYPE] Brief description

Related Issues

N/A

Additional Notes

The public pipeline and service contracts remain compatible. Optimized tensor transport is method-scoped and retains
fallback behavior where direct CUDA transfer is unavailable.

Target compute and client delivery metrics are intentionally reported separately. LiveKit pacing, encoding, network
delivery, and client rendering are not included in chunk_compute_fps.

GPU Architecture Support

  • SM80 (Ampere, Ada Lovelace)
  • SM90 (Hopper H100)
  • SM100+ (Blackwell)

The new kernel and four-GPU paths were validated on H100/SM90. Other architectures have not been validated as part of
this PR.

Performance Impact

Validated on 4 x H100 80 GB, PyTorch 2.11.0+cu128, BF16 DiT, FP32 VAE, FlashAttention-4, with FSDP and
torch.compile disabled:

  • 77-frame direct gate: 17.1399 steady compute FPS at 832x480 against a 16 FPS target.
  • Steady chunk mean/p50/p90/max: 0.9335 / 0.9409 / 0.9410 / 1.0058 s.
  • One-minute replay: 16.1979 steady compute FPS, completing all 957 target frames and 60 chunks.
  • One-minute chunk p99/max: 1.0932 / 1.1149 s.
  • One-minute LiveKit delivery: 13.1967 stream FPS and 803 client-received frames.

The average target-side compute rate meets the 16 FPS real-time gate. This does not claim that every individual chunk
finishes within one second or that end-to-end client delivery sustains 16 FPS.

lzx1413 added 11 commits July 31, 2026 09:04
Fuse normalization and modulation kernels, reuse LingBot model inputs and projected session data, and reduce redundant RoPE and KV bookkeeping across denoising steps.

Keep FA4 return-LSE dispatch compatible and prefer tf-kernel RMSNorm when available. Add focused regression coverage for the optimized ops, cache invalidation, and denoising lifecycle.
Shard Wan VAE decode over height with halo exchange, colocate four-GPU decode with the DiT workers, and reuse local latent and shared CPU output buffers.

Serialize overlapping DiT/decode collectives, streamline worker queues and thread pools, preserve synchronized phase profiles, and keep the documented four- and six-GPU placements covered by tests.
Record decoded-ready, LiveKit publish, and client metadata timing separately, wait for the controller before pipeline startup, and finish adapter sessions from target completion status.

Keep the reproducible TeleFuser and SGLang benchmark launchers, add a direct-output validation path, and document the H100 environment, workload semantics, and compute-versus-delivery metric boundary without embedding comparison results.
Transport tensor outputs between independent worker groups with metadata references while CUDA IPC or shared memory carries the storage directly. Move final device placement into consumer ranks and allow method-scoped tensor transport without routing payloads through the parent process.\n\nDocument the channel lifecycle and cover FIFO, cancellation, CPU sharing, CUDA peer copies, and ParallelWorker bindings.\n\nVerification: focused worker unit tests and the two-GPU tensor-channel integration test passed; ruff and git diff --check passed.
Encode the bounded reference image once per session, distribute its latent directly to every DiT rank, and retain it for rank-local chunk slicing and mask construction. Connect non-colocated DiT and VAE stages through the generic tensor channel so large latents bypass the orchestrator.\n\nKeep scheduler timesteps and immutable RoPE frequency tables resident on worker devices, include condition memory in capacity accounting, and preserve the configured two-session capacity.\n\nVerification: 185 related unit tests and the full 957-frame four-GPU AIPerf runs passed; ruff, format check, and git diff --check passed.
Document the complete 957-frame TeleFuser runs in the cu128 and cu130 environments and compare target-side compute against the retained same-environment SGLang artifact. Keep client stream throughput separate because LiveKit uses realtime pacing while the WebSocket reference uses burst output.\n\nRecord synchronized compute time, first-frame decomposition, transport boundaries, warmup semantics, and artifact identifiers in both English and Chinese benchmark guides.\n\nVerification: both documented TeleFuser sessions completed 60 chunks successfully; git diff --check passed.
Force example regression runs onto TORCH_SDPA and disable Diffusers' optional xformers import path so the test backend is deterministic.

Route Wan2.2 VAE and denoising tensors through WorkerTensorChannel, add lifecycle coverage, and document the regression backend. Verified with focused unit and worker tests plus the four previously failing GPU regression cases.
Centralize process-group collectives and submit independent communication before synchronization across sequence-parallel model paths.

Harden worker tensor channels with pooled CUDA IPC buffers, rank-local sharding, generation acknowledgements, cancellation cleanup, and resident LingBot condition/latent handoff.

Document the communication architecture in English and Chinese, and add focused unit, integration, and SGLang comparison coverage.

Verification:\n- ruff check on changed Python files\n- pytest focused communication and LingBot suites (58 passed)\n- mkdocs build --strict\n- LingBot World V2 four-GPU 77-frame benchmark and example
Allow the local CI entry point to reuse an existing environment while explicitly hiding CUDA and binding pytest to the active Python interpreter.

Make the RayWorker resource test simulate its CUDA branch so it remains deterministic on GitHub CPU runners.

Verification:\n- bash scripts/run_ci_tests.sh --skip-install\n- unit tests: 940 passed, 3 skipped, 95 deselected\n- server tests: 62 passed\n- ruff check, format, and import checks
Publish the validated four-H100 LingBot-World v2 real-time gate in the project and example READMEs. Consolidate the bilingual AIPerf benchmark documentation around the 77-frame compute gate and the current one-minute LiveKit replay, including exact metric boundaries and reproducible commands. Remove stale NEW labels from the LingBot-Video news entries.

Verification: AIPerf one-minute stream profile 1/1 succeeded; mkdocs build --strict; git diff --check.
@lzx1413
lzx1413 merged commit 24af975 into main Aug 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant