Conversation
merceod
force-pushed
the
model/flux2-klein
branch
from
September 22, 2026 09:07
0dc334b to
e42a092
Compare
2 tasks
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?
Stacked on #286 (
engine/dit-scaffold); this PR adds the two model packages, their configs, tests and benchmarks.Numerics: the eager path is bit-exact with diffusers for klein-4B and 9B (text-to-image, single- and two-reference edits) and Z-Image-Turbo (including captions beyond the captured buckets). With the shipped defaults the klein transformer is bit-exact in the served path too (
compile_exact_ops: [norms]keeps the norms on the eager kernels inside the compiled forward; a plain compile landed at a median 35-38 dB from the eager path over the 100 prompts); the remaining deviation is the autotuned VAE, at least 53 dB on every prompt, andvae_compile: falsemakes the served output bit-exact. Z-Image ships the plain compile (median 34 dB) because keeping its norms eager costs 45%;compile_exact_ops: [norms]is the documented alternative. Also verified served: rows are independent of their batch neighbours bit for bit, edits batch and match their solo images, the API probe (formats,n, error paths, uploads, disconnects) passes, and a 60-minute mixed-size soak ran 15983 images with 0 errors and flat memory.Benchmarks (protocol table; 1x H100 80GB HBM3 on one node, driver 580.173.02, torch 2.11.0+cu128, FlashInfer 0.6.18.post1; 100 fixed prompts, seed = prompt index; latency n=20 after 3 warmups, throughput median of 3 x 32 images per concurrency level; M* rows re-measured 2026-09-21 on the shipped defaults, baselines from 2026-09-18)
JPEG output (
output_format: jpeg) saves about 30 ms per image on the M* rows. Exactness costs: klein withcompile: false0.461 s / 2.5 images/s (compiled VAE) or 0.523 s bit-exact; Z-Image withcompile_exact_ops: [norms]1.25 s / 0.80 images/s.Reproduction (same GPU, same node, back to back; the client is
benchmark/flux2_klein/bench_images.py)How was it tested?
python -m pytest test/modularat the head, 1002 passed / 142 skipped (tiny-config bit-exactness of both ports, graph/walk structure, batching, output formats, knobs, the PSNR and summary tools).test/flux2_klein/record_oracle.py --refs 2,test/z_image/record_oracle.py):test_flux2_klein_reference_equivalence.pyfor 4B and 9B (FLUX2_KLEIN_REPO),test_z_image_reference_equivalence.py, all steps 0.0 and images PSNR inf.test_flux2_klein_batch_invariance.py,test_z_image_batch_invariance.py; served probesbenchmark/flux2_klein/{batch_invariance_client,edit_probe,api_probe,soak}.py.Known gaps
vae_compile: falseavoids it. Z-Image's transformer output also depends on the batch size it ran in (cuBLAS/cuDNN algorithm choice, 31-39 dB vs the single-row image; rows are independent of each other).-basecheckpoints is not implemented.Checklist
ruff check .passes