Skip to content

[feat] Add LingBot-World v2 causal-fast streaming support#11

Merged
lzx1413 merged 8 commits into
mainfrom
lingbot_world_v2
Jul 15, 2026
Merged

[feat] Add LingBot-World v2 causal-fast streaming support#11
lzx1413 merged 8 commits into
mainfrom
lingbot_world_v2

Conversation

@lzx1413

@lzx1413 lzx1413 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Description

Add LingBot-World v2 support on top of the shared causal-fast runtime, including offline image-to-video generation, four-GPU bidirectional WebRTC streaming, and v2-focused documentation.

Motivation

LingBot-World v2 uses a different public checkpoint layout and causal-fast defaults from v1. This PR integrates v2 without duplicating the runtime, aligns shared inference behavior with the reference implementation, and reduces streaming memory growth for long sessions.

Type of Change

  • Bug fix
  • New feature
  • Performance improvement
  • Code refactoring
  • Documentation update

Changes Made

  • Add a session-owned VAE encoder cache alongside the existing decoder cache; encode conditioning video incrementally per chunk and reset cache state after the final chunk.
  • Align the shared LingBot causal-fast runtime with the reference implementation:
    • tensor-space bicubic image preprocessing
    • VAE/text precision handling
    • configurable timestep selection and stricter checkpoint validation
    • incremental noise and condition-latent generation instead of duration-sized chunk lists
    • centralized frame alignment and derived chunk completion
  • Add LingBotWorldV2Pipeline with public checkpoint validation, camera-control enforcement, offline v2 example, and four-GPU v2 streaming example.
  • Configure v2 streaming for camera control, Torch SDPA, chunk_size=4, and a two-minute session limit.
  • Simplify the WebRTC demo so LingBot generation parameters come from the service PPL configuration instead of duplicated browser-side controls.
  • Update English and Chinese README content and add a News entry linking to LingBot-World v2.

Testing

  • Focused unit tests pass
  • Manual offline and streaming testing performed
  • Benchmarks added/updated

Test commands:

.venv/bin/python -m pytest tests/unit/pipelines/lingbot_world_fast tests/unit/pipelines/lingbot_world_v2 -q
# 61 passed

.venv/bin/python -m compileall -q \
  examples/lingbot \
  telefuser/pipelines/lingbot_world_fast/service.py

git diff --check

Manual validation:

  • Generated v1 offline output on four H100 GPUs: 81 frames.
  • Generated v2 offline output on four H100 GPUs: 77 frames.
  • Started the four-GPU v2 WebRTC service and connected the browser demo through TURN relay.

Checklist

  • Code follows the project's coding standards (ruff)
  • Commit hooks pass
  • Pre-commit hooks pass for all files (pre-commit run --all-files not run)
  • All repository tests pass (pytest tests/ not run)
  • New tests added for new functionality
  • Documentation updated (README, CLAUDE.md, docstrings)
  • Commit messages are clear and descriptive
  • PR title follows the convention: [TYPE] Brief description

Related Issues

N/A

Additional Notes

  • The v2 streaming PPL allows sessions up to 120 seconds. At 16 FPS with chunk_size=4, this resolves to 1917 output frames (119.75 seconds) to preserve complete latent chunks.
  • The two-minute limit is a configured ceiling; actual memory capacity still depends on resolution and concurrent GPU workloads.
  • No custom kernels were modified.

GPU Architecture Support

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

Performance Impact

Long-running LingBot sessions no longer retain duration-sized noise and VAE condition chunk lists. Conditioning VAE encoding is incremental and cache state is session-owned, reducing session memory growth and preserving isolation between concurrent sessions.

