Skip to content

idea: tiled stage-2 refine for H3 (upscale, low-sigma refine in feathered tiles) - the #471 refine pass #1043

Closed
3 of 3 issues completed

Description

@dkackman

Source: mo-akkakk/ComfyUI-MiniMaxH3-TemporalWindow-SpatialTiles (MIT), a ComfyUI node that wraps native H3 sampling (h3_windows.py, ~380 lines). Its plumbing is ComfyUI-specific (an OUTER_SAMPLE wrapper, a recording CLIP clone); a port is a new dw pipeline processor against diffusers, using that file as a reference for the logic only.

Idea: a stage-2 refine for H3 done in spatial tiles. Render stage 1 at native size, decode, upscale, VAE-encode, then refine over the low part of the sigma schedule one overlapping tile at a time, each tile anchored to its crop of the upscaled plate, and feather-blend the tiles. This is the deferred refine pass from #471: the #500 gate (2026-10-03, T2VA crowd faces, seed 42) found the latent upscale preview "close but soft" (waxy faces) against native 768p, and the refine pass was left as a new plan. Tiling is what makes a refine at 1080p+ fit in VRAM.

How the node does it (WindowsWrapper.__call__, plan_tiles, tile_weight, tile_refs):

  • tiles on the 2x2 latent patch grid, linear feather over the overlap; their advice is >= 192 px overlap, default tile 960x544 with 256 px overlap;
  • each tile's reference videos and keyframe latents are cropped to the tile, and <Picture N> optionally too (on for a frame of this shot, off for a character/style reference);
  • the prompt is re-encoded per tile with the cropped reference images.

Known limits (theirs):

  • tiles are denoised independently, so flat areas (sky, walls) can differ slightly between tiles; wider overlap helps;
  • each tile renders its own soundtrack and they are averaged: the deliverable's audio should come from stage 1, not the tiles;
  • a full-denoise pass in tiles without a plate repeats the subject in every tile, so this is a refine (partial sigmas) only.

Gate: rerun the #500 case (same prompt, seed 42, 124 frames) as stage-1 + tiled refine against native video-with-audio-768p and the #500 preview; faces must not be soft. Quote wall time against the 12.7 min native run.

(claude-opus-5-5 via anthropic)

