Repository navigation
Add Bria fibo-2 - #14991
Open
muhammadali-afridi wants to merge 1 commit into
Open
Add Bria fibo-2#14991muhammadali-afridi wants to merge 1 commit into
muhammadali-afridi wants to merge 1 commit into
Conversation
muhammadali-afridi
force-pushed
the
ali/fibo2
branch
2 times, most recently
from
October 15, 2026 08:47
e3fdebc to
2b7b792
Compare
muhammadali-afridi
marked this pull request as ready for review
October 15, 2026 08:51
muhammadali-afridi
force-pushed
the
ali/fibo2
branch
2 times, most recently
from
October 15, 2026 09:36
553af68 to
5c38cb1
Compare
fibo-2 is Bria's 8.1B flow-matching DiT, built on the Z-Image block and
conditioned on Qwen3-VL hidden states two ways: a Perceiver resampler turns
them into gist tokens that share the stream with the image tokens, and five
blocks add gated cross-attention to their own bundle of Qwen3-VL layers. It
uses the Flux 2 VAE.
One pipeline class covers both of the model's jobs and both checkpoints:
text-to-image generation, instruction editing of up to five images with an
optional mask, the turbo checkpoint (4 steps, no guidance) and the guided one.
- BriaFibo2Transformer2DModel, with images to edit passed as context latents
- BriaFibo2Pipeline, including:
- captions cleaned and serialized the way training did, for generation and
edits, in every caption form fibo-2 was trained with: a full caption, a
short description, or a short description with its text_render list
- images of the caption's text, which Qwen3-VL sees beside the prompt:
drawn the way training drew them, by default (`render_text_images`), or
passed as `text_images`
- masked edits, the region greyed out through a binary mask as in training
- a conversion script from the original checkpoint layout
- model and pipeline tests, and docs
Verified against Bria's reference implementation on an A100 and an H100.
muhammadali-afridi
force-pushed
the
ali/fibo2
branch
from
October 15, 2026 10:55
5c38cb1 to
4f7c850
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds fibo-2, Bria's text-to-image and image-editing model.
BriaFibo2Transformer2DModel: an 8.1B flow-matching transformer with a single token stream, in the style of Z-Image. Its text encoder is Qwen3-VL-4B.context_latents. Each is patchified by the shared embedder and gets its own RoPE plane.BriaFibo2Pipeline:"structured_caption": "..."in an edit), or a short description with itstext_renderlist;render_text_images=Falseturns them off), or the caller passes them astext_images.The checkpoint runs 30 steps with guidance 5, the pipeline's defaults. The pipeline also runs few-step distilled checkpoints:
guidance_scale=1.0turns guidance off.scripts/convert_bria_fibo2_to_diffusers.pyconverts the original checkpoints.Docs and tests.
Weights: the docs point to
briaai/fibo-2, where the weights will be released. The repo is private until then, and we're happy to give reviewers early access.Verification
I compared the pipeline against Bria's reference inference code, using the original checkpoints, the same seeds and bf16:
A100, SDPA:
H100: the reference code runs FlashAttention-3 there. With
pipe.transformer.set_attention_backend("_flash_3_varlen_hub"):Prompts and text images: compared with Bria's training and evaluation code, every prompt is byte-identical:
The drawn images are also byte-identical on 17 test strings, including non-Latin scripts, wrapped lines and characters no font has.
Text-encoder images: by default the pipeline thumbnails each image straight to 768 px for Qwen3-VL, as in training. The reference code upsamples 4脳 first, which changes that input slightly.
Batching: in float32, a batch of prompts of different lengths matches the separate single-prompt calls. This includes the varlen attention backends; see the self-review notes.
Checks (rebased on
main):make style,make qualityandmake fix-copiespass.check_copies,check_dummies,check_support_list,check_forward_call_docstringsandcheck_return_annotationspass.New tests: they pass on a Mac (CPU/MPS), except the group offloading and layerwise casting memory tests. Those fail the same way for Z-Image and Flux 2 on that machine, because MPS has no CUDA streams and no float8.
Notes
briaai/fibo-2before the release.mask: fibo-2 was trained on edits whose image has the region to regenerate greyed out. The pipeline does the same: flat (128, 128, 128) grey, through the mask made binary at 128.fontsfolder ofbriaai/fibo-2only when a text first needs them, so ASCII text never downloads anything. The fonts are already inbriaai/fibo-2/fonts/.aesthetic_scoreandpreference_scorefields. The pipeline drops them from text-to-image and edit captions alike and serializes compactly. The negative prompt is used as given.Self-review notes
I ran the
self-reviewskill on the diff.Fixed:
forwarddocstring had noReturns:section, whichcheck_forward_call_docstringsflags.flash_varlen,_flash_3_varlen_hub,sage_varlen) keep the firstmask.sum()keys, so they kept the wrong ones.test_padded_batch_matches_single_promptscovers this.__call__read the first image's size beforecheck_inputshad validated it.Not fixed, on purpose:
RopeEmbedder, copied from Z-Image, builds its frequency table under a device context on first use. Z-Image skips these tests for the same reason.torch.compile(transformer)..tolist().compile_repeated_blocks) is not affected.Before submitting
self-reviewskill on the diff?Who can review?
@yiyixuxu @sayakpaul @DN6
馃 Generated with Claude Code