-
Notifications
You must be signed in to change notification settings - Fork 46
Omnidreams: live mid-stream editing — prompt hot-swap, edit guidance, actor spawn/despawn #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wenqingw-nv
wants to merge
10
commits into
NVIDIA:main
Choose a base branch
from
wenqingw-nv:omnidreams-live-edit-pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bb756d8
Add mid-stream text-edit path to Omnidreams (hot-swap, guidance, ReCa…
wenqingw-nv af295f9
Add live prompt events and actor spawning to the Omnidreams WebRTC demo
wenqingw-nv a2b2c80
Add live-edit GPU probe scripts and the guidance-distillation plan
wenqingw-nv d587d65
Ground spawned actor boxes on the road plane
wenqingw-nv 5badb78
Add spawn yaw-offset argument for actor heading control
wenqingw-nv c6a55ce
Add the guidance self-distillation trainer (Tier-2a)
wenqingw-nv 70971f6
Deploy the distilled text-edit LoRA (pre-merged, window-gated)
wenqingw-nv 5541985
Make ReCache RNG-neutral via a dedicated seeded generator
wenqingw-nv 5e0c0bb
Fix CI: port probe scripts to runner_io; defer the trainer scripts
wenqingw-nv 4341487
Add /spawnt template spawner: clone real parked tracks to user targets
wenqingw-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Guidance self-distillation (Tier-2a of the live-edit hack) | ||
|
|
||
| **Goal:** bake the two-prompt text-edit guidance (`TextEditGuidance`, s≈3) into a LoRA so | ||
| a *plain* mid-stream prompt swap responds like a *guided* one — recovering the ~2x edit | ||
| strength at **zero inference cost** (guidance doubles the DiT forwards while active). | ||
|
|
||
| **Why it should work:** the teacher and student are the same network; the target is the | ||
| network's own guided output on RNG-matched on-policy states. This is standard | ||
| CFG-distillation, except the "CFG" here is the old-prompt/new-prompt axis and it only | ||
| matters for a few chunks after a swap. No external data or models needed. | ||
|
|
||
| ## Recipe (on-policy, mirrors `drift_correction/train_v2.py`) | ||
|
|
||
| Per training step: | ||
|
|
||
| 1. **Sample** a clip (32 local HF samples, `drift_correction/build_pairs._sample_files`), | ||
| a swap chunk `k ~ U[4, 20]`, and an edit prompt from the bank. | ||
| 2. **Roll the student** (LoRA active, plain swap at `k`) with the KV cache to a random | ||
| chunk `j >= k` — self-forcing-style on-policy states. History replay machinery: | ||
| `drift_correction/_host.py` (`reset_history`, `replay_history`, bracket helpers). | ||
| 3. **At chunk `j`, per denoise step** (timesteps 1000, 450): | ||
| - Teacher flow = frozen base (LoRA scale 0) with the guidance combine | ||
| (`kv_old`/`kv_new` loads + `flow_old + s*(flow_new - flow_old)`) — i.e. exactly | ||
| `CosmosTransformer._predict_with_text_edit_guidance` on unwrapped weights. | ||
| - Student flow = LoRA'd network, single branch, new-prompt KV only. | ||
| - Loss = MSE(student, teacher) in v-space; optionally also the context forward | ||
| (t=128) so committed history matches. | ||
| 4. **Backprop** through the student's step only (history detached — the KV buffer write | ||
| severs grads anyway; use `_train_attn.py` functional dual-branch attention + | ||
| per-block `torch.utils.checkpoint`, both proven on this host). | ||
|
|
||
| **LoRA config:** start from the drift-corrector recipe — r16 on | ||
| `blocks.*.self_attn.{q,k,v,output}_proj` — and add `cross_attn.{q,k,v,output}_proj` | ||
| (the edit signal enters through cross-attn; likely where the capacity is needed). | ||
| `_lora.py:apply_lora` handles both via substring match. | ||
|
|
||
| **Prompt bank (v1):** the weather/lighting set from `scripts/sweep_text_edit.py` | ||
| (incl. scene-native snow/rain phrasings) + per-clip base prompts as "no-op edits" | ||
| (swap to the same prompt → teacher == plain flow → regularizes against drift). | ||
| Precompute all text embeddings once (`pipeline.precompute_embeddings` pattern) so the | ||
| 14 GB text encoder is not resident during training. | ||
|
|
||
| ## Deployment: gate the LoRA like the guidance countdown | ||
|
|
||
| Enable the LoRA **only for the N chunks after a swap** — the exact window | ||
| `TextEditGuidance.chunks_remaining` covers today — via the drift corrector's per-chunk | ||
| gating + premerge pattern (`_drift_corrector.py`; premerged weight swaps cost ~0 ms). | ||
| Outside the window the base weights run untouched, so non-edit behavior carries zero | ||
| regression risk by construction. | ||
|
|
||
| ## Eval / kill gate | ||
|
|
||
| - Reuse `scripts/sweep_text_edit.py`: (LoRA + plain swap) vs (base + guided) divergence | ||
| curves on held-out clips x prompts; eyeball grids. | ||
| - Pass: LoRA plain-swap reaches >=80% of guided divergence at matched chunks, with | ||
| no MUSIQ drop on no-swap rollouts (drift eval harness `eval_rollouts.py`). | ||
| - Budget: ~1k steps eager w/ checkpointing; hours on the shared GB300 (fits the | ||
| ~65 GB share; full card is comfortable). | ||
|
|
||
| ## Open choices | ||
|
|
||
| - Distill a *fixed* s (3.0) vs conditioning on s (start fixed; the wrapper default | ||
| becomes "swap = guided-strength swap"). | ||
| - Whether to include ReCache in the teacher rollout (probably yes — it is on by | ||
| default in serving). | ||
| - Later (Tier-2b): extend the same loop with object/appearance edit pairs from | ||
| JoyAI-Video-Edit to push beyond what guidance alone can reach. |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.