Rebased onto current master, which already contains the guard-then-load
fix (fd2c6a5) and the re-patch pending-preservation fix (143883c) from
the earlier review -- verified both satisfy the four requirements from
the review comment (unselected-key pending preserved across copies,
lazy-origin keys keep pending while loaded, re-patch replaces pending
config, remove_hicache still drops everything) by reading the code and
re-running the full suite (15/15 green before this commit).
The one thing genuinely untested was the real unload mechanic:
Trellis2ImageTo3DPipeline.unload_sparse_structure_model /
unload_shape_slat_flow_model_512 do `del self.models[key]` followed by
`self.models[key] = None`, not a direct reassignment. Verified by hand
first (see the del/None/reload trace in the PR thread) that `del` only
removes the dict entry and never touches `_pending` (a separate instance
attribute), so the reload still re-wraps correctly -- then encoded that
as a proper regression via a GGUFLikeLazyPipe fixture that mirrors the
real pipeline's load_*/unload_* method pairs (guard-then-load AND
del-then-None) across two independently-cycled stages, per the request
for either a small multi-stage fixture or lifecycle documentation.
16/16 tests green, ruff clean.
pipeline.models[key] is None at patch time for GGUF Trellis2 pipelines
(Aero-Ex/ComfyUI-Trellis2-GGUF) that lazy-load the flow DiT inside the
sampler. nn.Module.__setattr__ only routes real Modules into _modules, so
self.inner = None became a plain __dict__ attribute that nn.Module.__getattr__
never searches, and the fallback raised 'object has no attribute inner'.
- store inner via _set_inner: real Modules stay registered submodules, None/
lazy placeholders are kept as a plain attribute; __getattr__ resolves both
- clear errors when a compute step / attribute access hits an unloaded model
- bind_inner(model) to attach the real DiT once it materializes
- _LazyPatchDict binds the model transparently when the sampler assigns it
into pipeline.models[key] (TRELLIS repos), so the cache survives lazy load