# One more measured note for diffusers — named containers never hook as blocks

> Source: <https://discuss.huggingface.co/t/one-more-measured-note-for-diffusers-named-containers-never-hook-as-blocks/192464#post_2>
> Published: 2026-11-29 08:52:15+00:00

**Recommendation:** Use automatic block grouping for ordinary ModuleList blocks and drop redundant list names; diagnose with a fresh model, block_level, group size one and use_stream=False, then verify repeated forwards match a no-offload reference before measuring memory or speed.
More in the playbook "Inference and self-hosting": <https://wpnews.pro/playbooks/inference-serving>

In addition to counting the groups, I also checked whether the hooks actually fired and compared the outputs:

I tested the three-plus-two-block selection difference with real Diffusers hooks on a small CUDA model.

[PR #15409](https://github.com/huggingface/diffusers/pull/15409), addressing [issue #15386](https://github.com/huggingface/diffusers/issues/15386), merged on November 28, 2026. It warns and ignores redundant `ModuleList` names, preserving child grouping. Named `Sequential` modules still take the explicit selection path.

On a Tesla T4 I used three FP32 Linear/Tanh blocks in one container and two in another, not a FLUX checkpoint. Both names were supplied, with group size one and streams enabled.

| Observation | Released 0.43.0 | With the ModuleList change | 
|---|---|---|
| Unique groups / registered group-hook entries | 2 / 2 | 5 / 5 | 
| Hook locations | The two containers | The five children | 
| Input and weight at the first block’s computation | CUDA input, CPU weight | Both CUDA | 
| Onload / offload method calls during the first attempted forward | 0 / 0 | 5 / 5 | 
| Output comparison against a no-offload reference | Stopped at a device-mismatch check | Max absolute difference 0.0 on each of three forwards | 

The failure was an explicit device check in my block immediately before Linear, not an uninstrumented PyTorch matmul exception. Transfer counts are real group method invocations, not every hook callback or a GPU copy trace. Both the functional-hunk variant and the fixed source gave the result on the right.

A directly called named `Sequential` already worked with two parent groups. Manually iterating its children bypassed those groups and triggered the guard. The actual call boundary matters.

The latest [release](https://github.com/huggingface/diffusers/releases/tag/v0.43.0) on November 29 was still 0.43.0 (November 12). The tested fixed revision was `ffd566461df1ab130c46bee8b0131469bcc756ed`; it was not the released wheel.

Start with automatic grouping for ordinary `ModuleList` blocks. Removing redundant names avoids the old selection branch.

Omitting `block_modules` or setting `None` can select the model’s `_group_offload_block_modules` defaults; `[]` bypasses that fallback in the inspected versions. Preserve custom callable parent names that are actually needed.

| Situation | First thing I would try | 
|---|---|
| Ordinary ModuleLists, no special parent selection needed | Use automatic block grouping. | 
| Pinned to 0.43.0 and supplying redundant list names | Remove the redundant names; check whether a model default reintroduces them. | 
| Model default only contains redundant lists | An explicit empty list is a candidate on the old release; verify the resulting groups. | 
| Model default also identifies real callable parent modules | Preserve those deliberately selected parents; remove only the redundant list entries if needed. | 
| Sequential or custom container is called as a unit | A parent-level group can be intentional. | 
| Children are called individually instead | Prefer a grouping boundary that the real forward path reaches. | 

Start diagnosis with a fresh model, `block_level`, size one, and `use_stream=False`; repeat with streams at size one and multiple forwards once correct. Turning off streams does not fix the named-list selection problem.

See the [memory optimization guide](https://huggingface.co/docs/diffusers/optimization/memory) for configuration options.

The counting result therefore has an execution counterpart. The merged change restores child grouping for redundant ModuleList names; matching group ownership to actual execution and checking repeated reference parity are useful before measuring memory or speed.
