Skip to content

Commit 6d2b69d

Browse files
committed
MOSS-Image: sm_89 (RTX 4090) loads the transformer, checked as on the GB10 and 5090
1 parent 667839f commit 6d2b69d

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

‎docs/recipes/moss-image-cuda.md‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Metal. It is a denoiser, not a token family: it does not register with the lane
1616
The config, the rotary tables and the timestep's modulation (`config.zig`, `host.zig`) are shared with Metal. The
1717
weights are checked as on Metal: the released geometry only, and no tensor left unread.
1818

19-
It runs on the two GPUs it was checked on, sm_120 (RTX 5090) and sm_121 (GB10): `Model.load` refuses any other.
19+
It runs on the three GPUs it was checked on, sm_89 (RTX 4090), sm_120 (RTX 5090) and sm_121 (GB10): `Model.load`
20+
refuses any other.
2021

2122
## Precision
2223

@@ -69,7 +70,7 @@ SUMMARY moss image: 8 kernels, 8 pass gates 1-4, 0 fail; 5 controls: 5 red as pl
6970
```sh
7071
hf download OpenMOSS-Team/MOSS-Image-Base --revision 85975793d8b3d432f1b6e27f352abaa4c2a4c0d3 --local-dir MODEL_DIR
7172
python3 tools/zig/moss_image_case.py case MODEL_DIR case/ --prompt-file prompt.txt --device cuda
72-
zig build install -Doptimize=ReleaseFast -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=121 # -Dsm=120 for an RTX 5090
73+
zig build install -Doptimize=ReleaseFast -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=121 # 120: RTX 5090, 89: RTX 4090
7374
zig-out/bin/tf-moss-image MODEL_DIR/transformer case/case.safetensors case/
7475
python3 tools/zig/moss_image_case.py decode MODEL_DIR case/latents.f32 case/zig.png --device cuda
7576
python3 tools/zig/moss_image_case.py compare case/reference.png case/zig.png case/side.png
@@ -121,3 +122,23 @@ velocities and float32 runs as recorded on the GB10):
121122
- **Memory:** the transformer's bf16 weights (9.5 GB) on the device, plus scratch sized at load for one image and the
122123
longest prompt: 0.51 GB at 1024x1024 with a 34-row prompt (from the allocations, not measured), and cuBLASLt's
123124
32 MiB workspace.
125+
126+
Results on an RTX 4090 (sm_89, 24 GB, Windows 11, driver 616.56, nvcc 13.3), with the cases made on the same card
127+
(torch 2.12.0, diffusers 0.42.1, transformers 5.22.1) from the recipe's fox and sticky-note prompts and seeds:
128+
129+
- **Contract:** `tf-cuda-test moss-contract` gives the same summary line as above (8 kernels pass gates 1-4, 5 controls
130+
red as planted).
131+
- **Velocity:** against torch bf16, cosine 0.99972 to 0.99998 (fox) and 0.99978 to 0.99998 (sticky note). Against the
132+
float32 run, mean 1 - cosine: fox prompt 1.600e-4 (torch bf16's own 1.609e-4), negative 1.702e-4 (1.696e-4); sticky
133+
note prompt 1.652e-4 (1.638e-4), negative 1.791e-4 (1.791e-4). Ours is the closer at 25 and 20 of the fox's steps,
134+
22 and 23 of the sticky note's.
135+
- **Image:** 46.54 dB PSNR from the pipeline's picture for the fox, 29.85 dB for the sticky note (its handwritten text
136+
the same). Against a float32 run of the whole schedule, over the 8 cases (both prompts, seeds 42/7, 1, 2, 3), ours is
137+
the closer in 5, at a mean of 31.62 dB against torch bf16's 31.35 dB.
138+
- **Repeat:** identical bytes, the same step twice and two runs of the fox case.
139+
- **Speed**, the GPU otherwise idle:
140+
- torch bf16: 0.490 s a forward for the fox, 0.499 s for the sticky note (the median of its 100).
141+
- Ours: 0.352 s and 0.358 s, 1.39x torch's (35.2 s and 35.8 s for 50 guided steps). Load 4.6 to 5.0 s.
142+
- **Memory:** as on the 5090. The case tool's own pipeline holds the 16 GB encoder and the transformer at once, which
143+
does not fit in 24 GB: the cases above were made with the encoder and transformer taking turns on the card (the
144+
float32 transformer converted on the host), the publisher's code otherwise unchanged.

‎zig/src/families/moss_image/cuda_model.zig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ pub const Model = struct {
114114
/// The timestep `mods` holds, if any.
115115
timestep: ?f32 = null,
116116

117-
/// The transformer of `dir` for prompts of up to `max_text` rows and one image size, on sm_120 or sm_121 only.
117+
/// The transformer of `dir` for prompts of up to `max_text` rows and one image size, on sm_89, sm_120 or sm_121 only.
118118
pub fn load(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: []const u8, max_text: usize, width: usize, height: usize) !*Model {
119119
const d = ctx.d;
120120
const sm = try ctx.capability();
121-
if (sm != 120 and sm != 121) {
122-
std.log.err("moss image: sm_{d} is not a GPU this family was checked on (sm_120, sm_121)", .{sm});
121+
if (sm != 89 and sm != 120 and sm != 121) {
122+
std.log.err("moss image: sm_{d} is not a GPU this family was checked on (sm_89, sm_120, sm_121)", .{sm});
123123
return error.UncheckedGpu;
124124
}
125125
const g = try cfg.grid(width, height);

0 commit comments

Comments
 (0)