Skip to content

Wan on the diffusion runtime with LoRA plug-ins; offer them in TensorAgent - #434

Merged
zhongkaifu merged 20 commits into
mainfrom
claude/sharp-curie-oofrq8
Nov 30, 2026
Merged

zhongkaifu merged 20 commits into
mainfrom
claude/sharp-curie-oofrq8

Conversation

@zhongkaifu

Copy link
Copy Markdown
Owner

Summary

Wan 2.1 T2V, Wan 2.2 TI2V-5B and A14B (both experts) now generate only on the unified diffusion runtime (DiffusionVideoPipeline) and its tensor executors. The bespoke Wan pipeline, its native DiT and their switches are deleted. LoRA plug-ins are new and run on every backend, and TensorAgent offers Wan 2.2's two speed plug-ins.

What changed

Runtime migration

  • WanFamily ports request resolution, the UniPC and Euler schedules, seeded noise, the TI2V first-frame replacement, and A14B's condition and expert switch. WanDenoiser runs guidance, the CFG combine and the cfg-cache stride.
  • WanTransformer emits the DiT as one replayable GraphProgram per geometry. On the GGML executor it is the retired native graph, node for node; on cuda and cpu it is regions served by the retired direct DiT's kernels.
  • New family-neutral runtime pieces: UniPCFlowSampler, the PairRotaryAttention region, the layer-norm form of AdaLnModulate, the bias form of RowNorm, and shared direct-engine attention routing.
  • Tensor executors donate an op's last-read operand, so bias adds, the gated residual (CUDA) and the pair rotary run in place. They also rerun a geometry's step trace and bind large step inputs as device tensors. Together these removed a 1.3–3.5% direct-CUDA step regression in the first build.

LoRA plug-ins (WanLoraSet, plug-in type wan-lora)

  • Applied unmerged on every backend. Accepts ComfyUI, PEFT, kohya and diffusers keys. Bias and norm differences are added exactly. Each A14B expert is bound on its own, and the step count comes from the config or the file name.
  • Three pinned configs in config/lora/: TI2V-5B Turbo and the A14B Lightning high/low pair. Factor binding runs in parallel (about 1–2.5 s, down from 4–7 s, with bit-identical factors).

Deleted

  • WanVideoPipeline, WanDiT, WanDirectDiT, WanScheduler, WanUniPCScheduler.
  • The native DiT (TSGgml_WanDitForward and its resident cache), its test and its Maui export entries.
  • The TS_WAN_DIT_*, TS_WAN_NO_RESIDENT, TS_WAN_DIRECT_* and TS_WAN_DEBUG_DUMP switches. They are refused at startup with advice, and each one's default is kept.
  • ggml stays unpatched.

TensorAgent and Studio

  • The LoRA catalog offers Turbo 4-Step on the base Wan 2.2 TI2V 5B entry and Lightning 4-Step on the base Wan 2.2 I2V A14B entry. Lightning is one choice that the engine is handed as two adapters, each with the config naming its expert (CatalogLora.ExtraParts, LoraStore.SpecsFor).
  • Neither plug-in is offered on the step-distilled entries or on the other Wan checkpoints; a choice that does not apply sits out with a reason. Purpose strings are in all eight languages.
  • Studio used to refuse a Wan clip when a plug-in was chosen, and defaulted Wan to the base recipe even with the server's --lora. It now takes the default steps and guidance from the planned plug-ins (WanVideoModel.DistilledStepsWith), as it does for a distilled checkpoint. A request's own values still win.

Validation

NVIDIA A40 host (Xeon Gold 6342) and a Xeon 2.10 GHz host. ggml bb877c0, unchanged. Retired pipeline built from db1c686. Details are in docs/models/wan.md ("Validation of the runtime migration") and docs/design/diffusion-runtime.md §3.14.

Quality

  • The retired DiT's per-step velocities were frozen in five synthetic cases. The runtime reproduces their bytes on every lane (ggml_cuda, cuda, cpu, ggml_cpu), including after reruns.
  • Whole clips ran in ABBA rounds with prebuilt binaries. Every clip gave the retired pipeline's frames byte for byte: on GPU across TI2V-5B, TI2V-5B Turbo, Wan 2.1 1.3B and A14B (base and lightx2v); on ggml_cpu and cpu on Wan 2.1 1.3B, 12 runs per backend.

