mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
d877f150a06f4fdfd3a7e01acfe7be4dde844ca4
19
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ce64edfe78 |
image: the steps between the image parts as stable-diffusion.cpp makes them (step 5, joined program, piece 1)
src/image/pipeline/qi21_glue.cpp (include/strata/image/qi21_image.hpp): the starting latent from the noise (DiscreteFlowDenoiser::noise_scaling on a zero latent), the condition from the text encoder's rows (apply_token_weights, then the system rows dropped) and the decoder output to 0..1 (scale_tensor_to_0_1), each in sd.cpp 2988060's float order with contraction off; and the PNG parameters text. Used only by the strata-image test program; nothing shipped calls it. Tests: tools/test_qi21_glue.py (numpy float32 expectations, -O2 and -O3 -ffp-contract=fast; p1006 2 passed); strata-glue-check on sd.cpp's own dumps on the GB10: the starting latent from sd.cpp's noise.bin is byte-identical to its first DiT input at 512 and 1024, seeds 42 and 1234 (dgxspark-20261111-0744-db66). |
||
|
|
9b4cedd08d |
image: the latent's VAE input and the 8-bit picture as stable-diffusion.cpp makes them (step 5, part 3)
include/strata/image/qi21_pixels.hpp, src/image/vae/qi21_pixels.cpp: the decoded float picture to 8-bit pixels as sd.cpp 2988060's tensor_to_sd_image / preprocessing_float_to_u8 (0 at or below 0, 255 at or above 1, else (uint8)(v x 255 + 0.5) with two roundings: no fused multiply-add, contraction off for the file), planar in, interleaved out. The latent's preparation for the VAE is step 2's wan_vae_denormalize (sd.cpp's diffusion_to_vae_latents for Qwen-Image-2.1: 64 channels, x std / 1 + mean; sd.cpp unpatchifies nothing before its VAE). Nothing joined or hooked anywhere. Test-only: stage_hooks.py dumps vae_in (what sd.cpp's VAE decoder gets) and vae_out (its float picture before the 8-bit step) (+ test_stage_hooks.py); strata-vae-io-check (src/image/vae/qi21_vae_io_check_main.cpp, nvcc, links wan_vae.cu); strata-pixels-check; tools/image/gate/png_pixels.py (a PNG reader with all five row filters, for sd-cli's PNGs). GB10 (dgxspark-20261111-0610-e738), sd-cli with the stage hooks (build te5bvio), prompt 0 at 512 (seeds 42, 1234) and 1024 (seed 42): wan_vae_denormalize(latent) byte-identical to vae_in on all three; our 8-bit picture of vae_out identical to the pixels of sd-cli's own PNG on all three (4 channels; a fused-multiply-add variant gave the same bytes here). CPU test tools/test_qi21_pixels.py: 8,184 values of that picture with sd-cli's PNG bytes (tools/image/gate/data/qi21_pixels_fixture.bin, 729 within 1e-3 of a rounding boundary) and edge values from numpy float32, built -O2 and -O3 -ffp-contract=fast; p1006 p1006-20261111-0618-a6f6: 58 passed (with the other image tests). |
||
|
|
89b4d9f1fd |
image: initial noise in our own code (step 5, part 2)
include/strata/image/qi21_noise.hpp, src/image/noise/qi21_noise.cpp: the noise of a picture as stable-diffusion.cpp 2988060 makes it by default (PhiloxRNG, manual_seed(seed), one randn over the latent), from Strata's integer-only Philox generator (tools/image/sdcpp_noise/strata_noise.hpp, the same file the sd-cli patch uses; its sin table from apply.py --prepare). Test program strata-noise-check. Nothing joined or hooked. Reference: sd.cpp's x86 build. On x86 (p1006, g++ 13.3 -O3, p1006-20261111-0611-d91d), sd.cpp's own core/rng_philox.hpp and ours give byte-identical noise for seeds 42, 1234, 7 and 2026 at 65,536 and 262,144 values (the 512 and 1024 latents); their sha256 are in tools/image/gate/data/qi21_noise_sha.json for the CPU test tools/test_qi21_noise.py. Against the dumps of sd-cli on the GB10 (aarch64, dgxspark-20261111-0602-6aba) 0.65-0.78% of the values differ (435-1983 per picture, up to 1321 ulp): sd.cpp's aarch64 build does not compute its own x86 stream (box_muller's float multiply-add can fuse on aarch64, and glibc's aarch64 sin / log differ from x86's); the generator reproduces the x86 stream on every platform by design. In those dumps the first DiT input equals the noise (sigma 1). CPU test: p1006-20261111-0612-f905, 1 passed. |
||
|
|
6edd6f21af |
image: PNG writer of our own, stored deflate blocks (step 5, part 4)
include/strata/image/png_write.hpp, src/image/png/png_write.cpp: 8-bit grey / grey+alpha /
RGB / RGBA, filter 0 on every row, the pixels in deflate stored blocks (<= 65535 bytes each)
in a zlib stream with its Adler-32, chunk CRC-32s, and the "parameters" tEXt chunk right
after IHDR as stable-diffusion.cpp's stb_image_write puts it. No compression and no new
dependency; the file bytes differ from stb's (stb compresses), the decoded pixels do not.
Nothing joined or hooked anywhere.
Test program strata-png-write (src/image/png/png_write_main.cpp) and tools/test_png_write.py:
CRC-32 / Adler-32 against published check values ("123456789": cbf43926 / 091e01de; also
"Wikipedia", the empty string, the quick brown fox, split input, 1 MiB of 0xff against
Python's zlib); PNGs of six shapes (1x1, 3x2 and 300x200 RGB - several stored blocks -,
64x48 grey and RGBA, 1024x1 RGB) decoded back with Python's zlib (every chunk CRC checked)
and with Pillow to the same pixels, with the parameters text kept.
p1006 (p1006-20261111-0607-36f9): 3 passed, 6 subtests; Pillow 13.0.0.
|
||
|
|
8ee4250e5a |
image: Turbo sampler in our own code, byte-identical to stable-diffusion.cpp (step 5, part 1)
include/strata/image/qi21_sampler.hpp, src/image/sample/qi21_sampler.cpp: Turbo's fixed
schedule (the --sigmas string serve/images.py passes, parsed as sd-cli's std::stof), the
DiT timestep sigma x 1000, and one Euler step with CFG 1 for the flow model in sd.cpp
2988060's order (c_skip 1, c_out -sigma, c_in 1; den = v c_out + x c_skip;
d = (x - den) / sigma; x += d (sigma_next - sigma)), each line its own pass, contraction off
for the file. CPU, plain float, no ggml. Nothing joined or hooked anywhere.
Test program strata-sampler-check (src/image/sample/qi21_sampler_check_main.cpp): chains all
8 steps from sd.cpp's own dumps (dit_x_0, then sd.cpp's vel_k) and requires dit_x_{k+1},
dit_t_k and, after the last step, the final latent byte-identical.
GB10 aarch64 (dgxspark-20261111-0604-05ed), dumps from sd-cli with its own noise
(dgxspark-20261111-0559-e8d7): 512 and 1024 x seeds 42 and 1234 (prompt 0) and 512 prompt 5:
every step byte-identical, timesteps identical, the final latent identical; built with g++
-O2 and with -O3 -ffp-contract=fast.
CPU test tools/test_qi21_sampler.py with tools/image/gate/data/qi21_sampler_fixture.bin
(512 values per step of steps 0-6, 512 p0 seed 42): 2 passed on p1006 x86 g++ 13.3
(p1006-20261111-0605-f597).
|
||
|
|
18795cfdb3 |
image: strata-dit-step --f16-resident, a measurement switch (D4)
An opt-in flag of the test program (qi21_dit_open flag QI21_DIT_F16_RESIDENT): every 2-D DiT weight is decoded once to f16 at open and the raw blocks are freed; the GEMMs then read the f16 weights in place instead of decoding them on every call. Not a default and not a memory plan: the mode's rules (which cards, when) are D5's and wait for the cards. It tells what a card with room could gain. GB10 (dgxspark-20261111-0552-384c), Q8_0 (GGUF 7.641 GB): - velocities byte-identical to the f16-output build (512 p0, p5, 1024 p0): same f16 values, same GEMMs; - step time, median of 5 steps after the text prefix run, two rounds: 512 p0: 261.8 / 270.5 ms ( |
||
|
|
bb5f308b9b |
image: DiT kernels write the GEMM inputs as f16 directly (D4, second piece)
The kernels whose output only feeds a GEMM - LayerNorm + modulate (also the head's),
SwiGLU and both attention kernels - now store f16 instead of f32, and the GEMMs read those
rows in place (dit_gemm_x16); dit_gemm's separate f32 -> f16 conversion pass is gone from
the step. Each kernel computes in f32 as before and rounds at the store, to nearest even:
the same bits the conversion pass made (f16_from_f32; the attention's epilogue uses the
hardware pair conversion, the same bits for every finite value, because f16_from_f32's
integer code there doubled the kernel's time). dit_gemm reads an F16 weight in place
without the decode. The text-input MLP and the prelude keep the f32 path.
Gate (GB10, dgxspark-20261111-0552-384c): the velocities of the nine stage cases (512
prompts 0-7, 1024 prompt 0) are byte-identical to 1705c8b9f's.
Step time, median of 5 steps after the text prefix run, two rounds in the same job
(
|
||
|
|
1705c8b9f0 |
image: Qwen-Image-2.1 DiT step without ggml, and the strata-dit-step test program (D4, first piece)
One DiT step (latent + text condition + timestep -> velocity) in our own code, CUDA:
- src/image/dit/qi21_dit.cu, include/strata/image/qi21_dit.hpp: the weights read with
strata/artifact/gguf_reader.hpp into one device buffer as the file's bytes (q, k, v of a
block one after the other: one GEMM), 1-D norms as f32; own buffers and stream; every
multiply through dit_gemm (D1+D2); the text prefix once per condition with its K / V kept,
as the native runner does.
- src/image/dit/qi21_kernels.cu: the native runner's kernels moved out of the sd.cpp patch
(LayerNorm + modulate + gated residual, q/k RMSNorm + RoPE + f16 K/V, SwiGLU, the causal /
exact attention, the mma.sync attention for sm_80+, the gfx11 WMMA attention), plus the
steps ggml still did: timestep sinusoid, SiLU, GELU (tanh form), txt_in's RMSNorm.
The sd.cpp patch keeps its own copy for the test builds.
- src/image/dit/qi21_dit_step_main.cpp: strata-dit-step <dit.gguf> <out> <dump dirs>
[--repeat N], on the stage-hook dumps of what sd.cpp fed its DiT.
- tools/image/gate/dit_step_check.py (+ test_dit_step_check.py, CPU): the velocity against
dit_ref's f32 result, both emulations, the D1+D2 test build, stock and native.
Not used by any build or by sd-cli; sd.cpp stays the default and the fallback. HIP is
written but not compiled (no card tonight).
Measured on the GB10 (dgxspark-20261111-0538-11fc), Q8_0, velocity rel L2 to f32:
512 p0: ours 0.00055 | float32-sum emulation 0.00052 (1.061) | exact-sum 0.00046 (1.179)
| D1+D2 test build 0.00050 | stock 0.00658 | native 0.00570 | ours vs D1+D2 0.00026
512 p5: ours 0.00058 | 0.00098 (0.594) | 0.00055 (1.061) | 0.00114 | 0.00492 | 0.00612
| ours vs D1+D2 0.00107
1024 p0: ours 0.00045 | 0.00050 (0.901) | 0.00056 (0.809) | 0.00049 | 0.00535 | 0.00518
| ours vs D1+D2 0.00023
Three runs per case (the first with the text prefix pass) byte-identical.
Step time: 512 369-391 ms (first run with the prefix 588-716 ms), 1024 1316-1326 ms
(first 1524 ms). sd-cli sampling at 1024 divided by 8 steps (host side included): native
1.54 s, D1+D2 1.57 s, stock 2.45 s.
Device memory of the DiT's own buffers: 8.12 GB at 512, 8.91 GB at 1024 (weights 7.64 GB
= the GGUF's size, work 0.48 / 1.27 GB incl. the GEMM's f16 buffers).
|
||
|
|
09d67a33d4 |
image: own DiT GEMMs for the native Qwen-Image-2.1 runner (D1+D2, test builds only)
D1 and D2 together: every multiply of the native runner's DiT call on our own GEMM (src/image/dit/dit_gemm.cu: weights decoded to f16 by te_dequant, activations to f16, cuBLAS / hipBLAS GemmEx with float32 sums). Groups: blocks + img_in (D1); timestep MLP, modulation, norm_out; txt_in; the head (D2). Wired into the pinned stable-diffusion.cpp by tools/image/sdcpp_dit/apply.py (build_variant.py --dit) behind --model-args strata_dit_gemm=1. No build or product path uses it; sd.cpp stays the default and the fallback. Measured together, not D1 alone: D1 alone was 0.00331 from the f32 reference against the emulation's 0.00065 (5x); only all four groups together reach the emulation's level, because the multiplies left on ggml's MMQ (8-bit activations) then dominate. vel_0 rel L2 to f32, 512 prompts 0-3 (mean), per group switched on: none (native runner) 0.00609 | all (D1+D2) 0.00065 | D1 0.00331 | D1 + timestep/modulation/norm_out 0.00271 | D1 + txt_in 0.00342 | D1 + head 0.00200 | f16 emulation 0.00065 | stock 0.00678 Stage rule (coordinator's restated rule: mean within 1.25x the emulation, no case above 1.5x, every case closer than stock and native). Nine cases (prompts 0-7 at 512, prompt 0 at 1024), velocity rel L2 to f32: against the emulation with float32 sums (dit_ref mode f16acc32): mean ratio 1.039, largest 1.177 (512 p6); against the emulation with exact sums (mode f16op): mean ratio 1.116, 512 p5 at 2.078. Every case 0.00048-0.00114 from f32; stock 0.0049-0.0090, native 0.0052-0.0083. The comparison was changed to the float32-sum emulation after the measurement (coordinator, 11-11): on prompt 5 the exact-sum emulation moves from 0.00055 to 0.00086 when started from inputs that differ by 3e-6; a per-block trace found no step that differs from the emulation's arithmetic (block 20 replayed from our input agrees to 0.0002). Both modes stay in dit_ref.py; tools/image/gate/dit_acc32_cases.py reproduces the table. Gate (a): with the argument off, 16 pictures (prompts 0-7, seeds 42 and 1234, 1024) byte-identical to the build before D1: 16 of 16 (dgxspark-20261111-0513-8147). Pictures, 16 against stock sd.cpp, PSNR mean / min, SSIM mean / min (GB10): sd.cpp cuBLAS-forced 33.35 / 23.06 dB, 0.979 / 0.937 sd.cpp native runner 34.32 / 21.32 dB, 0.982 / 0.923 ours (D1+D2) 34.45 / 23.74 dB, 0.982 / 0.948 ours vs native 35.90 / 20.71 dB, 0.982 / 0.912 Sampling median at 1024: stock 19.57 s, native 12.32 s, ours 12.54 s. Also: te_type_supported / te_row_bytes moved into te_dequant.cu (needed without the host decoder); run_set.py --model-arg; test-only trace hooks in apply.py (STRATA_DIT_TRACE_DIR / STRATA_DIT_TRACE_BLOCK, read after a backend sync, change no value); dit_replay.py / dit_replay2.py (the prompt-5 trace tools). Tests: tools/test_sdcpp_dit.py, tools/image/gate/test_dit_ref.py (modes). |
||
|
|
9b242bb5b4 |
Image generation, DiT: Qwen-Image-2.1's token positions and RoPE table in our own code, byte-identical to stable-diffusion.cpp's (not used by any build yet)
include/strata/image/qi21_rope.hpp, src/image/dit/qi21_rope.cpp: QwenImage21Layout::build's positions (text (p, p, p), image (L, h - (H - H/2), w - (W - W/2))) and Rope::embed_nd's table (axes 16 / 56 / 56, theta 10000, 64 x [cos, -sin, sin, cos] a token), written as sd.cpp writes them, float operation by float operation, with the C library's cosf / sinf / powf. Test program strata-dit-rope. Gate (GB10, against the tables sd.cpp's stock and native runners built, stage hook pe_*_0): 14 of 14 byte-identical - 512x512 with four prompts (25-32 text tokens), 1024x1024, 1536x1024, a 1,025-token prompt at 1024, both runners. Test: tools/test_dit_rope.py compiles the table code with the system C++ compiler and checks the sha256 of 7 of those tables (tools/image/gate/data/qi21_rope_sha.json, recorded from sd.cpp on aarch64 glibc); passed on the GB10 and on p1004 (x86 glibc). Another C library (MSVC, Apple) may differ in the last bit of some entries; not checked. |
||
|
|
666bef70a8 |
Image generation, text encoder: our own Qwen2 tokenizer, prompt-weight parser and template, ids identical to stable-diffusion.cpp's (not used by any build yet)
include/strata/image/qwen2_tok.hpp, src/image/te/qwen2_tok.cpp build the token ids of Qwen-Image-2.1's text encoder
the way sd.cpp 2988060 does, with no regex library and no sd.cpp:
- sd-cli's <lora:NAME:WEIGHT> removal (its --lora-model-dir defaults to "."), parse_prompt_attention as its code runs
(only "\(" loses its backslash, "\]" stays), the system / user / assistant template, each piece encoded alone;
- the 31 special literals with sd.cpp's ids (151643 + index; at 5 of those ids the GGUF lists [PAD151669] ..
[PAD151673], sd.cpp names them <|boi_token|> .. <|tms_token|>; we follow sd.cpp);
- the Qwen2 pre-tokenizer regex as a scanner; \p{L}, \p{N}, \s and the contraction case folds (s also matches U+017F)
are Oniguruma's own, dumped from sd.cpp's build over every code point (tools/image/gate/te_tok_probe.cpp ->
te_tok_tables.py -> src/image/te/qwen2_tok_unicode.inc);
- byte-level BPE with the GGUF's merges (equal to sd.cpp's compiled-in 151,387, checked); invalid UTF-8 refused as
sd.cpp refuses it.
No engine tokenizer to reuse: the engine takes ids from the Python server (tools/strata_tokenizer.py, qwen35 rule).
Gate: 408 prompts (tools/image/gate/te_tok_cases.py: the 8 gate prompts, the 1,025- and 4,002-token prompts, every
special literal and the 5 GGUF pad literals, 19 prompt-weight cases, 22 unicode cases (CJK, kana, hangul, emoji with
joiners / flags / skin tones, combining marks, right-to-left, other digits and spaces, case-fold traps), empty and
whitespace-only prompts, long words, 5 invalid UTF-8, 300 random prompts from a fixed seed); sd.cpp's ids, weights and
system-token count recorded through the stage hook (stage_hooks.py: tokens.weights and OWN5_EXIT_AFTER_TOKENS, which
exits before any model loads; te_tok_collect.py). GB10 with the full merges: 408 of 408 identical (sd.cpp refuses the
5 invalid-UTF-8 prompts, so do we).
Test: tools/test_te_tokenizer.py compiles the tokenizer with the system C++ compiler and checks all 408 cases from
tools/image/gate/data/te_tok_expected.json with the 2,557 merges they use (te_tok_merges.txt, ranks kept): no GPU, no
sd.cpp, no model file. Passed on the GB10 (aarch64) and p1004 (x86).
|
||
|
|
44c4224d21 |
Image generation, text encoder: weights uploaded through pinned chunks, and a streamed mode for cards under 14 GiB (test program only)
The weights now travel from the mapped file through two 32 MB pinned chunks (filled by up to 8 threads) with async copies: open on the GB10 0.7 s instead of 12.0 s (sd.cpp's text-encoder load: 0.28 s). Streamed mode keeps two layers on the device and uploads layer i + 2 while layer i runs. qwen3vl_te_open mode 0 picks it from the card's TOTAL memory (under 14 GiB: streamed; 16 GB cards and up keep the weights resident), never from free memory; 1 / 2 force resident / streamed for tests. The arithmetic is the same: both modes give the same bytes. GB10 (strata-te-encode --mode): - gate prompts: resident and streamed byte-identical to the previous commit's conditions, 8 of 8, repeats identical - 1,025 and 4,002 tokens: resident == streamed, repeats identical - encode / peak device memory, resident vs streamed: gate prompts 261 ms / 4284 MiB vs 378-389 ms / 464 MiB; 1,025 tokens 472 ms / 4484 MiB vs 583 ms / 665 MiB; 4,002 tokens 1.57 s / 5091 MiB vs 1.72 s / 1271 MiB (unified memory: the streamed upload over PCIe on a discrete card is not measured yet) - sd.cpp on the same long prompts: 1.20 s / 5.79 s; its condition is 0.174 / 0.190 relative L2 from the numpy f32 reference (per-token cosine down to 0.50 / 0.31), ours 0.0034 / 0.0073 (the f16 emulation of our arithmetic: 0.0041 / 0.0094); token ids identical to sd.cpp's for both. |
||
|
|
f683674465 |
Image generation, text encoder: Strata's own Qwen3-VL text encoder on CUDA / HIP, test program only (no build or product path uses it)
include/strata/image/qwen3vl_te.hpp and src/image/te/qwen3vl_te.cu compute what stable-diffusion.cpp 2988060's
LLMRunner (QWEN3_VL, text only, out_layers {36}) returns for a prompt's token ids: 36 layers of RMSNorm, q/k/v,
per-head q/k norms, NEOX rope (angles in double on the device), causal attention over fixed 256-query chunks, SwiGLU,
the residual stream after the last layer without the final norm. Weights stay quantized on the device and are decoded
one group at a time into an f16 buffer (te_dequant); GEMMs are cuBLAS / hipBLAS GemmEx, f16 inputs, f32 accumulation;
the residual stream is f32. The token embedding rows are decoded on the host (f32, as ggml_get_rows).
Test program strata-te-encode (src/image/te/qwen3vl_te_encode_main.cpp) encodes sd.cpp's own token ids (stage hook
dumps) and writes the condition as sd.cpp's cond.bin.
GB10, the 8 gate prompts, sd.cpp's token ids:
- run to run: byte-identical 8 of 8 (two encodes each)
- against the numpy f32 reference: relative L2 0.00118 mean / 0.00150 max, per-token cosine >= 0.999994
- against sd.cpp's CUDA condition: relative L2 0.0548 mean / 0.0603 max, whole cosine >= 0.99818, per-token >= 0.98999
(sd.cpp's own distance from the f32 reference is 0.0546)
- pictures with our condition through stock sd.cpp (16, seeds 42 and 1234) against stock: PSNR 29.82 / 14.55 dB
mean / min, SSIM 0.954 / 0.789; sd.cpp's own encoders against stock: cuBLAS 30.02 / 16.71 dB, 0.965 / 0.860;
CPU (12) 29.00 / 14.23 dB, 0.948 / 0.763
- encode 259-264 ms per prompt (sd.cpp's get_learned_condition: 0.63 s); peak device memory 4284 MiB (sd.cpp's text
encoder weights alone: 4418 MiB)
- open: 12.0 s to copy the 4.28 GB of weights from the mapped file (pageable copies; sd.cpp loads in 0.28 s) - to be
made faster before the encoder goes anywhere near sd-cli.
|
||
|
|
1cb8b6a0da |
Image generation, text encoder: GGUF weight decoders to f16 rows on CUDA / HIP (not used by any build yet)
include/strata/image/te_dequant.hpp, src/image/te/te_dequant.cu and te_dequant_host.cpp decode Q4_K, Q5_K, Q6_K, IQ4_XS, Q8_0, F32, F16 and BF16 rows into f16 for the GEMMs of Strata's own text encoder. The values are ggml's f32 dequantization (dequant.hpp's order of operations, every product and difference rounded on its own: __fmul_rn / __fsub_rn on the device, contraction off on the host) rounded to nearest even with f16_bits.hpp. Kept apart from the engine's dequant_bf16.cu; a shared header is a later step under the engine identity gate. Test program strata-te-dequant-check (src/image/te/te_dequant_check_main.cpp): device against host, bit for bit. GB10: synthetic blocks of all 8 types and every tensor of Qwen3-VL-8B-Instruct-UD-Q4_K_XL.gguf (399 tensors, 8.19 G values) with 0 mismatches. |
||
|
|
97b14b6b06 |
Image generation, VAE decoder: faster open - the file read in parallel parts, every weight converted straight into one staging buffer over the image program's threads, one device allocation and one copy
The conversions are the per-value ones of src/image/vae/convert.hpp (bf16 -> f32 exact, f32 -> f16 round to nearest
even): the same bytes for any thread count. sd-cli passes its own thread setting (n_threads), not all cores. No
cache file, no changed rounding. wan_vae_open_report says where the open time went; strata-vae-decode --threads N.
test_vae_convert.py: every one of the 65536 bf16 bit patterns (zeros, subnormals, infinities, NaN payloads, values
that round up into the next exponent) gives the same bytes with 1, 2, 7 and 16 threads, agrees with numpy's float16
on every non-NaN pattern and keeps NaN a NaN; the conv layout against numpy. test_safetensors_lite.py: the parallel
read gives the same bytes as the per-tensor reads (1, 3, 16 parts). 45 passed on boston-20261110-1922-1874.
Pictures of the 16 gate latents byte-identical to cab47f3d2's on both vendors (Spark dgxspark-20261110-1920-2e41,
p620 p620-20261110-1921-b026). Open, standalone (runtime start-up included):
Spark 20 cores: 1 thread 1.11-1.22 s (read 253-262, convert 388-393, upload 27-29 ms); 20 threads 0.55-0.56 s
(read 38-40, convert 37-38, upload 28-29 ms); before (
|
||
|
|
cab47f3d2c |
Image generation, VAE decoder: f16 headroom for the block-4 shortcut (fixed shift 11), GEMM blocks on the picture's pixel grid (row bands byte-identical on HIP too), and no broken picture on a non-finite value
Operand range (strata-vae-decode --stats over the 16 gate latents, merged per convolution): the only layer within 16x of the f16 maximum under stable-diffusion.cpp's 2^-7 is up_blocks.4.resnets.0.conv_shortcut (largest input 3.48e6, 2.4x headroom); it gets the fixed shift 11 (38.5x). The shift is a constant per layer (conv_shift()), never from the picture's data; vae_ref.py carries the same table and a test checks they agree. Next closest layers: 62.8x and 113x, kept at 7. The row bands were not byte-identical on HIP (R9700: 8 of 16 differed; hipBLAS gives a row another reduction order at another row position of the call). Every convolution now runs its GEMM blocks on the picture's pixel grid, also in a row window (rows outside the window are zero and dropped), so a pixel sits in the same row of a same-shape call in both paths. wan_vae_set_band_rows / --band-rows: vae_identity.py also checks band heights 48 and 100. A picture with a non-finite value is an error (the sd-cli hook then logs "...; using stable-diffusion.cpp's decoder, which may fail the same way", the approved line). Test-only: wan_vae_set_range_stats / wan_vae_range_report. Gates: identity (bands of 128, 48 and 100 rows against one pass, bands run to run) PASS 16 of 16 on CUDA (dgxspark-20261110-1832-ea13) and on HIP (p620-20261110-1832-6e66). Against sd.cpp's CUDA pictures, PSNR worst / mean: CUDA 56.80 / 57.72, 56.20 / 57.50, 57.02 / 57.37 dB at 512, 1024, 1536x1024 (vae_same_tiling pass); HIP 56.81 / 57.71, 56.21 / 57.50, 57.02 / 57.37 dB. Against the previous commit's pictures 79.4-81.2 dB (max 1). Stress, 1024 p4's latent x2 / x4: ours finite, 65.36 / 63.99 dB from the numpy f32 reference (sd.cpp's decoder 53.91 / 49.59 dB); the shortcut's headroom 113x / 133x. Decode (bands) CUDA 0.46-0.48 / 1.03-1.08 / 1.46-1.50 s, HIP 0.82-0.84 / 1.19-1.23 / 1.49-1.50 s. CPU tests 98 passed with the other image tests (boston-20261110-1837-287a). |
||
|
|
e09b23383e |
Image generation: the VAE decoder always takes the row-band path (coordinator 11-10: one path for small and big cards); the one-pass decode stays as the reference the byte-identity gate compares against
wan_vae_set_streaming defaults to on; strata-vae-decode --stream off and vae_decode_set.py --stream off give the one-pass reference. tools/image/gate/vae_identity.py is the gate: for every fixed latent of the sets named, the row-band decode against the one-pass decode byte for byte, and the row-band decode run to run. Spark (GB10, CUDA 13): VAE-IDENTITY PASS 16 of 16 (4 x 512, 8 x 1024, 4 x 1536x1024), bands run to run identical 16 of 16; the default-path pictures byte-identical to f7d8aa28e's one-pass pictures 16 of 16. Peak device memory of the decoder 1388 / 2565 / 3411 MiB (one pass 1626 / 4293 / 6003 MiB); decode 450-470 / 1034-1063 / 1438-1474 ms. |
||
|
|
bbf2a5476c |
Image generation: the VAE decoder's small-card path, the same bytes as the one-pass decode in less memory (owner decision 11-10, option A); off unless asked for
wan_vae_set_streaming(on): block 3's upsample, block 4 and the head run in bands of 128 picture rows, each computed with 7 rows more above and below (block 4's six 3x3 convolutions and conv_out need one each) from the complete block-3 tensors. Every kept pixel goes through the same operations on the same operands, GEMM bands included, so the picture is the one-pass picture byte for byte. The kernels take row windows (zero padding only at the picture's own edges). Blocks 2 and 3 keep their input for the DupUp shortcut without a copy (their first resnet writes a new tensor anyway); this does not change any value. The rule that turns the path on is not in this commit. strata-vae-decode --stream on, vae_decode_set.py --stream on; diff_where.py says where two picture sets differ (largest difference with its pixel and channel, share of pixels above 8/255, PSNR of the pictures as the server sends them, flattened on white by serve/images.py flatten_png). Spark (GB10), the 16 fixed latents: row bands against one pass, the float32 outputs byte-identical 16 of 16 (4 x 512, 8 x 1024, 4 x 1536x1024); one pass with these sources against the previous commit's pictures byte-identical 16 of 16. Decoder peak device memory one pass / row bands: 1626 / 1388 MiB at 512, 4293 / 2565 MiB at 1024, 6003 / 3411 MiB at 1536x1024; decode time 455-457 / 457-466 ms, 1015-1039 / 1036-1068 ms, 1404-1444 / 1460-1466 ms. |
||
|
|
f7d8aa28ed |
Image generation: Strata's own VAE decoder for Qwen-Image-2.1 (src/image/vae, CUDA; HIP from the same source through hip_compat), not wired into anything yet
include/strata/image/wan_vae.hpp: open / decode / close, plus the latent denormalization. Pixel-major float32 activations; every convolution is a gather of f16 operand rows (RMS norm, SiLU or the nearest-2x upsample fused in, x 2^-7 as stable-diffusion.cpp does) for fixed bands of 8192 pixels, cuBLAS GemmEx f16 x f16 with f32 accumulation, and an epilogue (x 2^7, bias, residual, the DupUp shortcut). The mid-block attention is f32 SGEMM / softmax / SGEMM. sd.cpp accumulates its convolutions in f16; we deliberately do not. The band size never depends on the picture size or the card's memory, so the picture is the one-pass result everywhere. safetensors_lite.hpp reads the VAE file (no third-party JSON code); strata-vae-decode (wan_vae_decode_main.cpp) decodes a dumped latent for the gate. Gate on the Spark (GB10, CUDA 13), ours against sd.cpp's decode of the same fixed latents, PSNR worst / mean, SSIM worst: 512 x4 56.80 / 57.71 dB, 0.99890; 1024 x8 56.20 / 57.50 dB, 0.99885; 1536x1024 x4 57.02 / 57.37 dB, 0.99865 (limit 45 dB / 0.998: pass). Run to run byte-identical 16 of 16. Decode, first run in a process: 0.44-0.46 / 1.02-1.05 / 1.41-1.44 s against sd.cpp's 1.03-1.06 / 3.34-4.36 / 4.89-4.95 s; opening the VAE file 1.03-1.10 s. The numpy f32 reference (vae_ref.py) is 56.77-58.34 dB from sd.cpp's pictures at 512. tools/image/gate/vae_decode_set.py runs the decoder over a stage set for compare.py / check_limits.py; test_safetensors_lite.py tests the reader (11 passed with test_vae_ref.py on p1004). |