lzx1413 added 5 commits July 15, 2026 13:43
- add an encoder cache state alongside the existing streaming decoder state\n- encode first and subsequent temporal chunks incrementally with cache ownership kept by the caller\n- reset encoder cache state after the final chunk\n\nVerification:\n- .venv/bin/python -m pytest tests/unit/pipelines/lingbot_world_fast tests/unit/pipelines/lingbot_world_v2 -q\n- .venv/bin/python -m compileall -q examples/lingbot telefuser/pipelines/lingbot_world_fast/service.py\n- git diff --check
- match source image preprocessing, VAE precision, timestep selection, and checkpoint validation\n- generate noise and VAE conditioning incrementally instead of retaining duration-sized chunk lists\n- derive completion from the chunk boundary and centralize frame alignment policy\n- move stream defaults into PPL configuration while preserving service-side session defaults\n- cover preprocessing parity, runtime lifecycle, and service action loop behavior\n\nVerification:\n- .venv/bin/python -m pytest tests/unit/pipelines/lingbot_world_fast tests/unit/pipelines/lingbot_world_v2 -q\n- .venv/bin/python -m compileall -q examples/lingbot telefuser/pipelines/lingbot_world_fast/service.py\n- git diff --check
- add a v2 facade that validates the public checkpoint layout and camera-only control projection\n- provide v2 offline and four-GPU streaming examples with v2 PPL defaults\n- set the v2 streaming duration ceiling to two minutes while preserving the shared service behavior\n- document the shared streaming-state ownership and fixed offline frame presets\n- cover v2 PPL mapping, service defaults, and offline CLI forwarding\n\nVerification:\n- .venv/bin/python -m pytest tests/unit/pipelines/lingbot_world_fast tests/unit/pipelines/lingbot_world_v2 -q\n- .venv/bin/python -m compileall -q examples/lingbot telefuser/pipelines/lingbot_world_fast/service.py\n- four-GPU offline v2 smoke generation completed\n- git diff --check
- hide redundant generation and control tuning fields from the browser page\n- stop forwarding client-side LingBot defaults so the service PPL configuration is authoritative\n- preserve optional browser FPS forwarding when explicitly configured\n\nVerification:\n- .venv/bin/python examples/stream_server/webrtc_bidirectional_demo.py --help\n- launched the demo against the four-GPU LingBot v2 stream service\n- git diff --check
- announce LingBot-World v2 support with the upstream project link\n- point English and Chinese quick-start commands to the v2 streaming service\n- refresh the LingBot example guide for v2 offline generation, WebRTC interaction, and multi-GPU inference\n\nVerification:\n- git diff --check\n- checked v1 example command references are absent from the updated READMEs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds LingBot-World v2 support by introducing a v2 pipeline facade on top of the shared LingBot “causal-fast” runtime, while refactoring the shared runtime to generate/encode incrementally per chunk (reducing long-session memory growth) and updating streaming/offline examples plus documentation.

Changes:

  • Introduce LingBotWorldV2Pipeline + public-checkpoint validation and add v2 offline + 4-GPU bidirectional streaming examples.
  • Refactor LingBot causal-fast runtime to be chunk-incremental (noise generation + VAE conditioning encode cache), add frame_policy, and make timestep selection configurable/validated.
  • Simplify the WebRTC demo and update English/Chinese READMEs + project documentation notes.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/pipelines/lingbot_world_v2/test_service.py Adds unit tests validating v2 example/service wiring and CLI forwarding.