Performance (runtime / retired, steady-state step)

  • ggml_cuda: 0.959×–1.004×.
  • cuda: 1.000×–1.005×. The 1.005× is A14B, where the expert switch compiles the low-noise program once a request (about 0.05 s).
  • ggml_cpu: 1.001× wall, 0.997× CPU time.
  • cpu: 0.973× steady, 0.987× wall.
  • Wall times on cuda follow the VAE decode, the same code in both trees, which varies by several seconds from run to run.

Memory

  • A14B peaks lower on ggml_cuda (15.0 → 10.9 GB, 13.2 → 10.7 GB).
  • On cuda, nvidia-smi shows +0.6 GB for A14B, which is the CUDA pool's cached free blocks. By the allocator's live bytes, the runtime's peak is 59 MiB lower.

LoRA

  • Unmerged vs merged weights: relative L2 ≤ 2.6e-7 on cuda, 1.9e-7 on cpu, 8.3e-7 on ggml_cpu, 1.2e-4 on ggml_cuda (F16 factors).
  • TI2V-5B Turbo LoRA vs the merged Turbo checkpoint: 20.6/23.8 dB (t2v/i2v) on ggml_cuda, 20.7/23.5 dB on cuda; the no-plug-in control is 16.6/14.3 dB.
  • A14B Lightning gives a clean clip.
  • The unmerged products cost 13% a step on ggml_cuda and 6.4–9.4% on cuda.

The app's form

  • Specs produced by TensorAgent's own LoraSelection.Plan from its store give the same frames, bit for bit, as the configs passed as --lora. This was checked on ggml_cuda and cuda for TI2V-5B Turbo (1280×704×49, t2v and i2v) and A14B Lightning (640×384×17).
  • These are the same frames the LoRA quality checks measured.

Tests

  • A40, CUDA-pinned (TS_TEST_GGML_BACKEND=cuda), filtered to the Wan denoiser, Wan LoRA, Wan video, Studio Turbo and Web UI video-LoRA tests: 139 passed, 0 skipped.
  • TensorAgent.Tests: 1669 passed, 0 failed, 172 skipped (live-model and platform-gated, not counted as passes).
  • InferenceWeb.Tests, full suite in a cloud container: 14209 passed, 1 failed, 1478 skipped. The failure is Lfm3RuntimeTests.ConcurrentRequestsOverRingsAreBatched(tp: 2, stages: 1): a batched CPU stream parted from its lone run at token 2 under suite load. It passed 3/3 when rerun alone, and this branch does not touch that code.

Not validated

  • Metal and Vulkan.
  • The A14B T2V and Wan 2.1 14B checkpoints.
  • A run inside the TensorAgent app's own window (iPhone, iPad, Mac or Windows).

Generated by Claude Code

