Views
No views yet
coreai-torch (LLMs: coreai.llm.export) into .aimodel bundles that run on the GPU or the Neural Engine, e.g. Qwen3-8B 4-bit decodes at 94 tok/s on an M4 Max GPU, MLX 90 under the same protocol (apple-silicon-llm-bench, macOS 27 beta, 2026-06).| file | role | size |
|---|---|---|
zimage_dit_..._dyncap_dynimg_iofp32.aimodel | the DiT — any resolution, any prompt length | 11 GB |
zimage_encoder_seq64_full_bf16_ids_iofp32.aimodel | Qwen3 encoder → penultimate hidden; embed_tokens is inside the graph | 7.3 GB |
zimage_vae_{256,512,1024}_fp32.aimodel | 16ch VAE decoder (per-size) | 189 MB each |
glue/ | RoPE tables + a t_embedder graph | 2.4 MB |
tokenizer/ | Qwen2 BPE | 15 MB |
--io-fp32). That is not a preference:
a Swift host cannot fill or read a bfloat16 NDArray, and bf16 is the only dtype this DiT is
numerically safe in. Casting at the boundary costs ~15 % per forward and improves fidelity
(PSNR 39.5 → 42.6 dB) because nothing rounds on the way in.glue/ is what keeps a host from re-implementing the reference: RopeEmbedder is a
per-axis table lookup, so three tables reproduce it exactly at any resolution and prompt
length, and the timestep MLP ships as a 2 MB graph.diffusers reference)| s/forward | denoise (8 steps, CFG = 16 forwards) | PSNR | |
|---|---|---|---|
| 256² | 0.36 | 5.8 s | 35.6 dB |
| 512² | 1.12 | 17.9 s | 42.6 dB |
| 1024² | 4.36 | 69.7 s | 42.3 dB |
ZImagePipeline.swift;
the Python twin is
conversion/zimage/pipeline_engine.py.
Both agree with the fp32 reference to ~42.6 dB.1# per step, for cond and uncond:
2# ins = build_native_inputs(rm, latent, cap) # patchify + RoPE + pad masks
3# v = dit(**ins, adaln=t_embedder(t * t_scale)) # Core AI graph
4# vel = unpatchify(v[:, :n_img])
5# noise_pred = -(pos + guidance * (pos - neg)) # Z-Image CFG is NEGATED
6# latent += dsigma[s] * noise_pred # FlowMatchEuler
7# image = vae(latent) # unscale: z/0.3611 + 0.1159hidden_states[-2]);-(pos + g·(pos − neg)), not neg + g·(pos − neg);n_cap = round_up(L, 32) must match, and cond/uncond generally
have different n_cap (hence the dynamic caption axis).coreai-build compile refuses a bf16 module, which iOS
needs for graphs this size. Full analysis in the
port notes.guidance=0 skips CFG — half the work, a different composition, still clean at 256².