$ show Tencent-Hunyuan/HY-WU
HY-WU is a machine learning application for text-guided image editing that implements a Functional Neural Memory framework. The system generates instance-conditioned LoRA (Low-Rank Adaptation) weights on-the-fly from hybrid image-instruction representations and injects them into a frozen backbone model (HunyuanImage-3.0-Instruct) during forward pass, enabling test-time adaptation without optimization. The architecture centers around a WUPipeline orchestrator that coordinates a parameter generator, the base model with PG mixin integration, and image processing components. Key entry points include the infer.py CLI script and gradio/app.py web interface. The system processes user prompts and input images through VAE encoding, condition extraction, parameter generation, LoRA injection, and image decoding to produce edited outputs.
The LLM identified 3 files worth highlighting for reuse:
The PGMixin class provides a reusable way to add LoRA-based parameter generation to any PyTorch module. It cleanly separates base model functionality from LoRA adaptation, supporting both standard nn.Linear modules and custom modules with specialized LoRA forwarding. Features include lazy device transfer, activation tracking, and minimal coupling (only imports torch and typing), making it easily extractable for other projects requiring parameter-efficient adaptation.
Tokenizer2DBatchedLoRA implements a novel 2D tokenization scheme for LoRA weights that efficiently packs/unpacks weight matrices into token grids. It handles standard LoRA parameters and grouped entries for Mixture-of-Experts layers, providing a clean interface between weight matrices and token representations. This solves the recurring problem of transmitting LoRA parameters in vision-language models and demonstrates non-obvious skill in its tensor manipulation strategies.
Implements advanced caching mechanisms for diffusion model inference, including TaylorCacheContainer for storing higher-order derivatives and CacheWithFreqsContainer combining Taylor caching with FFT-based frequency decomposition. The decomposition_FFFT function efficiently separates low/high frequency components for selective caching. These techniques reduce inference computation while maintaining quality, representing a sophisticated optimization pattern applicable to various iterative generative models.