WanDenoiserGoldens writes four synthetic Wan DiT GGUFs (16, 36 and 48 input
channels; F32, F16, Q8_0 and Q4_K matrices with F32 or F16 vectors) and five
step cases (a uniform timestep, and TI2V's first latent frame at t = 0), and
keeps the frozen velocities in MiniMaxH3ImageGoldens' format, one file a lane.
WanLegacyFreezeTests (opt-in: TS_WAN_FREEZE_DIR, TS_WAN_FREEZE_BACKENDS) runs
the native WanDiT on the pinned GGML backend and WanDirectDiT on cpu and cuda.

Frozen here: ggml_cpu and cpu on the cloud container's Xeon (ggml bb877c0,
unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
The five synthetic-checkpoint cases as the retired native DiT (ggml_cuda) and the retired direct DiT (cuda, cpu) gave
them on an NVIDIA A40 host with an Intel Xeon Gold 6342, built from db1c686 with ggml bb877c0 unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…oke pipeline

Wan 2.1 T2V, 2.2 TI2V-5B and A14B (both experts) now generate only on DiffusionVideoPipeline. WanFamily ports the retired
pipeline's request resolution, its UniPC and Euler schedules and its seeded noise, plus the TI2V first-frame replacement
and A14B's 36-channel condition and expert switch. WanDenoiser runs the guidance passes, the CFG combine and the
cfg-cache stride, and releases the first expert at the switch. WanTransformer emits the DiT as one replayable
GraphProgram per geometry:
- on the GGML graph executor, the retired native graph node for node;
- on the cuda and cpu tensor executors, regions served by the retired direct DiT's kernels.

LoRA plug-ins are new (WanLoraSet, an AdapterSet, plug-in type wan-lora), applied unmerged on every backend:
- the ComfyUI, PEFT, kohya and diffusers key spellings;
- bias and norm differences added exactly;
- per-expert binding on A14B;
- the step count from the config or the file name.
Three configs ship: TI2V-5B Turbo and the A14B Lightning pair.

New runtime pieces, all family-neutral:
- UniPCFlowSampler;
- the PairRotaryAttention region;
- the layer-norm form of AdaLnModulate;
- the bias form of RowNorm;
- the direct engines' attention routing, now shared with the executors (CudaWanOps.Attention, DirectOps.HostAttention).

Deleted:
- WanVideoPipeline, WanDiT, WanDirectDiT, WanScheduler and WanUniPCScheduler;
- the native DiT (TSGgml_WanDitForward and its resident cache) and its test;
- the freeze harness.
Their switches (TS_WAN_DIT_*, TS_WAN_NO_RESIDENT, TS_WAN_DIRECT_*, TS_WAN_DEBUG_DUMP) are refused at startup with
advice, and each one's default is kept. ggml stays unpatched.

Validated locally (Intel Xeon 2.10 GHz, ggml bb877c0 unchanged):
- WanDenoiserTests: the retired steps' bytes on ggml_cpu and cpu in all five cases, and within 5e-2 of every other frozen
  lane.
- WanLoraSetTests: the unmerged LoRA within 8.3e-7 (ggml_cpu) and 1.9e-7 (cpu) of merged weights.
The GPU lanes and whole-clip A/B are validated separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
… A/B tool's driver

- The Wan model card (English and Chinese), USAGE, FEATURES, the capability reference and config/README describe the
  runtime path, --lora on Wan with the three shipped plug-ins, and the retired switches.
- The design doc marks Wan migrated.
- eng/validation/WanAbProbe gets a README and abba.sh, a generic alternating-order driver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…st to the mark

The runtime's denoiser gives the retired DiT's step bytes in all five synthetic cases on every frozen lane:
- ggml_cpu and cpu on an Intel Xeon 2.10 GHz;
- ggml_cuda, cuda and cpu on an NVIDIA A40 host with a Xeon Gold 6342 (ggml bb877c0 unchanged; 91 of 91 Wan tests
  passed there with the GGML backend pinned to CUDA, none skipped).
The unmerged LoRA test gives 2.6e-7 (cuda) and 1.2e-4 (ggml_cuda, F16 factors) of the merged weights, on a plug-in that
moves the velocity by 52%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
… symbol manifest

TSGgml_WanDitForward and TSGgml_WanResetForwardCache left the native library with the bespoke Wan DiT. Every listed
name is a -u link root, so keeping them would fail the Release device link with "Undefined symbols".
TensorAgentMauiProjectTests holds the manifest to the native sources' exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…s not offer

- WanFamily resized the conditioning image through a bare ImageIO, which on the Apple targets resolves to Apple's ImageIO
  namespace (AppleTargetSourceTests). It now names QwenImage.ImageIO, as the other families do.
- TensorAgent already offers a merged 4-step distilled checkpoint of TI2V-5B and of A14B, so the three wan-lora configs
  stay CLI and server plug-ins. They are listed, with that reason, in the configs the app does not offer
  (LoraCatalogTests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…ps work in place again

On direct CUDA the runtime's Wan steps ran 1.3-3.5% slower than the retired direct DiT's (A40, steady-state step time; the
frames bit-identical). The extra work was 9-30 ms a pass of copies and slow adds the retired DiT never made:
- q and k copied before the pair rotary;
- the residual stream copied in every gated residual;
- each linear's bias added on the generic broadcast kernel, which indexes in 64-bit divisions.

A session now donates an operand to the op or region about to read it when all of these hold:
- the template's liveness has no other reader of it left;
- it is an op's value its node owns;
- nothing pins it;
- no other tensor shares its storage.
This is the tensor the session would release right after that reader.

The executors use donation where the retired DiT worked in place:
- the add of a donated operand and a bias row runs on the direct engines' row kernels (ts_add_bias_rows_f32, DirectOps'
  host rows);
- CUDA's gated residual adds on the residual stream itself;
- both tensor executors' pair rotary rotate donated q and k where their norms wrote them.
The arithmetic is unchanged. A launch refused after an in-place write throws instead of falling back to the region's ops.

WanDenoiserTests now also checks that the bias rows and the donated region inputs ran in place. Locally the managed
executor gives the retired bytes in every frozen case with 42-50 bias rows added and 24 region inputs donated in place
over the test's two predictions. The full suite and the A40 re-run are separate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
… tracing every prediction

Every prediction emitted the whole program again (a hash-only trace checking the cached plan's signature) before the
device got any work. That is host time the retired direct DiT never spent, about 0.1 ms a block. The tensor executors'
later predictions of a geometry now rerun the trace that ran its first one, as LTX's denoiser reruns its step:
- the same rotary tables, sequence and LoRA binding are the program's shape;
- only the tokens, conditioning and timestep features are written again, into the arrays the trace binds.
The GGML path still traces each prediction.

WanDenoiserTests: a second step's values on the same plan give a fresh denoiser's bytes for them, and the first step's
again give its own, on ggml_cpu and cpu locally (and the CUDA executor in the GPU run).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…f the transformer's own

nsys on the A40 (TI2V-5B at 2,730 tokens, direct CUDA) put the remaining step gap in host time between predictions, about
8-10 ms a pass with the device idle. The kernels' time matched the retired direct DiT's within 0.3%.

The session copied every F32 input of every run through a new host array (the tokens, the 8 MB conditioning and both
rotary tables: about 13 MB of large-object allocations, zeroed and copied, before each upload). On the tensor executors
the transformer now binds these as device tensors of its own, as the retired direct DiT uploaded them:
- the tokens and conditioning are uploaded from the caller's arrays each prediction;
- the rotary tables are uploaded once for the trace that reruns them.
The GGML path still binds host arrays.

Locally the Wan, Studio and LoRA tests pass on ggml_cpu and cpu (1361 passed, the 36 CUDA ones skipped); the A40 run is
separate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
nvidia-smi counts the CUDA pool's cached free blocks too, so a higher peak there need not be more allocated memory. The
probe now samples the model's device allocator every 10 ms while a case runs and records its peak live bytes
(peak_live_mib). It reads ModelBase's own field by reflection, so it still builds against any tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…-clip A/B on ggml_cuda and cuda)

The model card and the design doc (§3.14, Wan on the runtime as built) record:
- the frozen steps given bit for bit on every lane;
- whole clips identical to the retired pipeline's on ggml_cuda and direct cuda;
- the steady-step and wall ratios, and the peak memory (A14B on ggml_cuda 2.5-4.1 GB lower);
- the direct-CUDA step regression that nsys traced, and its fixes.

The Turbo cuda round, the LoRA quality runs, the CPU clips and the A14B live-memory comparison are still running and are
not claimed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…arrowing

Binding the A14B Lightning pair took about 6.5 s at each expert's first step on the A40 (ggml_cuda, F16 factors), and the
TI2V-5B Turbo plug-in about 4 s. The cost was 300M values an expert, stacked, scaled and narrowed one at a time, with a
per-value half cast done twice (once to check that every value fits).

The projections are now made in parallel. The narrowing is TensorPrimitives.ConvertToHalf (the same IEEE round to nearest
even, written straight into the factor's memory). The fits check is one max-magnitude pass: no NaN, and every magnitude
below 65520, the first value that rounds to infinity.

WanLoraSetTests.HalfFactorsNarrowAsTheScalarConversion holds the vectorized narrowing to the scalar cast's bits (20,000
random values, subnormals, rounding ties and half's limit) and the fits check to the scalar one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…e Turbo cuda round

- LoRA:
  - unmerged against merged weights on all four backends;
  - the TI2V-5B Turbo plug-in against the merged Turbo checkpoint and a no-plug-in control;
  - the A14B Lightning pair and a bare Wan 2.1 DMD file;
  - the cost per step.
- Memory: A14B's 0.57 GB higher nvidia-smi peak on direct CUDA is the pool's cached free blocks. The allocator's own live
  bytes peak 59 MiB lower.
- Turbo: the cuda round is at parity per step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
… memory and LoRA evidence

The Chinese model card gets the A40 validation tables and the LoRA results. Both cards record the parallel bind's cost
at an expert's first prediction on ggml_cuda: about 1 s, or 2.5 s at A14B's switch, against 4-7 s before, with the
factors and frames bit-identical. §3.14 records A14B's live-memory result and the LoRA evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
…red pipeline

The clip was Wan 2.1 1.3B at 480x320x9, in three alternating rounds per backend on the A40 host's CPU quota, the last
two with each process's CPU seconds. All runs gave the retired frames byte for byte:
- ggml_cpu: 1.001x wall and 0.997x CPU time;
- cpu: 0.987x wall, 0.987x CPU time and 0.973x steady steps.
The first round's apparent 2% on ggml_cpu sat inside the single runs' spread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
The app's LoRA catalog lists the two Wan 2.2 step-distillation plug-ins the
engine ships configs for: Turbo 4-Step on the base TI2V 5B checkpoint and
Lightning 4-Step on the base I2V A14B pair. Lightning is one choice that the
engine is handed as two adapters, the high-noise half and then the low-noise
half, each with the config that names its expert (CatalogLora.ExtraParts,
LoraStore.SpecsFor). Neither is offered on the step-distilled entries (TI2V 5B
Turbo, I2V A14B LightX2V) or on the other Wan checkpoints; a choice that sits
out says why. Chat clips carry no steps or CFG for Wan, so the plug-in's
recipe (4 steps, guidance off) applies.

Studio refused a Wan clip whenever a plug-in was chosen ("wan takes no LoRA
plug-ins"), and it defaulted Wan to the base recipe even with the server's
--lora. It now plans the clip's default steps and guidance from the chosen
plug-ins (WanVideoModel.DistilledStepsWith, read from the configs and names
alone), as it does for a distilled checkpoint, with no fixed contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
The TensorAgent README describes Turbo 4-Step and Lightning 4-Step: where they
are offered, the two-adapter Lightning pair under one switch, the recipe chat
and Studio apply, and why they sit out on the other Wan entries. The Wan cards
and the config README say that Studio follows a step-distillation plug-in's
recipe and that the app embeds the same configs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
… A40

The specs TensorAgent's planner hands the engine (weights from the app's store
with the config beside them, Lightning as two) give the same frames, bit for
bit, as the configs passed as --lora, on ggml_cuda and cuda, for the TI2V-5B
Turbo and A14B Lightning cases, and the same frames the engine's LoRA
validation measured. No run in the app's own window is recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T03:43:29.687326Z 94fa3e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94fa3e0683

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +102 to +105
float strength = spec.Scale ?? 1f;
if (!float.IsFinite(strength)) throw new ArgumentException($"LoRA {spec.Path}'s strength must be finite.");
// A wan-lora config's declarations win; bare weights are read by their file or folder name.
WanLoraConfig config = WanLoraConfig.Of(spec);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor the Wan plug-in config's default strength

When a wan-lora manifest specifies a non-default "scale" and the caller omits --lora-scale, the adapter is nevertheless applied at strength 1. LoraCliFlags.Resolve leaves the manifest attached as ConfigPath rather than copying its scale into the spec, and WanLoraConfig never reads that field, so spec.Scale ?? 1f silently discards the configured strength. Read and validate the manifest's scale and use the precedence explicit spec scale → manifest scale → 1, as the other plug-in loaders do.

Useful? React with 👍 / 👎.

Comment on lines +368 to +371
finally
{
_beat = null;
TrimDevicePools();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Release component residency when a clip is cancelled

If a clip is cancelled during denoising, this cleanup only trims unused pool buffers and leaves the DiT's resident weight copies allocated. DiffusionVideoPipeline.Run deliberately skips ReleaseFailedPhase for OperationCanceledException and releases only workspaces; consequently, the normal ReleaseAfterPhase cleanup is never reached. Unlike the retired pipeline's unconditional ReleaseDeviceMemory() cleanup, cancelling a Wan clip can now leave several GB of VRAM occupied while the model stays loaded, preventing other workloads from using it. Release the pipeline's device residency in the request cleanup as well.

Useful? React with 👍 / 👎.

…lled clip's GPU memory

- The local regression harness's catalog inventory listed no preset for the three
  config/lora/wan-*.json plug-ins, so test_every_config_has_one_inventory_entry
  failed (offline-harness on every OS). They are now plugin presets of the wan
  family; Turbo names config/wan-video-ti2v-5b.json as its base, and the Lightning
  halves note that they adapt the base I2V-A14B experts.
- That config/wan-video-i2v-a14b.json is jayn7's merged lightx2v pair, a different
  4-step distillation from the Lightning LoRA, is now what the Lightning configs,
  the config README and the Wan cards say; they had called the two the same.
- A wan-lora config's "scale" was ignored: the strength is now the spec's
  (--lora-scale), else the config's, else 1, as for the other families' plug-ins,
  and a scale that is not a finite number is refused.
- A cancelled or failed clip left the phase it stopped in resident (several GB of
  DiT weights), where the retired pipeline released all its device memory at a
  request's end. WanVideoModel now releases the pipeline's device memory after a
  clip that did not finish; a finished clip's path is unchanged.

Checked here: the harness's 610 tests, audit and plan pass; the Wan, LoRA and
Studio filters pass (349, 3 CUDA-only skips); TensorAgent's LoRA and catalog
filters pass (332). The GPU check of the cancelled clip is a separate run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012qWiYcpkUFBdz4N2CfoVMi
@zhongkaifu
zhongkaifu merged commit e55ba57 into main Nov 30, 2026
6 of 7 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.

2 participants