Skip to content

Studio: count the hosted text encoder and keep the GGUF denoiser resident when only the encoder does not fit - #11802

Merged
danielhanchen merged 14 commits into
mainfrom
studio-gguf-resident-transformer
Sep 25, 2026
Merged

danielhanchen merged 14 commits into
mainfrom
studio-gguf-resident-transformer

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Why

A Windows user on HF (unsloth/Qwen-Image-2.1-GGUF discussion #4, Desktop v0.1.813-beta) reports that Qwen-Image-2.1 GGUF Q8_0 takes much longer per image in Studio than the same Q8_0 file in ComfyUI. I reproduced it with the same Q8_0 file, the same fp8 text encoder repo Studio pulls (unsloth/Qwen-Image-2.1-FP8) and the same VAE, on 24, 16 and 12 GiB VRAM caps. On those cards the time goes into memory placement, not into the GGUF kernels:

  1. The planner never counts the text encoder. Qwen-Image-2.1 loads its fp8 Qwen3-VL (8.7 GiB) pre-cast from unsloth/Qwen-Image-2.1-FP8. The companion scans only walk the base repo, so a GGUF load budgets 8,938 MiB (DiT + VAE) for 17.9 GiB of weights. On a 16 GB card that gives group offload with the encoder resident, and the first image runs out of memory. On Windows, WDDM spills the overflow into shared system memory instead of raising, which is the "drastically slower" case.
  2. No tier keeps the denoiser resident. When the DiT fits but the DiT plus the encoder does not, every tier streams the 7.1 GiB transformer on every step while the encoder, used once before step 0, stays resident. ComfyUI does the reverse on the same card: it encodes, drops the encoder and keeps the denoiser.
  3. The streamed-encoder tier runs the transformer unpinned too. It sets low_cpu_mem_usage=True for everything, so diffusers re-pins every tensor on every onload. On the 16 GB cap that is 25.1 s against 8.5 s pinned. The encoder-only pass goes from 0.39 s to 2.37 s.

Measured and ruled out as causes for this report:

  • Missing Triton on Windows. The compiled GGUF dequant and eager dequant give bit-identical Q8_0 images, and the speed difference is within noise. TORCHDYNAMO_DISABLE=1 matches what a Windows install without Triton gets.
  • Encode and decode. With everything resident, Studio's text-encoder and VAE phases are faster than ComfyUI's.
  • Default steps. Studio defaults to the model card's 40 steps and ComfyUI's template to 25. That alone is 1.57x (15.4 s vs 9.8 s), but it changes the image (LPIPS 0.151 mean / 0.260 max), so it is a product call and this PR does not touch it.

What changes

  • _plan_memory takes the resolved text_encoder_quant. When the load takes its encoder from a hosted pre-cast checkpoint, it prices that checkpoint in the encoder, companion and model terms (_precast_text_encoder_mib, which uses the same resolver as the injection).
    • The size is the cached file size.
    • Only the text_encoder* folders the checkpoint replaces leave the budget, so FLUX.1 keeps its dense CLIP-L.
    • The pre-cast checkpoint is never priced below the dense shards on disk, cached or not, since a failed pre-cast load falls back to them.
  • New planner tier between none and group: the transformer stays resident and only the text encoders stream. It is chosen when model - encoders + headroom + overhead fits the budget.
    • It is still offload_policy == "group", with a new MemoryPlan.stream_transformer = False, so every existing != none check (compile fullgraph, CUDA graphs, torchao declines) behaves as before.
    • _apply_group_offload(stream_transformer=False) hooks only the encoders.
    • If the first encoder refuses, the load falls back to whole-module offload. If a later encoder refuses, the transformer is streamed before that encoder is placed, so the two are never resident together.
    • Video never passes the encoder split, so its plans are unchanged.
  • The streamed-encoder tiers pin what host RAM covers, leaving max(4 GiB, 15%) free: transformer first (paid every step), then the encoders (paid once per call). Each tensor is priced at the pinned allocator's power-of-two size. UNSLOTH_DIFFUSION_GROUP_OFFLOAD_PIN=0|1 overrides this. A RAM-poor host keeps today's unpinned path, and so do native Windows and WSL2: both cap page-locked memory near 1 GiB whatever RAM is free (NVIDIA lists it as a known WSL limitation), and a pin that fails part way used to fail the resident-transformer load outright. On those hosts the 16 GiB row below is the unpinned figure (the "nothing pinned" spot check), not the pinned one.
  • If the first encoder refuses group offload part way, its hooks are removed before whole-module offload takes over (diffusers rejects model offload while any component still carries group hooks).

Results

Qwen-Image-2.1 qwen-image-2.1-Q8_0.gguf, 1024x1024, 25 steps, CFG 1. Timings are the median of 4 renders per cell over 2 interleaved passes. Compile is off to match Windows without Triton. ComfyUI is a current upstream build with a GGUF loader node that reads this file, the template's int8 text encoder and the same VAE.

VRAM cap Studio before Studio after ComfyUI Studio before s/step Studio after s/step ComfyUI s/step placement before -> after
24 GiB 7.81 s 4.68 s 4.46 s 0.301 0.167 0.146 DiT streamed per step -> DiT resident, encoder streamed
16 GiB OOM at image 1 7.54 s 4.99 s - 0.282 0.164 group with 8.7 GiB encoder resident (OOM) -> DiT + encoder streamed, pinned
12 GiB 18.90 s 19.40 s 5.11 s 0.451 0.447 0.169 whole-module offload (unchanged)

Spot checks, one pass each:

Case Before After
24 GiB, compile on 6.09 s 4.10 s
16 GiB, compile on OOM 6.11 s
16 GiB with a 32 GB host simulated (pin budget 2 GB, nothing pinned) OOM 12.19 s

Phase split for the 24 GiB cap (after): TE 0.35 s, denoise 4.17 s, VAE 0.11 s. Peak allocated drops from 15.7 to 14.3 GiB at 24 GiB. At 16 GiB it is 7.0 GiB.

Accuracy. Every image from this PR is either bit-identical to the pre-PR image at the same seed or within run-to-run cuDNN noise: LPIPS (alex) at most 9.5e-5, PSNR at least 58 dB, over 4 prompts per cell.

12 GiB. This PR does not change the 12 GiB tier; it stays whole-module offload. With #11764 and #11766 merged on top it measured 26.4-28.4 s -> 16.7 s in an earlier contended run.

Tests

  • tests/test_diffusion_memory.py:
    • tier choice at the 24 / 16 / 8 GiB shapes, the unknown-split fallback, fast and balanced modes;
    • encoder-only hooking, first-encoder and late-encoder refusal ordering;
    • how apply_memory_plan threads the flag;
    • the pin gate: RAM-rich, partial, unknown host memory, env override, reserve arithmetic, power-of-two pricing.
  • tests/test_diffusion_backend.py:
    • pre-cast pricing in _plan_memory, including the swap of scanned dense shards, the FLUX.1-style partial swap, never pricing below dense shards on disk, and caller overrides left alone;
    • _precast_text_encoder_mib against a fake cache, both cached and table-priced.
  • One existing expectation changed on purpose (test_plan_memory_hands_the_planner_the_text_encoder_split): that shape now picks the resident-transformer tier.
  • test_diffusion_backend.py, test_diffusion_memory.py, test_diffusion_auto_policy.py and test_video_backend.py: 966 passed on CPU. ruff check and scripts/run_ruff_format.py are clean.

How it was measured

  • In-process DiffusionBackend on a shared B200. The VRAM cap is simulated by patching torch.cuda.mem_get_info to report the card's total, minus a 1.2 GiB desktop and context share, and hard-capping the allocator with set_per_process_memory_fraction. ComfyUI ran under the same patch.
  • Each render is split at encode_prompt and vae.decode with device syncs. ComfyUI is split per node from its websocket events.
  • The GPU was shared with other jobs throughout, so absolute times moved between passes. The table interleaves arms per tier and reports medians.

Not measured

  • A real Windows machine with an NVIDIA consumer card, where WDDM spills to shared memory instead of raising OOM. The 16 GiB "before" row is an OOM here and would be a very slow render there.
  • Consumer PCIe and compute ratios. This host copies host-to-device at 24.6 GB/s pageable and 52.9 GB/s pinned, and its compute is several times a 4090's. On a consumer card, per-step streaming at 16 GiB should hide better behind the slower compute, and the encoder pass should cost more. Neither is measured.
  • Real host-RAM limits. The 32 GB case is simulated through the pin budget only.
  • Families other than Qwen-Image-2.1 on real weights. The pre-cast pricing applies wherever te_prequant_repos is set, and the new tier applies to any image load whose encoder split is known. Both are covered by unit tests only.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T18:51:56.345963Z 54183cf Manual request
🔒 Security Review ✅ Completed 2026-09-25T15:08:33.305697Z 4379853 Manual request
ℹ️ 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[bot]

This comment was marked as resolved.

load_prequant_text_encoder can return None for a cached checkpoint too, and
assembly then opens the dense shards on disk, so budget max(pre-cast, scanned
dense) whether or not the checkpoint is cached. The prefetch skips covered
shards, so the usual case is unchanged, and the resident-denoiser tier only
streams encoders, so the 24 GB placement holds even with dense shards cached.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…artly offloaded encoder before falling back

WDDM and WSL2 cap page-locked host memory near 1 GiB whatever RAM is free, so pinning a multi-GB encoder or transformer failed part way. On the resident-transformer tier the leaf hooks left by that failure made enable_model_cpu_offload reject the pipeline and the load failed. Those hosts keep the unpinned streaming they had before, and a first-encoder refusal now drops its hooks before whole-module offload takes over.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@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: 5f08f6369c

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

model_dense_mib = None
if transformer_resident is not None:
model_dense_mib = transformer_resident + (companion_mib or 0)
if companions_from_cache and text_encoder_quant is not None:

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 Reprice pre-cast encoders in override plans

When a pipeline combines a hosted pre-cast encoder with transformer quantization, the dense-quant replans pass candidate.companions_mib and candidate.text_encoders_mib, which estimate_dense_quant() derives from the dense BF16 family table. This guard prevents the new pre-cast correction from running for those overrides, so a configuration such as Qwen-Image-2.1 on a 40 GB card is charged for the 17.5 GB dense encoder rather than the roughly 9 GB artifact; the replan can consequently retain encoder-only group offload and decline or reject an explicit transformer-quant request even though the combined quantized artifacts fit resident. Apply the pre-cast replacement to these override terms as well, or scale them before passing them to _plan_memory().

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not a regression: the dense-quant replans price the encoder exactly as main does, and this PR deliberately leaves caller overrides alone (test_plan_memory_leaves_a_callers_companion_override_alone). The over-estimate errs toward more offload, never an OOM; repricing those replans is a separate change.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 24, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 5f08f6369c

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

danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 25, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 25, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@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

out = _original(grid_thw)
device = getattr(grid_thw, "device", None)
return out.to(device) if device is not None and out.device != device else out

P1 Badge Move interpolation tensors before calling the offloaded embedding

When a Qwen3-VL encoder is leaf-offloaded and an image condition is supplied, the original fast_pos_embed_interpolate() reads the still-offloaded pos_embed.weight.device and creates its interpolation weights on CPU; the embedding hook then onloads the embedding and moves its index argument to CUDA, so the original method attempts to multiply the CUDA embedding output by CPU weights and raises before this wrapper regains control. Moving out after _original() therefore cannot prevent the device mismatch; the interpolation inputs must be created on the compute device (or this embedding must remain resident) before invoking the original calculation.

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

@shimmyshimmer

Copy link
Copy Markdown
Member

@codex security review

@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: 4379853e56

ℹ️ 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 +1355 to +1359
if not stream_transformer and installed == 0:
# Resident encoder here would OOM; fall back to model offload, which rejects partial hooks.
_remove_group_offload_hooks(module)
raise
if not stream_transformer and not transformer_demoted:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Clear partial hooks after any encoder setup failure

When the resident-transformer tier has multiple text encoders, a successful first encoder makes installed > 0; if apply_group_offloading then raises after partially installing hooks on a later encoder, this branch skips _remove_group_offload_hooks(module), demotes the transformer, and subsequently calls module.to(onload) with the failed encoder's partial hook registry still attached. This can abort loading or leave an incompletely configured encoder at inference time—the same partial-install condition the installed == 0 path explicitly cleans up. Remove hooks from the currently failing encoder before either fallback path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reproduced on real diffusers pipes (tiny SD3, CUDA): the 2nd or 3rd encoder installs its hooks then raises, the load stays group and two generations are bit-identical to fully resident. The leftover hooks keep that encoder streamed, so the later .to() does not leave it resident or broken. Not a correctness issue.

Comment on lines +1166 to +1167
except Exception: # noqa: BLE001 - an unsizeable module is priced as nothing to pin
return 0

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 Disable pinning when a module cannot be sized

If tensor enumeration or numel()/element_size() fails for a custom or quantized module, returning zero makes _streamed_pin_plan treat that module as free and enable low_cpu_mem_usage=False. The new default pinning path can then pin an arbitrarily large, unsized transformer or encoder despite the host-RAM gate, recreating the host-memory exhaustion this gate is intended to prevent. Propagate an unknown-size result and conservatively leave that component unpinned instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

parameters(), numel() and element_size() do not raise on nn.Module / GGUF parameters, so the zero fallback is unreachable on real loads.

Comment on lines +1172 to +1176
total, _available = _system_memory_mib()
available = _available_system_memory_mib()
if total is None or available is None:
return None
reserve = max(_PIN_RESERVE_MIN_MIB, int(int(total) * _PIN_RESERVE_FRACTION))

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 Base the pin reserve on cgroup capacity

Under an enforcing memory cgroup, _available_system_memory_mib() is capped to the container but total still comes from host-wide physical RAM, so the reserve is calculated from a pool the process cannot use. For example, a 64 GiB container on a 512 GiB host gets a 76.8 GiB reserve and therefore a zero pin budget even when nearly all 64 GiB is available, disabling the new pinned streaming optimization. Cap the total by _cgroup_memory_limit_mib() before applying the 15% reserve, as the device-budget path already does for container capacity.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Under a tight cgroup the budget just drops to zero and nothing is pinned, which is the previous unpinned behavior: a missed speedup, not a correctness bug.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Addressed in 54183cf while merging main: #11766 now sizes its offload pin reserve from the container, so this budget caps the total by _cgroup_memory_limit_mib() the same way and reuses its constants.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4379853e56

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 25, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 27ba7c817f

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

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 25, 2026
Size the streamed-tier pin reserve from the container like _pin_host_weights (#11766) and reuse its constants.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 25, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

@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: 54183cf738

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

policy = OFFLOAD_NONE
reasons.append("weights fit resident with headroom")
elif _resident_transformer_fits():
policy = OFFLOAD_GROUP

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 Preserve resident-denoiser speed optimizations

When this encoder-only streaming tier is selected with the default or max speed mode, the OFFLOAD_GROUP policy is still translated to offload_active=True in DiffusionBackend.load_pipeline. apply_speed_optims() then disables full-graph compilation and diffusion_cuda_graph.graph_eligible() unconditionally refuses CUDA graphs because it assumes denoiser weights have onload hooks; here stream_transformer=False, so only text encoders have hooks and the denoiser's pointers remain stable. This unnecessarily removes denoising optimizations from the tier intended to run every denoise step resident; thread a transformer-offload predicate based on stream_transformer into those speed checks instead of deriving it solely from the policy.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Deliberate in this PR: the tier stays offload_policy group so every existing != none check (fullgraph compile, CUDA graphs, torchao) behaves as before. That is a missed speedup, not a correctness bug; the stacked #11883 threads a resident-transformer predicate into those checks.

@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 54183cf738

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

@danielhanchen
danielhanchen merged commit ea11ce2 into main Sep 25, 2026
34 of 37 checks passed
@danielhanchen
danielhanchen deleted the studio-gguf-resident-transformer branch September 25, 2026 18:57
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…dent when only the encoder does not fit (unslothai#11802)

* Studio: price the hosted pre-cast text encoder and keep the transformer resident when only the encoder does not fit

* Studio: pin the streamed-encoder tiers when host RAM allows, transformer first

* Studio: price only the encoder folders a pre-cast checkpoint replaces, pin at allocator size, stream the transformer if a late encoder refuses

* Format

* Studio: never price a cached pre-cast encoder below its dense shards

load_prequant_text_encoder can return None for a cached checkpoint too, and
assembly then opens the dense shards on disk, so budget max(pre-cast, scanned
dense) whether or not the checkpoint is cached. The prefetch skips covered
shards, so the usual case is unchanged, and the resident-denoiser tier only
streams encoders, so the 24 GB placement holds even with dense shards cached.

* Studio: do not pin streamed modules on Windows or WSL, and unhook a partly offloaded encoder before falling back

WDDM and WSL2 cap page-locked host memory near 1 GiB whatever RAM is free, so pinning a multi-GB encoder or transformer failed part way. On the resident-transformer tier the leaf hooks left by that failure made enable_model_cpu_offload reject the pipeline and the load failed. Those hosts keep the unpinned streaming they had before, and a first-encoder refusal now drops its hooks before whole-module offload takes over.

* Studio: trim comments

* Studio: do not add a pre-cast encoder on top of a bf16 table-priced pipeline

* Format

* Studio: price HiDream's hosted fourth text encoder in the memory plan

* Studio: price an uncached HiDream fourth encoder from its own size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants