Repository navigation
Unsloth Studio: Cosmos3-Nano video continuation (extend a clip from its last or first frames) - #16741
Conversation
…e picker Edge and Nano gain the pipeline's 256p tier (320x192, 192x320, 256x256, 320x256, 256x320) and Nano the 480p sizes it lacked, so the custom-size floor drops to 61,440 px and NVIDIA's 448x256 is accepted. VideoFamily gains fps_range / fps_choices: Edge 12-30 (model card), Nano 10, 16, 24, 30 (NVIDIA/cosmos models.md). The status defaults carry them with the frame window, the request is refused outside them, and the Video page shows a picker instead of the fixed label for those families only. Durations, the pipeline fps and the mp4 follow the chosen rate.
… or last frames) Nano's pipeline takes video= and keeps 5 frames from one end of it. Studio now decodes an uploaded clip with PyAV, resamples it onto the output frame rate, centre-crops it to the canvas aspect and passes video= and condition_video_keep (default last). Gated on a supports_video_continuation family flag set only on Nano; Edge and every other family refuse the field. The Video page gets a Continue a clip section with a preview and a first/last choice.
…smos3-nano-video-continuation
…nly when both are omitted
… absent Backend CI installs no diffusers, so the unguarded import failed the rest shard. The preset assertions don't need diffusers and now always run; the comparison against the pipeline's bins moves to its own test behind importorskip.
|
Backend CI installs no diffusers, so the other diffusers tests in this file start with The |
A variable-frame-rate clip was resampled by decoded-frame index at the stream's average rate, so the 5 kept frames could stand for uneven intervals. Each frame now covers the output ticks from its timestamp to the next frame's.
…tamps too The cap was a frame count at the stream's reported rate, so a variable-frame-rate clip whose rate overstates its timestamps could span past 15 s. Test added.
…ed-load retry (#16768) ## Summary `Chat UI Tests (extra)` fails on unrelated PRs several times a day at the same place, for example #16722, #16741 and the staging run for #16750: ``` File "tests/studio/playwright_multi_account.py", line 173, in run open_login(page) File "tests/studio/playwright_multi_account.py", line 67, in open_login page.goto(url) playwright._impl._errors.TimeoutError: Page.goto: Timeout 30000ms exceeded. Call log: - navigating to "http://127.0.0.1:18894/login", waiting until "load" ``` #16437 added a recorded retry for exactly this stalled `/login` load, but it never runs in these failures. None of the failing logs print its `WARN: /login did not fire load ...` line, and the whole step lasts about 33 s, i.e. one 30 s timeout. `open_login` gives aborts and timeouts one shared two-attempt budget: right after a log-out the app's own 401 redirect (`redirectToAuth`) aborts the first `goto` with `ERR_ABORTED`, which spends attempt 1, and the stalled load then happens on attempt 2, where it is fatal. ## Change `tests/studio/playwright_multi_account.py`, `open_login` only: - Aborts and timeouts each get their own single retry, so an abort can no longer use up the retry #16437 added for a stalled load. A second abort, a second timeout, or any other error still fails the run as before. - When the abort came from the app's redirect and that redirect has already loaded `/login`, the page is used as it is instead of navigating to `/login` a second time. A redirect that ends anywhere else (for example `/change-password`) still navigates to `/login`. Nothing outside this Playwright driver changes. `tests/studio/test_playwright_multi_account_open_login.py` drives `open_login` with a scripted page and the real Playwright error types: | goto outcomes | expected | |---|---| | abort, redirect already on `/login` | returns after one goto | | abort elsewhere, timeout, load | returns after the third goto (the CI failure) | | abort to `/change-password`, load | navigates to `/login` | | two aborts / two timeouts / abort then two timeouts | raises | | an error other than an abort | raises, no retry | ## Testing - New test: 7 passed. Against the driver on main: 3 failed, including `test_a_timeout_after_an_abort_still_gets_its_retry`, the sequence the CI logs show. - `tests/test_ci_repo_cpu_shards.py`, `tests/studio/test_playwright_suites_run_in_ci.py` and `tests/studio/test_pwsh_calls_use_the_shared_runner.py` pass. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
A frame count still offered at the new rate was kept, so Nano at 2 s (49 frames) became 4.9 s at 10 fps.
…a clip over 15 s at pick time Picking a clip to continue silently dropped a staged start frame (and the reverse); a toast now says which one went. A clip longer than the backend's 15 s cap is flagged under its preview instead of only failing at Generate. The first/last hint now uses the same words as the options. Tests added.
Loading a model that cannot continue a clip removed a staged clip without a word; a toast now says it went, like the start-frame and clip swaps. Test updated.
…ource; plain short-clip message A start frame switched the aspect ratio to Match source, but a clip to continue left whatever size was picked and was centre-cropped onto it, while the backend already matches the clip's aspect when the size is omitted. The clip now drives Match source the same way. The too-short refusal now reads "This clip has N frames at F fps, and continuing it needs at least 5" without the decode count. Tests added.
Driving a switch from Cosmos3-Nano to Cosmos3-Edge in the model picker showed the toast never reaches the screen: it fires while the load is finishing and the load's own toasts replace it. The clip is still removed, as before 6e1ec4e.
|
Codex is clean at this head ( Fork mirror CI at
|
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… reset to the family default when the preset has none
…mid-load waits for the incoming family
…en the load settles
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # studio/backend/tests/test_media_generation_preset_settings.py
# Conflicts: # studio/backend/tests/test_video_shape_validation.py
…rame-rate picker (#16737) **#16741 (Nano video continuation) is stacked on this PR. Merge this one first.** Lets Unsloth Studio's Cosmos3 Edge and Nano families take the generation settings NVIDIA's model cards list, so the release doc can quote NVIDIA's numbers and Unsloth Studio accepts them. **UI**: the Video page on a Colab G4, main `590119de67` (BEFORE) vs this branch (AFTER), light and dark theme set from Settings, driven with headless Chromium. Shots at `a012d267c0` unless labelled; the two commits after it touch only the duration snap and the picker text.  Durations follow the picked rate and stay inside the frame window. Changing the rate keeps the length you picked, not the frame count (fixed in `74671433c6`: at `a012d267c0`, Nano at 2.0 s became 4.9 s at 10 fps, and Edge at 3.0 s became 6.1 s at 12 fps).  An out-of-range rate is refused with a toast instead of starting a job (the page's own request with `fps` rewritten to 31; the controls never send one), and restoring a clip brings its rate back.   Also checked, nothing to change: the Trained sizes list shows the five 256p sizes on Edge and Nano; the slider takes arrow keys (24 to 25 moves the duration to 3.1 s); a family without a picker keeps the "24 fps" label; at 1024 and 768 px the rail reflows without clipping. Not driven: switching models with a rate picked. **What changed** | | before (`590119de67`) | after | |---|---|---| | Edge sizes | 480p only (832x480, 480x832, 640x640, 736x544, 544x736) | + the pipeline's 256p tier: 320x192, 192x320, 256x256, 320x256, 256x320 | | Nano sizes | 720p + 832x480 / 480x832 | + 640x640, 736x544, 544x736 and the same 256p tier | | Custom-size floor | 204,800 px on Edge: 448x256 and 320x192 refused with a 422 | 61,440 px: 448x256 (NVIDIA's Jetson T2000 size) is accepted | | Edge frames | 53-149 | unchanged (see below) | | Nano frames | 5-397 | unchanged | | Frame rate | read-only "24 fps, fixed per model"; the API took any 1-120 and passed it through | Edge any integer 12-30, Nano 10 / 16 / 24 / 30, default still 24; anything else refused | - `VideoFamily` gains `fps_range` / `fps_choices` (`video_families.py`). `validate_video_request_shape` refuses a rate outside them with a `VideoShapeError` (422 on `/video/generate`, 400 with `param: fps` on `/v1/videos`). A family that declares neither is never judged, so every other family behaves as before. - Status `defaults` carries `fps_range`, `fps_choices`, `min_num_frames`, `max_num_frames`. - The Video page shows a frame-rate slider (Edge) or dropdown (Nano) instead of the fixed label, only for families that declare one (`video-fps.ts`). Duration options follow the picked rate and stay inside the frame window; the request, the pipeline's `fps` and the mp4 all use it. Restoring a clip's settings restores its rate, and never a frame count the loaded family refuses. Changing the rate keeps the picked length (the nearest offered duration), not the frame count. **Where the numbers come from** - 256p sizes: diffusers `Cosmos3OmniPipeline._ACTION_RESOLUTION_BINS["256"]`, the same table as NVIDIA's `cosmos-framework` `VIDEO_RES_SIZE_INFO["256"]` and `NVIDIA/cosmos` `docs/reference/models.md` ("256p uses 320×192"). The pipeline defines no separate video-generation bins. - Edge: model card, "256p and 480p resolution, 12–30 fps, and 50–150 frames". - Nano fps: the card states no range; `NVIDIA/cosmos` `docs/reference/models.md`, Generation settings: "10, 16, 24, 30 FPS (default 24)". - **Edge keeps its 53-frame minimum.** 53 and 149 are the 4k+1 counts inside the card's 50–150; 49 is outside it. #14554 picked the window for that reason (its test: "Windows: the 4k+1 counts inside") and nothing NVIDIA publishes says 49 is supported. - Nano keeps 397, the largest 4k+1 count at or under the card's 400. (NVIDIA's `models.md` says 5–300; the card says 5–400; this keeps the card's.) **Renders**: Colab G4, NVIDIA RTX PRO 6000 Blackwell Server Edition 96 GB, Linux, driver 580.82.07, torch 2.11.0+cu130, diffusers 0.42.1. Unsloth Studio booted from this branch at `4095020d9f` (backend identical to the head; later commits touch only the restore logic in the page and a test). Seed 0, card steps (Edge 20, Nano 35), CFG 6, bf16 (`transformer_quant: none`). Prompts from our own test set. Each Unsloth Studio render is compared with plain diffusers `Cosmos3OmniPipeline` on the same VM (cudnn.benchmark off, card scheduler, untiled VAE, frames through Unsloth Studio's own x264 encode), decoded frame by frame. | render | Unsloth Studio speed off vs diffusers | Unsloth Studio default load vs diffusers | |---|---|---| | Edge T2V 448x256, 53 f, 24 fps (waves) | identical, 53/53, same mp4 bytes | differs, PSNR 26.8 dB | | Edge T2V 320x192, 53 f, 24 fps (dog) | identical, 53/53 | differs, 27.7 dB | | Edge T2V 832x480, 121 f, **12 fps** (rain) | identical, 121/121 | differs, 16.2 dB | | Edge T2V 832x480, 121 f, **30 fps** (rain) | identical, 121/121 | differs, 18.9 dB | | Edge T2V 832x480, 121 f, 24 fps (rain, existing preset) | identical, 121/121 | differs, 17.4 dB | | Nano T2V 320x192, 189 f, 24 fps (waves) | identical, 189/189 | differs, 28.4 dB | | Nano T2V 448x256, 121 f, **16 fps** (dog) | identical, 121/121 | differs, 24.0 dB | | Edge I2V 832x480, 121 f (bees) | identical, 121/121 | differs, 21.9 dB | | Edge I2V 448x256, 53 f (bees) | identical, 53/53 | differs, 24.6 dB | | Nano I2V 320x192, 121 f (bees) | identical, 121/121 | differs, 20.1 dB | - **Nothing changed for the existing sizes**: the 832x480 / 24 fps clip is byte-identical between base `590119de67` and this branch, at the default load (`9aaba48470dc38af`) and at speed off (`50f69a6420eff926`), both Unsloth Studio servers on the same VM. - The default-load column is not this PR: on this card Unsloth Studio's default speed mode picks the `_native_cudnn` attention backend and a channels-last VAE, and base renders the same bytes as the branch there. `seam_safe_tile_strides` has no 256p edge case: 192/256/320 px sides fit in one stock 256 px tile or leave an 8-latent edge tile, and 448 px gets the seam-safe 16/10 tiles (covered by the existing tile sweep); every render above decoded untiled anyway. - Refusals on the branch (HTTP 422): fps 31 and 11 on Edge ("Supported: 12 to 30 fps"), 176x176 ("between 61,440 and 409,600 pixels"), 49 frames ("Supported counts run from 53 to 149"). Base refused 448x256 and 320x192 with "between 204,800 and 409,600 pixels", and took fps 31 on Edge without complaint. Each card is one setting, Unsloth Studio at speed off on the left and plain diffusers on the right (frame-identical, per the table), 2.2 s per card at the clip's own frame rate. 320x192 clips are upscaled 1.34x (lanczos) to match the cell; 832x480 clips are shown at 448x258. **256p**     **Frame rate**: same prompt and seed on Edge 832x480, 121 frames, each played at its real rate (so 12 fps covers less of the clip in the same 2.2 s)    **Image to video**: both clips start from this image (generated with Qwen-Image-2.1, cropped to 832x480), prompt "The bee lifts off the flower and flies toward the camera as the petals sway gently in the breeze."    ## Memory and speed  Measured at the head `2676a6d138` on Colab (Tesla T4 15 GB and RTX PRO 6000 96 GB), waves prompt, Auto memory mode. On the T4, where Unsloth Studio offloads and runs fp32, Edge at 448x256 peaks at 7.6 GiB against 11.0 GiB at 832x480, and 121 frames take 249 s instead of 1,217 s. On the 96 GB card Edge drops from 14.4 to 10.1 GiB at 121 frames and Nano from 38.5 to 32.8 GiB at 189 frames. Not run: Nano on a T4 (the VM's 50 GB of host RAM ran out while loading it), L4, A100, H100. **Tests**: new backend tests in `test_video_cosmos3.py` (presets equal the pipeline's tiers, 320x192 / 448x256 accepted and smaller refused, frame snapping, fps validation per family, every other family takes any rate, status payload, generate passes and exports the picked rate) and `tests/video-fps.test.ts` (options, fallback, duration math identical to before for families without a window, restore, a rate change keeps the picked length: fails at `a012d267c0`, passes at `2676a6d138`). `test_video_shape_validation.py`'s 256x256 refusal now skips a family that lists it. Locally on macOS (M5): the video backend suites show the same 23 failures on base and branch (H3 modular loads, native quant/stream builds, prequant download plans: environment), branch +48 passing; frontend typecheck clean; full frontend suite 14,930 pass and 2 fail of 14,933: a KaTeX import check that trips on a symlinked `node_modules` and a timing test. **Status**: head `2676a6d138`. Codex: [no major issues at `2676a6d138`](LeoBorcherding#765 (comment)) on the fork mirror. CI at `2676a6d138`: 62 passed; `Core` / `Core zoo` (6 jobs) and the parity verdict still queued on the runner pool (all green at `a012d267c0`; the two new commits are frontend only). `connection (dsh, stable)` [failed](https://github.com/unslothai/unsloth/actions/runs/42179371398/job/127765159935) because `npm install -g @deepseek-ai/dsh` finds no version on npm (ETARGET); the same job [fails the same way on main](https://github.com/unslothai/unsloth/actions/runs/42150846508/job/127673440744) (`9d40777eb1`). **Noticed, not changed** - Refusal toasts name the family by its id ("for cosmos3-edge"), like every other shape refusal in `video_families.py`. - A saved generation preset keeps size, length and steps but not the frame rate. - Restoring a clip whose rate the loaded family does not offer (an Edge 12 fps clip on Nano) keeps the current rate and still says "Settings restored to inputs". - At 768 px the header's Family / Engine line clips behind the Create / Train toggle (pre-existing). **Not run**: Hopper / Ampere (A100 80 GB and H100 were refused by Colab; this ran on Blackwell), the default speed mode against diffusers with a matching attention backend, multi-GPU and offloaded loads at 256p, video continuation, AMD / Apple silicon. ## Before / after (maintainer check) Video page settings rail, merge base vs this branch, two isolated Studio installs. No GPU on this host, so the loaded model is not a live load: each side's page is served the status its own backend returns for a Cosmos3 load with a stubbed pipeline. Edge: the read-only "24 fps" row becomes a 12 to 30 slider. Nano: it becomes a 10 / 16 / 24 / 30 dropdown, and the default canvas is no longer pushed up to the old 204,800 px floor.   --------- Co-authored-by: Daniel Han <[email protected]>
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Builds on #16737, so this diff includes its commits until that one merges. Review #16737 first.
What
Adds a third workflow for Cosmos3-Nano on the Unsloth Studio Video page: Continue a clip. You upload a short video, Nano keeps 5 frames from its end (or its start) and generates what happens next.
Why
Predicting the future of a clip is one of the main things Cosmos 3 is built for, and NVIDIA's pipeline already supports it (
Cosmos3OmniPipeline(video=...)). Unsloth Studio only offered text-to-video and image-to-video, so there was no way to use it. Nano only: Cosmos3-Edge does not accept video input, and the section does not show for it.Before / after
Merge base
590119dvs the head, Cosmos3-Nano loaded, theme set in Settings > Appearance. The AFTER frame-rate picker comes from #16737.States: first/last choice, clip over 15 s, generating, Cosmos3-Edge (light and dark)
Messages: a start frame and a clip replacing each other, a 20 s clip, a 3-frame clip
Full page: generating, result, switching to Cosmos3-Edge with a clip staged, 1024 px
Screenshots: headless Playwright on a Colab G4, Unsloth Studio at
9358a68(the headf6a1402only drops a toast that never reached the screen).Unsloth Studio vs plain diffusers
Colab G4 (NVIDIA RTX PRO 6000 Blackwell Server Edition, 96 GB), Linux, backend at
965e910(the clip decoding is unchanged since; later commits are frontend and one error message). Unsloth Studio loadednvidia/Cosmos3-Nanoin auto mode (bf16, no offload) withUNSLOTH_COSMOS3_SAFETY_CHECKER=0, since the guardrail repo is gated./video/generatewithcontinuation_videoandcontinuation_keep.Cosmos3OmniPipeline(video=<the source's decoded frames>, condition_video_keep=...)with the model card's setup (UniPCMultistepSchedulerwithflow_shift=10.0,enable_safety_checker=False).Source | plain diffusers | Unsloth Studio, from the last frames:
From the first frames:
Kept frames 0 and 4 and the first generated frame 5 (top row: the source's kept end)
GIFs are 400 px a panel at 8 fps.
Memory and speed
Same runs as the table above, measured at
965e910on the Colab G4 (RTX PRO 6000, 96 GB). Peak is the nvidia-smi card total: Unsloth Studio holds 36.0 GiB through the source and both continuations, plain diffusers peaks at 38.3 GiB. Not run: other GPUs, offloaded loads, 720p.UI pass
Driven in Unsloth Studio on Colab, light and dark, 1440, 1024 and 768 px. Fixed here:
Checked and fine: the preview (same player and size as the MiniMax-H3 reference videos), progress (the page's usual step counter and time left), the section hidden for Cosmos3-Edge, the layout at 1024 and 768 px in both themes. Not checked: keyboard-only use and reloading the page with a clip staged.
Noticed, not changed:
Tests and status
studio/backend/tests/test_video_cosmos3.py: 267 passed, 2 skipped with diffusers 0.42.1; 260 passed, 9 skipped with diffusers blocked (as therestCI shard runs it).studio/frontend/tests/video-continuation.test.ts: 9 passed; frontend suite 14942 passed; typecheck clean. Local, macOS, atf6a1402.f6a1402. Codex at the head: Didn't find any major issues on the fork mirror.8eafc9b,Backend CI / (Python 3.13, rest)failed on this branch (a test imported diffusers unconditionally; fixed by merging Unsloth Studio: Cosmos3 256p, NVIDIA's frame ranges and a per-model frame-rate picker #16737'sa012d26).Chat UI Tests (extra)failed on a/loginpage timeout inplaywright_multi_account.pythat is not this PR's: the same timeout failed on main's push run (a1e340b) and on three other PR branches the same day (1, 2, 3).Not run
720p, anything other than NVIDIA on Linux, and the Unsloth Desktop app.
Before / after (maintainer check)
Video page settings rail, merge base vs this branch, two isolated Studio installs. No GPU on this host, so the loaded model is not a live load: each side's page is served the status its own backend returns for a Cosmos3 load with a stubbed pipeline. Cosmos3 Edge gets no continuation section; Cosmos3 Nano gains "Continue a clip" (and the frame-rate dropdown from #16737).
Also fixed here: a portrait phone clip (stored landscape with a display rotation) is now decoded upright, matching ffmpeg's autorotate, before its frames reach the pipeline.