[draft] Attempt to implement the Flux Klein bonsai model - #1
Closed
Juste-Leo2 wants to merge 7 commits into
Closed
Conversation
- Add FLUX.2 tensor name mappings for shared modulation, fused single-block QKV+MLP, and separate double-block Q/K/V - Add SelfAttention fused_qkv option for separate Q/K/V weights - Add sharded safetensors loader for LLM text encoder - Add image-studio workspace
…Bonsai) VAE config has 'force_upcast: true', which diffusers uses to cast the entire VAE to float32 before decode. C++ has no equivalent, causing yellow/chroma noise in output. Workaround: set expected_type = GGML_TYPE_F32 on all first_stage_model tensor entries before ae.init().
Owner
Author
|
The conversation below is interesting and might provide some insights for the future (see leejet#1580) |
Owner
Author
|
I don't think this approach will work. So I'm going to fall back on the method suggested in this discussion leejet#1580 . I'm closing this PR and will open another one for potential operational optimizations. |
…compat Diffusers stores shift/scale in opposite order from what the C model expects. Swap the two halves after loading to produce correct images.
Owner
Author
|
Well, I got this branch working again :) |
…r Flux2/Bonsai)" This reverts commit ce0fc14.
Owner
Author
|
In the end, I think I'll close this branch, even though it works. It's best to keep the original implementation; modifying Safetensor makes the code easier to read. |
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.
This draft adds the necessary mappings to make the dequantized 4B model work.
Opencode was used, but I am noticing significant differences during inference that I haven't been able to patch using DeepSeek Flash on Opencode.
Here are some avenues to explore:
I suspect the problem lies either in the denoising process or in the VAE conversion. However, despite comparing it with the Python implementation, I haven't been able to pinpoint the issue yet. Any help would be greatly appreciated!
Here is an inference example:
Here is the result using the Python reference:
Here is the result using the fork:
