1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Z-Image-Turbo on native Metal (plan WP3). OWNER: WP3 — this file only.
//!
//! Implements the `gpu::zimage_*` / `gpu::vae_decode_chain` contract
//! (`gpu.rs`, "Z-Image-Turbo device contract"). Rules (plan §2.2):
//! - reach the parent's private kernels, MSL sources, `ctx()` and buffer
//! pools through `super::`; new MSL goes into this module's own library
//! string; never edit parent functions;
//! - build pipelines into a module-local, lazily created cache (`OnceLock`);
//! never add fields to the parent's context struct;
//! - `release` touches module-local state only and must never bring a
//! device up (it is called unconditionally by `gpu::zimage_release`);
//! - every entry returns `false` before changing any output when it cannot
//! honour the full contract — the caller then runs the CPU path.
//!
//! The module is `pub` (doc-hidden) so WP3's examples/tests can reach
//! `pub` helpers added here without touching `gpu_metal.rs`.
//!
//! WP0 state: stubs, every entry declines.
use crate;
use CmfModel;
use Arc;
/// Build/refresh the per-(prompt, resolution) state for `a.key`.
pub
/// One DiT forward for a prepared `a.key`; writes `a.out`.
pub
/// Drop all module-local device state (prepared states, VAE chain).
pub
/// Unmodulated context refiner on the device (s = 0, gate = 1).
pub
/// Resident Flux-VAE decoder; `z` is already de-normalised.
pub