Completed: Z-Image native inpaint¶
Metadata¶
- Created: 2026-06-15
- Status: Completed
- Completed: 2026-06-21
ADR status¶
- Governing ADRs: ADR 0001, ADR 0002
- ADR impact: No new ADR was required. The shipped path stays explicit, fail-closed, and inside the existing image-to-image contract.
Outcome¶
Completed as the first narrow native inpaint route for the existing Z-Image family.
MLX-Gen now:
- exposes
z-image.inpainton the exactAbstractFramework/z-image-turbo-8bitrow; - accepts the generic
--image + --mask-path + --promptrequest shape through unifiedmlxgen generate; - rejects
--mask-pathwithout--image; - rejects
--image-strengthtogether with--mask-pathinstead of silently falling back to latent img2img; - publishes an accepted same-prompt same-seed engine-thruster proof against the previous latent route.
Closing code reality¶
src/mflux/models/z_image/variants/z_image.pynow implements native inpaint as a distinct masked route:- source image latents are encoded explicitly;
- mask latents are built in latent space;
- unmasked regions are preserved through per-step latent blending;
image_strengthandmask_pathstay mutually exclusive.src/mflux/models/z_image/cli/z_image_turbo_generate.pynow exposes--mask-pathand fails closed on invalid combinations. (Correction 2026-07-15: this item originally claimed both Z-Image CLIs gained--mask-path, but only the turbo command did; the non-turboz_image_generate.pycommand gained it in completed item 0082 when the non-turbo route was opened.)src/mflux/task_inference.pynow surfaces a distinctz-image.inpaintcapability only on the exact Z-Image Turbo rows that were intentionally opened for this route.tests/image_generation/test_masked_generation_routes.py,tests/cli/test_mlx_gen_router.py, andtests/test_task_inference.pynow lock the mask-route math, routing, and error contract.
Validation¶
Focused automated validation:
tests/image_generation/test_masked_generation_routes.pytests/cli/test_mlx_gen_router.pytests/test_task_inference.pytests/arg_parser/test_cli_argparser.py
Accepted published proof bundle:
- native inpaint report
- native inpaint command log
- native inpaint stats
- native inpaint full contact sheet
- native inpaint crop sheet
- native inpaint output
- latent baseline output
Accepted result on the public engine-thruster proof row:
- model:
AbstractFramework/z-image-turbo-8bit - latent baseline: same source, same prompt, same seed,
--image-strength 0.35 - native inpaint: same source, same prompt, same seed,
--mask-path - latent baseline timing:
2.78sgeneration,5.99swall,11.49 GBmax RSS - native inpaint timing:
21.00sgeneration,26.86swall,18.11 GBmax RSS
Maintenance update on the accepted route:
- the route now invalidates cached source/mask conditions when those files change in place;
- the accepted published output was refreshed after the runtime tune because the current native inpaint result is cleaner in the masked thruster region while keeping the same narrow public proof contract.
The public claim stays intentionally narrow: exact q8 Z-Image Turbo row, exact engine mask case, same-prompt same-seed comparison against the old latent route.
Related backlog items¶
Follow-ups¶
- Keep
controlnet_inpaintseparate in 0045. - If future Z-Image native inpaint proofs broaden beyond the engine case, publish them only after they are clearly good enough for the public validation surface.