tests/unit/pipelines/lingbot_world_fast/test_service_action_loop.py Updates action-loop test expectations for new done semantics.
tests/unit/pipelines/lingbot_world_fast/test_runtime_baseline.py Updates baseline runtime tests for incremental noise/condition handling and v1/v2 shared contracts.
tests/unit/pipelines/lingbot_world_fast/test_pipeline_call.py Updates pipeline-call tests to use session status (RELEASED) and done completion.
telefuser/service/api/stream_schema.py Changes WebRTC offer request fps default to None.
telefuser/pipelines/lingbot_world_v2/pipeline.py Adds v2 pipeline facade + checkpoint layout/shape validation.
telefuser/pipelines/lingbot_world_v2/init.py Exports v2 pipeline symbols.
telefuser/pipelines/lingbot_world_fast/session.py Adds frame_policy, per-session noise generator + VAE encoder cache state, and chunk_count property.
telefuser/pipelines/lingbot_world_fast/service.py Adds session default config plumbing, duration-based frame calculation, and max_generation_seconds enforcement.
telefuser/pipelines/lingbot_world_fast/pipeline.py Refactors image preprocessing, per-chunk condition encoding, per-chunk noise generation, and timestep plumbing.
telefuser/pipelines/lingbot_world_fast/denoising.py Adds validated timestep selection and autocast around DiT calls.
telefuser/pipelines/lingbot_world_fast/control.py Simplifies deferred control handling to plain callables.
telefuser/pipelines/lingbot_world_fast/init.py Updates exports after timesteps refactor.
telefuser/models/wan_video_vae.py Adds session-owned incremental VAE encode cache + cached encode method.
telefuser/models/lingbot_world_fast_dit.py Tightens checkpoint validation/loading, adjusts dtype handling and output casting.
README.md Updates news and streaming demo docs to reference LingBot-World v2.
README_zh.md Chinese README updates mirroring v2 additions.
examples/stream_server/webrtc_bidirectional_demo.py Removes browser-side LingBot parameter controls and stops always sending fps.
examples/lingbot/stream_lingbot_world_v2.py Adds v2 streaming service example with PPL-configured defaults + 2-minute cap.
examples/lingbot/stream_lingbot_world_fast.py Updates v1 streaming example to use service-side defaults config.
examples/lingbot/README.md Updates LingBot examples README to cover v1 + v2 and fixed frame counts per PPL config.
examples/lingbot/lingbot_world_v2_image_to_video_h100.py Adds v2 offline camera-controlled example + CLI.
examples/lingbot/lingbot_world_fast_image_to_video_h100.py Updates v1 offline example to align with new session config defaults and removes CLI frame_num override.
CLAUDE.md Documents LingBot streaming state constraints and adds pipeline directory entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread telefuser/pipelines/lingbot_world_fast/service.py Outdated
Comment thread telefuser/pipelines/lingbot_world_fast/pipeline.py
Comment thread telefuser/service/api/stream_schema.py
lzx1413 added 3 commits July 15, 2026 14:20
- preserve explicitly supplied zero values instead of falling back through truthiness defaults\n- reject non-positive FPS, chunk size, and duration before frame-count calculation\n- guard the duration-to-frame helper against invalid direct callers\n- cover zero and negative client parameters, including explicit frame-count requests\n\nVerification:\n- .venv/bin/python -m pytest tests/unit/pipelines/lingbot_world_fast/test_service_action_loop.py tests/unit/pipelines/lingbot_world_v2/test_service.py -q\n- .venv/bin/python -m compileall -q telefuser/pipelines/lingbot_world_fast/service.py tests/unit/pipelines/lingbot_world_fast/test_service_action_loop.py\n- git diff --check
- write the effective truncate-policy frame count back to the shared session configuration\n- normalize explicit service frame requests before duration validation\n- keep control truncation, latent chunk counts, and service duration checks aligned\n- cover runtime and service regressions for a 13-frame request truncated to 9 frames\n\nVerification:\n- .venv/bin/python -m pytest tests/unit/pipelines/lingbot_world_fast/test_service_action_loop.py tests/unit/pipelines/lingbot_world_fast/test_runtime_baseline.py tests/unit/pipelines/lingbot_world_v2/test_service.py -q\n- .venv/bin/python -m compileall -q telefuser/pipelines/lingbot_world_fast/service.py tests/unit/pipelines/lingbot_world_fast/test_service_action_loop.py\n- git diff --check
Resolve WebRTC media-track FPS from an explicit request value or the underlying stream service default_fps, rather than forcing 24 FPS when the request omits it. Keep absent FPS out of session configuration so LingBot PPL defaults remain authoritative.\n\nAdd server-push and bidirectional route regressions for service-provided FPS defaults.\n\nVerification:\n- .venv/bin/python -m pytest tests/unit/service/test_service_routes.py tests/unit/pipelines/lingbot_world_fast/test_service_action_loop.py tests/unit/pipelines/lingbot_world_v2/test_service.py -q\n- git diff --check
@lzx1413
lzx1413 merged commit 4a601c5 into main Jul 15, 2026
5 checks passed
@lzx1413 lzx1413 mentioned this pull request Jul 15, 2026
21 tasks
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.

2 participants