Activity

  1. added
    enhancementNew feature or request
    owner:donParked for human decision
    ideaAn idea for the researcher agent to assess
    featureWork bigger than a fix: designed with Don, built in stages (harnest R11)
    owner:leadFeature lead's turn (harnest R11)
    status:needs-specTester writes acceptance cases for the plan's stages
    and removed
    owner:donParked for human decision
    on Oct 27, 2026
  2. dkackman commented on Oct 27, 2026

    @dkackman
    OwnerAuthor

    Ruling (Don, 2026-10-26): approved. Over to lead for a plan. The gate stays as written: rerun the #500 case (same prompt, seed 42, 124 frames) as stage-1 + tiled refine, compared against native video-with-audio-768p and the #500 preview. Faces must not be soft, and wall time is quoted against the 12.7 min native run. The deliverable's audio comes from stage 1.

    (claude-opus-5-5 via anthropic)

  3. dkackman commented on Oct 27, 2026

    @dkackman
    OwnerAuthor

    Plan v2: tiled H3 refine above 768p (#1043)

    Lead: claude-opus-5-5 via anthropic. Read-only sweep of develop @ 57daeb2. v2 folds in Don's ruling of 2026-10-26 (approved with one change: a zero-build pre-gate before stage A; Q1-Q5 answered as the defaults, plus an LTX arm).

    Verdict: build smaller, behind a zero-build pre-gate. Measure the routes that exist today first; build the engine only if they fail, then gate the template on Don's A/B

    The issue's premise is stale, and that changes what this feature is. #471's deferred refine pass has been built: #598 (refine_strength, DwH3RefineScheduleStep). Its upscale-refine template lost Don's A/B (M-F086, crowd faces, seed 42: 11.53 min against 9.59 min for native 768p, and still softer) and was reverted by #664. The engine stayed. A tiled refine at 1344x768 is #598 cut into pieces: slower, and with seams. The only new thing tiling buys is a refine above H3's 1344x768 canvas, i.e. a 1920x1088 deliverable that native H3 can't render. This plan builds that (Q1). The issue's 12.7 min baseline is from #500. The current native figure is 9.59 min (M-F086), and the pre-gate re-times native on the current build.

    What the sweep found against the issue

    1. idea: opt-in H3 latent upscaler path (generate small, upscale latents, refine) - separate from existing H3 templates #471's refine pass already exists (above). This feature is "refine above the canvas", not "the idea: opt-in H3 latent upscaler path (generate small, upscale latents, refine) - separate from existing H3 templates #471 refine pass".
    2. refine_strength is reusable per tile as-is. One self.pipeline(**arguments) call per tile (dw/pipeline_processors/pipeline.py:685) with cropped latents. DwH3RefineScheduleStep (h3_hold_steps.py:248-362) re-noises the generated rows and rebuilds the per-row plan. No graph change is needed for the refine itself (h3_hold.py:107-150).
    3. Width and height must be passed per tile. Diffusers takes them from the call or the default 16:9 canvas, not from latents (before_denoise.py:382-397,972-978). It needs multiples of 32 (16 px × the 2x2 patch). Diffusers' 768x1344 cap applies only when they're omitted, so tile calls aren't refused.
    4. Each tile call would decode its own tile. idea: opt-in H3 latent upscaler path (generate small, upscale latents, refine) - separate from existing H3 templates #471 found dw can't drop H3's decode block for a normal step. Decoding 4 tiles at 768p would waste ~9 min and give pixel tiles that would need a second, pixel-space blend. So the tile calls run a graph variant without the decode block, built where insert_audio_hold already edits the graph, and the blended canvas is decoded once with diffusers' MiniMaxH3VideoDecodeStep (the decode_h3_latents path). That VAE tiles spatially by default (autoencoder_kl_minimax_h3.py:524-526,619-626), so a 1080p decode should fit. Nothing is measured above 768p (one reading: 10.93 GB reserved for the 768p decode).
    5. Audio: each tile re-encodes and holds the whole track, and _with_held_audio (pipeline.py:703-731) adds one audio output per tile. The tiled step returns one video with stage 1's held waveform, once. That's Don's ruling ("audio from stage 1"), and it also sidesteps the node's averaged-soundtrack limit.
    6. The upscaler cap blocks the plate. h3_latent_upscale.py:62-63,165-170 caps the target at 1344x768. Its comment says "H3's canvas", not VRAM. The cap is repeated in model_handlers.py:242,254,258 and pinned by tests/test_h3_latent_upscale.py:45-137. 960x544 → 1920x1088 is 2x, the scale the upscaler was mostly trained at. 1344x768 → 1920x1088 is 1.43x. Both are inside 1-4x.
    7. There is no H3 encode task. The issue's decode → pixel upscale → encode route needs a new task built on _encode_guides' encode_vae_condition (h3_guide_steps.py:343-380). This plan takes the latent route instead (Q2).
    8. Cropping references is all new code. There is no crop-by-box task, and guides are centre-fitted (h3_guide_steps.py:226-245). The gate case is T2VA with no references, so v1 refuses references and guides in tile mode (Q4).
    9. A real feather already exists in diffusers' VAE _split_tiles/_blend/_stitch_tiles (:656-719). dw's upscale.py:174-221 _tiled_inference is a flat average despite its docstring, so it's not a model to copy.
    10. The VRAM projection would warn falsely. vram_estimate.py prices a call by its width/height. A tiled 1920x1088 refine's denoise peak is a tile's, and only the decode is at full canvas. Stage A must price tile mode by the tile and the decode, or validate warns on every tiled run.

    Problem and non-goals

    Problem: H3 renders at most 1344x768. A 1080p H3 deliverable today is an upscale of 768p detail. Does a route that exists today (spandrel, LTX upscale-clip) already give acceptable 1080p faces? If not, can a low-σ refine, run in 768p tiles over an upscaled latent plate, give 1080p faces sharper than those routes, at a wall time Don will pay?

    Non-goals (v1):

    • tiling at or below 1344x768 (idea: H3 audio-hold in the denoise loop + refine pass after latent upscale (follows #471/#500) #598 measured that);
    • full-denoise tiling (repeats the subject per tile, as the node warns);
    • per-tile cropping of references, <Picture N>, keyframes or guides (Q4);
    • the pixel decode → upscale → encode route and an encode_h3_latents task (Q2);
    • persisted latents;
    • LTX or other families (arm (f) is a comparison, not a build);
    • fixing _tiled_inference's docstring (a separate one-line fix; I'll file it if Don wants).

    The design

    Surface decided here (everything status:needs-approval would ask about):

    • Engine, one new H3 call argument: refine_tiles: {"width": int, "height": int, "overlap": int}. It is valid only together with refine_strength, so it inherits refine's requirements (latents, hold_audio, H3 step, steps >= 2). No MCP tool, REST route or workflow-schema change. Arguments are already free-form, and the rules are static.
    • Rules, added to refine_problems (h3_rules.py), the single owner #598 stage 2: H3 refine schedule after latent upscale (refine_strength) #620's review required, so validate and run time share them. Each refusal names the argument:
      • refine_tiles without refine_strength;
      • width, height or overlap not an integer, or not a multiple of 32;
      • a tile larger than 1344x768 (or 768x1344), or larger than the canvas;
      • overlap < 192 (the node's floor) or >= half the tile's shorter side;
      • any reference image or video, <Picture N>, keyframe or guide argument on the same step;
      • an explicit width/height that disagrees with the latents canvas. In tile mode the canvas is taken from latents (latent H×W × 16).
    • Tile plan: on the 32 px grid, the fewest tiles per axis whose overlap is ≥ the requested overlap, spread evenly, with the last tile flush to the edge. 1920x1088 at 1344x768/256 gives 2x2. The plan is a pure function, unit-tested.
    • Noise: the full-canvas noise is drawn once from the step's generator and cropped per tile, so overlapping tiles start from the same noise where they blend. It enters DwH3RefineScheduleStep as an internal block input (it still calls scale_noise), not as a call argument.
    • Per tile: one call through a graph variant without the decode block, built at component load beside insert_audio_hold. The call gets the tile's width/height, its latent crop, the step's prompt, hold_audio, refine_strength and num_inference_steps. If diffusers' H3 blocks accept precomputed prompt embeddings, the prompt is encoded once, since with no references every tile's text is the same. Otherwise it's re-encoded per tile and the cost is quoted.
    • Decode-free variant guard (Don's ruling): if diffusers' H3 graph can't drop the decode block cleanly, the build stops and reports on this issue before taking the per-tile-decode fallback. It doesn't take the fallback on its own.
    • Blend: a linear feather across each overlap, weights normalized, in float32 on the CPU (results already come back to the CPU, pipeline.py:623-625). It is modelled on diffusers' _blend.
    • Decode once and return: the blended canvas goes through the decode_h3_latents path with VAE tiling on. The step returns latents (the full canvas), the video, and stage 1's held audio, once. Per-tile audio outputs are dropped.
    • Upscaler cap: upscale_h3_latents' target cap rises from 1344x768 to 1920x1088 (or 1088x1920), with its descriptions and tests. Refusals beyond the cap are unchanged in form. The guide states that an upscale-only plate above 768p is soft until it's refined.
    • VRAM projection: in tile mode, vram_estimate prices the denoise at the tile's size and the decode at the canvas's size.
    • Introspection: get_pipeline_signature on an H3 pipeline lists refine_tiles (#598 stage 1: H3 audio-hold blocks in the denoise pipeline (hold_audio) #618 bounced on exactly this for hold_audio).

    Stages

    Stage P: zero-build pre-gate (Don's ruling)

    Stage A: engine refine_tiles + upscaler cap + guide (the measurement)

    Blocked by stage P: it builds only once Don's pre-gate ruling says build.

    • Builds: everything in The design. The guide section Refining above 768p in tiles goes under Promoting an H3 take to 768p in latent space, with an inline workflow: base 544p → upscale_h3_latents 1920x1088 → H3 refine step with refine_strength 0.2, 5 points, video_shift 6 on the 768p turbo LoRA, refine_tiles 1344x768/256, hold_audio from base → pair_audio. A num_frames constraint goes on it as in validate_workflow accepts MiniMax-H3 num_frames outside 120-360; the run fails after the model load #584.
    • Unit tests:
      • the tile plan (counts, flush edges, overlap floor, 32-grid);
      • feather weights summing to 1;
      • refine_problems' new refusals, static and at run time;
      • the decode-free graph variant;
      • noise cropping (a tile's noise equals the canvas noise at its offset);
      • the upscaler's new cap, editing tests/test_h3_latent_upscale.py's cap cases;
      • the VRAM projection in tile mode;
      • the signature listing refine_tiles.
    • Docs: the guide section; the ARCHITECTURE.md row "H3 audio hold and refine" (now with tiling); docs/TASKS.md and model_handlers.py's cap text.
    • Deploy: server (engine change, worker restart).
    • Estimate: $10-14, one build session.
    • Acceptance intent (over MCP):
      • Happy path. The guide's inline workflow validates clean with no false VRAM warning, then runs on lem. The output is 1920x1088 at 124 frames and 24 fps, with exactly one audio track: base's waveform, the same duration as base. No visible seam lines or tile-shaped brightness steps in flat areas (sky, walls), checked with get_output_frames and compare_outputs. The job events show per-tile progress and one decode, and quote the wall time.
      • Validate refusals, each naming the argument:
        • refine_tiles without refine_strength;
        • tile 1000x544 (not a multiple of 32);
        • tile 1920x1088 (over the H3 canvas);
        • overlap 128 (under 192);
        • overlap 400 on 768-high tiles (≥ half);
        • refine_tiles with a reference image;
        • refine_tiles with a guide.
      • Upscaler cap. upscale_h3_latents to 1920x1088 succeeds, while 1952x1088 and 1920x1120 fail naming the cap, with 1920x1088 named as the limit.
      • Untouched. A plain refine_strength run without refine_tiles behaves exactly as before, so the existing refine cases still pass.
      • Introspection. get_pipeline_signature on an H3 pipeline lists refine_tiles.
    • After it verifies: the tester runs the full gate's arms (c) and (d) below on stage A's build and posts their face crops and wall times on stage B, beside the pre-gate's (a), (e) and (f).

    Gate (Don's, after stage A verifies): the #500 crowd-face A/B, seed 42, 124 frames

    Run on lem. Faces must not be soft. Wall times are quoted against arm (a) as re-timed in the pre-gate, with the issue's 12.7 min and M-F086's 9.59 min alongside. The crops include a face on a tile boundary.

    arm route run in
    (a) native video-with-audio-768p (re-timed) pre-gate
    (b) #500 preview, job f90ea84a796e (existing, not re-run) -
    (c) 544p base → up 1920x1088 → tiled refine after stage A
    (d) 768p base → up 1920x1088 → tiled refine after stage A
    (e) (a)'s output → upscale (spandrel) → 1920x1088 pre-gate
    (f) (a)'s output → LTX-2.5 upscale-clip (#542) + pair_audio pre-gate

    Audio in every tiled arm is stage 1's. The tester posts face crops (compare_outputs). The ruling is Don's.

    Stage B (only if Don's gate says yes): catalog template + skill row

    Filed parked with Don (owner:don + status:needs-approval) and blocked by stage A. Don hands it back to owner:lead to build if the gate says yes.

    Order and dependencies

    P → A → gate → B. A is blocked by P, and B by A. No other open issue blocks any stage. #1030 is parked and independent.

    Risks

    • The pre-gate passes: then the feature closes with nothing built. That is the cheap outcome, not a risk to manage.
    • Seams in flat areas: the node's own limit. Shared noise and a ≥ 256 overlap are the mitigations, and the acceptance case looks for seams explicitly. If they show, raising the overlap is a call argument, not a rebuild.
    • Each tile's refine sees only its crop. At strength 0.2 composition is fixed by the plate, but a face cut by a tile edge is refined twice with different context. The feather averages the two, which may itself soften that face. The gate's crops include a face on a tile boundary.
    • The decode-free graph variant: this is the step idea: opt-in H3 latent upscaler path (generate small, upscale latents, refine) - separate from existing H3 templates #471 couldn't take for normal steps. If diffusers' H3 graph can't drop decode cleanly, the fallback is decoding per tile and blending in pixel space: ~9 min more, and a second blend. The build stops and says so before taking it (Don's ruling).
    • 1080p decode VRAM is unmeasured. Stage A's happy-path run measures it, and a failure there is a finding for the plan, not a stage bounce.
    • The run cost is ~3x native. That is the verdict's main exposure, and arms (e) and (f) exist to price it honestly.

    Decisions (Don, 2026-10-26)

    • Q1. Target resolution: 1920x1088. Yes.
    • Q2. Plate route: the latent upscaler, cap raised. Yes.
    • Q3. Gate arms: (d) and (e) yes, plus the LTX-2.5 upscale-clip arm (f). (a), (e) and (f) run as the pre-gate, ahead of stage A.
    • Q4. References and guides refused in tile mode. Yes.
    • Q5. Default tile 1344x768 with a 256 overlap. Yes.
    • A pre-gate before stage A (stage P above), and the stop-and-say guard on the decode-free graph variant.
  4. added
    owner:donParked for human decision
    and removed
    ideaAn idea for the researcher agent to assess
    owner:leadFeature lead's turn (harnest R11)
    status:needs-specTester writes acceptance cases for the plan's stages
    on Oct 27, 2026
  5. 5 remaining items

  6. dkackman commented on Oct 27, 2026

    @dkackman
    OwnerAuthor

    Plan v2: changed since v1

    This records Don's 2026-10-26 ruling. Scope is unchanged: stage A and stage B are as v1 had them.

    • New stage P, a zero-build pre-gate, runs ahead of stage A, and stage A is blocked by it. The tester runs arms (a), (e) and (f) on lem and parks the stage with Don. If (e) or (f) gives acceptable 1080p faces, the feature closes with nothing built.
    • New gate arm (f): LTX-2.5 upscale-clip, re-paired with H3's audio. The gate table now says which arms run in the pre-gate and which run after stage A. After stage A verifies, the tester runs arms (c) and (d) and posts them on stage B.
    • Stage B is filed parked with Don, the same way #471 stage 2: minimax/upscale-preview template + skill line (gated on Don's stage-1 comparison) #500 was.
    • The decode-free variant guard is now written into The design: if diffusers can't drop the decode block cleanly, the build stops and reports before taking the fallback.
    • Questions → Decisions: Q1-Q5 are recorded as Don answered them.

    (claude-opus-5-5 via anthropic)

  7. dkackman commented on Oct 27, 2026

    @dkackman
    OwnerAuthor

    Stages for plan v2, in build order (this is the first decomposition):

    1. #1043 stage P: zero-build pre-gate (native 768p vs spandrel and LTX upscale-clip to 1080p) #1047 stage P: zero-build pre-gate. No blockers. Nothing is built. The tester runs arms (a) native 768p re-timed, (e) spandrel to 1920x1088, and (f) LTX-2.5 upscale-clip + pair_audio on the #471 stage 2: minimax/upscale-preview template + skill line (gated on Don's stage-1 comparison) #500 case (seed 42, 124 frames), posts face crops and wall times, and parks the stage with Don for the ruling.
    2. #1043 stage A: engine refine_tiles + upscaler cap 1920x1088 + guide #1048 stage A: engine refine_tiles, upscaler cap 1920x1088, guide. Blocked by #1043 stage P: zero-build pre-gate (native 768p vs spandrel and LTX upscale-clip to 1080p) #1047, so it builds only after Don's pre-gate ruling says build. After it verifies, the tester runs gate arms (c) and (d) and posts them on #1043 stage B: templates/minimax/tiled-refine-1080p + skill row (gated on Don's A/B) #1049.
    3. #1043 stage B: templates/minimax/tiled-refine-1080p + skill row (gated on Don's A/B) #1049 stage B: templates/minimax/tiled-refine-1080p + skill row. Blocked by #1043 stage A: engine refine_tiles + upscaler cap 1920x1088 + guide #1048, and filed parked with Don (owner:don + status:needs-approval) until his full-gate ruling.

    All three need acceptance cases. Stage P's cases are the pre-gate runs themselves.

    No cross-feature blockers.

    (claude-opus-5-5 via anthropic)

  8. added
    status:needs-specTester writes acceptance cases for the plan's stages
    and removed
    owner:leadFeature lead's turn (harnest R11)
    on Oct 27, 2026
  9. dkackman commented on Oct 27, 2026

    @dkackman
    OwnerAuthor

    Spec for #1043 plan v2. Tester: claude-opus-5-5 via anthropic. All cases are in regression-suite-model-specific.md and carry pending: and source: lines. I made only read-only MCP calls; nothing was run.

    #1047 (stage P, pre-gate)

    • M-F169: arm (a), native video-with-audio-768p on the #471 stage 2: minimax/upscale-preview template + skill line (gated on Don's stage-1 comparison) #500 prompt, seed 42, 124 frames, with re-timing.
    • M-F170: arm (e), (a) → spandrel upscale → fit_to_model 1920x1088 → pair_audio with (a)'s audio.
    • M-F171: arm (f), (a) → LTX upscale-clip 1920x1088 → pair_audio with (a)'s H3 audio.
    • M-F172: audit of the pre-gate record: a row per arm, compare_outputs face crops against (a) and f90ea84a796e, wall times, and the stage parked with Don.

    #1048 (stage A, refine_tiles + 1080p upscaler cap)

    • M-F173: the guide's "Refining above 768p in tiles" section. Its workflow validates clean, with no false VRAM warning.
    • M-F174: refine_tiles refusals, which include the plan's seven probes. Also tested: off-grid sizes and overlap, wrong types, tile over the canvas, overlap 160 and 384, picture/keyframe, a width/height that disagrees with the latents, a non-H3 step, a missing overlap. Boundary controls (192, 352, 1344x768, 1024x576) must validate.
    • M-F175: upscale_h3_latents cap. 1920x1088 and 1088x1920 accepted. 1952x1088, 1920x1120, 1088x1952 and 3840x2176 refused, naming 1920x1088. 1344x768 still accepted.
    • M-F176: happy-path run. Checks 1920x1088, 124 frames, 24 fps, one audio track equal to the base's (measure_sync against a saved 544p take), per-tile events, a single decode, and no seams at the blend bands.
    • M-F177: a refine without refine_tiles is unchanged (M-F096, M-F097 and M-F115 re-run), and the signature lists refine_tiles.

    #1049 (stage B, templates/minimax/tiled-refine-1080p)

    • M-F178: listing with cost and constraints, the get_workflow variables, a clean validate at defaults, num_frames 125/360 handling, and the minimax-h3 skill row against (e) and (f).
    • M-F179: a run at defaults to 1920x1088 with the base audio once, wall time within 25% of the listed cost.

    Notes (none of these blocked a case):

    1. templates/ltx2/upscale-clip needs num_frames = 8n+1, so validate refuses 124. Arm (f) is specced at 121 frames, 3 frames shorter than (a). Don should weigh that when comparing the arms.
    2. The spandrel upscale task takes a PIL image. No existing video route through it is confirmed. M-F170 lets the tester use any chain of existing tasks. If none applies, the record says "(e) not runnable today" for Don, rather than filing a bug.
    3. get_job_workflow("f90ea84a796e") returns realized: false, so the #471 stage 2: minimax/upscale-preview template + skill line (gated on Don's stage-1 comparison) #500 preview's mp4 may be gone too. If it is, M-F172 accepts a record that compares against (a) only and says so.
    4. The plan's "overlap 400 on 768-high tiles" probe is off the 32-grid as well as at or above half. M-F174 adds overlap 384 (exactly half, on-grid) as the clean "half" probe.
    5. The plan doesn't say whether a missing overlap takes a default. M-F174 accepts either a refusal naming overlap, or a default the guide states.
  10. added
    owner:leadFeature lead's turn (harnest R11)
    and removed
    status:needs-specTester writes acceptance cases for the plan's stages
    on Oct 27, 2026
  11. dkackman commented on Oct 27, 2026

    @dkackman
    OwnerAuthor

    All stages are resolved: P (#1047) closed after the pre-gate, A (#1048) verified and shipped as the guide-only tiled refine (refine_tiles, upscaler cap 1920x1088), and B (#1049) closed not planned after Don's gate. The feature ends as opt-in guide surface with no catalog template.

    (claude-opus-5-5 via anthropic)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:cudaenhancementNew feature or requestfeatureWork bigger than a fix: designed with Don, built in stages (harnest R11)owner:leadFeature lead's turn (harnest R11)status:plan-approvedDon approved the feature plan (Don only)target:lem

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions