diff --git a/README.md b/README.md index 5230502..3317cf7 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,11 @@ The node pipeline is as follows: Region Mask Generator --> Region Mask Processor ![ComfyUI Screenshot](https://gseth.com/images/SNAG-4957.png)
-**Xformers & Token Limits:** The pipeline here needs VRAM to be stored in the same GPU while Flux, LoRA, and Dual Clip are loaded. Due to this, XFormers is required to optimize VRAM Usage. The total tensor size is approximately 5000x5000 for a 24GB VRAM GPU. This limit is set on purpose for consumer-grade hardware and will be increased with the release of a 5090 GPU. Due to this tensor size limitation, token size is also limited when using Dual Clip. Single Clip is not recommended. Use only Dual Clip. When Base Plus all 3 Regions are connected, a max token for each clip l and t5xxl should be 80 or less. 160 Tokens when combined. In other words, you can use (160 x 4 = 640) tokens in total before running into a tensor size error. Reduce prompt tokens when you get a tensor size error. This system was implemented to avoid any OOM errors (out-of-memory errors) on a 24GB VRAM GPU. All testing has been done on Flux 1.dev model with FP8 and t5xxl with FP 16 without any OOM on a 4090. +**Xformers & Token/Attention Limits:** The pipeline uses an advanced attention mechanism that combines text tokens from your prompts with spatial information from defined regions. As you increase prompt length or add multiple, complex regions, you create larger attention matrices. While xFormers helps optimize memory usage, there is still a practical limit on how many tokens and spatial positions the model can handle without causing dimension or shape alignment errors. + +Example Error: 'Invalid shape for attention bias: torch.Size([1, 24, 5264, 5264]) (expected (1, 24, 5118, 5118))' + +This limit isn’t about a fixed “5,000 x 5,000” size or a strict VRAM cap. Instead, it’s determined by the model’s architecture and how tokens are combined with spatial positions. Extremely long prompts or too many intricate regions can produce attention shapes that the model’s code cannot process, resulting in shape mismatch errors rather than running out of memory. If you encounter these errors, try shortening your prompt or reducing the complexity of your regional conditioning. There isn’t a simple formula linking VRAM size directly to token count. Instead, it’s about balancing your prompt length and region definitions to keep the attention mechanism within workable limits. Testing with the Flux model and T5-XXL in FP16 on a 4090 shows that keeping prompts relatively short (each clip under 80 tokens) and regions manageable helps avoid such issues. **GGUF & CivitAI fine-tune models:** The Flux Region Pipeline was tested with GGUF models without issues. Third-party CivitAI Copax Timeless XPlus 3 Flux models also worked without problems. @@ -261,7 +265,7 @@ Color Manipulation: Base Conditioning (ignored) + 2 Regions ![ComfyUI Screenshot](https://gseth.com/images/region_control_15.png) ![ComfyUI Screenshot](https://gseth.com/images/region_control_16.png) -**YouTube tutorial Flux Region Usage: Coming Soon** +**YouTube tutorial Flux Region Usage: Flux Region Spatial Control Tutorial** ### YouTube ComfyUI Tutorials @@ -274,6 +278,10 @@ Black Forest Labs, a pioneering AI research organization, has developed the Flux For more details on these models, their capabilities, and licensing information, you can visit the Black Forest Labs website +### Flux Regional Spatial Control Acknowledgment + +Inspired from: Flux Region Attention by Attashe + ### License This project is licensed under the MIT License.