Skip to content

Add Bria 3.2 text-to-image generation node#39

Open
georgi wants to merge 2 commits into
mainfrom
claude/bria-3-2-node-cx61H
Open

Add Bria 3.2 text-to-image generation node#39
georgi wants to merge 2 commits into
mainfrom
claude/bria-3-2-node-cx61H

Conversation

@georgi

@georgi georgi commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for Bria 3.2, a commercial-ready text-to-image generation model, as a new HuggingFace pipeline node. Bria 3.2 is trained entirely on licensed data and offers high-quality image generation with accurate text rendering capabilities.

Key Changes

  • New Bria node class (src/nodetool/nodes/huggingface/text_to_image.py):

    • Implements Bria class extending HuggingFacePipelineNode
    • Configurable parameters: prompt, negative prompt, guidance scale, inference steps, dimensions, seed, sequence length, and memory optimization flags
    • Sensible defaults tuned for Bria 3.2 (guidance_scale=5.0, steps=30, max_sequence_length=128)
  • Precision handling (_apply_precision_fixes method):

    • Casts T5 text encoder to bfloat16 for efficiency while keeping the final dense layer in float32 (Bria-specific requirement)
    • Keeps VAE in float32 when shift_factor is zero (VAE doesn't support mixed precision)
    • Includes error handling with informative logging
  • Memory optimization (move_to_device method):

    • Supports CPU offloading to reduce VRAM usage
    • Handles device movement with proper error messages for out-of-memory scenarios
    • Enables attention slicing on GPU to further reduce memory footprint
    • Disables CPU offload when moving to CPU for better performance
  • Comprehensive test suite (tests/test_text_to_image_bria.py):

    • Tests node metadata and configuration
    • Validates precision fixes for both zero and non-zero VAE shift factors
    • Tests device movement behavior with and without CPU offload
    • Includes mock pipeline classes for isolated testing
  • Metadata registration (src/nodetool/package_metadata/nodetool-huggingface.json):

    • Registers Bria node with UI metadata
    • Specifies basic fields (prompt, height, width, seed) for simplified UI
    • Includes recommended model configuration pointing to briaai/BRIA-3.2

Notable Implementation Details

  • Uses async/await pattern with asyncio.to_thread() for non-blocking pipeline execution
  • Implements reproducible generation via optional seed parameter (-1 for random)
  • Includes progress callbacks during inference for UI feedback
  • Properly handles generator creation on CPU for reproducibility
  • Follows existing HuggingFace node patterns for consistency with other text-to-image models

https://claude.ai/code/session_017UVzej67SDCFVHVfe6VQ2n

claude added 2 commits June 1, 2026 07:22
Implement a Bria node wrapping the diffusers BriaPipeline for the
briaai/BRIA-3.2 commercial-ready text-to-image model. Follows the
Flux-based Chroma node pattern (CPU offload, attention slicing, VAE
optimizations, progress callback) and applies Bria's required precision
fixes: T5 text encoder in bfloat16 with its final dense layer kept in
float32, and the VAE kept in float32 when shift_factor is 0.

Regenerated package metadata for the new node.
Covers node metadata/defaults, the recommended BRIA-3.2 model, the
Bria-specific precision fixes (T5 bfloat16 with float32 final dense
layer, VAE float32 only when shift_factor is 0), and move_to_device
behavior with and without CPU offload using a mock pipeline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants