Skip to content

Default to measured improvements over the paper; fused pre-rotation; Lloyd-Max v3; Vulkan W4A8 - #25

Merged
iamwavecut merged 2 commits into
mainfrom
dev/beneficial-defaults
Oct 30, 2026
Merged

iamwavecut merged 2 commits into
mainfrom
dev/beneficial-defaults

Conversation

@iamwavecut

@iamwavecut iamwavecut commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #22. An option becomes the default when it beats the paper recipe on quality, efficiency or speed without losing on the others. The paper method stays available as the baseline: recipe(name, paper=True) / PAPER_FIELDS.

Default changes

Field Old default (paper) New default Evidence
rotation_rounds 1 "auto": adds an independent RPBH round where the block h < 512 Z-Image-Turbo W4A4, LPIPS against BF16: 0.438 → 0.348 (−0.090, 95% paired interval −0.124 to −0.060), better on 27 of 30 pairs
activation_quantizer "lloyd_max" "auto": absmax INT8 at A8, Lloyd-Max below Z-Image W4A8: absmax 0.331 against 8-bit Lloyd-Max 0.330 (paired −0.007 to +0.007); 3.4–6.6× less GEMM time on an RTX 4090 at 4096 tokens
codebook_version 2 3 (Newton solver) 8-bit tables take about 0.1 s per width up to d = 30720; v2 failed to converge for d ≥ 7680

Artifacts without the new fields still load as one round with Lloyd-Max codes (from_dict setdefault).

Unchanged on purpose:

Runtime work

  • Pre-rotation runs as one Triton kernel on CUDA: +40–50 µs per call at 256 tokens, +70–75 µs at 4096 (the PyTorch path cost 0.5 ms and 3.4 ms). On MPS it is one Metal kernel. It also works on the fused block runtime and on Krea 2.
  • ExecuTorch Vulkan W4A8 absmax path:
    • shaders rpbh_a8, absmax_a8, w4a8;
    • ExecuTorchVulkanW4A8Linear and register_executorch_vulkan_w4a8();
    • the pre-rotation is exported as a dense block-Hadamard matmul (blocks ≤ 1024).
    • Verified only on Mesa lavapipe: 12/12 cases pass, and the Python export matches within 1e-5. No RADV or .pte run yet.

Benchmark subsets (2026-10-29)

These are not full-benchmark reproductions.

  • FLUX.1-dev, GenEval: 96 prompts × 2 seeds, official evaluator. Default W4A4 equals paper W4A4 here, because every block is ≥ 1024.

    Variant GenEval s/image Peak memory
    BF16 0.615 21.5 25.1 GiB
    W4A4 0.641 (+0.026, −0.020 to +0.074) 14.1 8.7 GiB
  • CogVideoX-2B, VBench W4A6: 12 prompts, 8 custom-input dimensions. Default (2 rounds at d = 1920) and paper settings differ by less than the pair spread on every dimension and on frame LPIPS. The default took 7% longer. The README now advises rotation_rounds=1 for such models when speed matters.

Checks

  • ruff
  • pytest (local)
  • scripts/run_paper_methodology_checks.sh rc=0
  • HF compat rc=0
  • MPS gate
  • CUDA tests on an RTX 4090: 77/77
  • Vulkan W4A8 on lavapipe: 12/12

Version stays 0.16.0, which is not released yet. Not published to PyPI.

…Lloyd-Max v3; Vulkan W4A8 (0.17.0)

- Defaults: rotation_rounds="auto" (an independent RPBH round in front of the paper round
  where the block h < 512) and activation_quantizer="auto" (absmax INT8 at 8 activation bits,
  Lloyd-Max below). recipe(name, paper=True) and PAPER_FIELDS pin the paper method as the
  baseline. Artifacts without these fields load as one round and Lloyd-Max codes.
- Z-Image-Turbo, 10 prompts x 3 seeds, LPIPS against BF16: W4A4 0.348 with the defaults
  against 0.438 with the paper fields (better on 27 of 30 pairs); W4A8 absmax 0.331, equal to
  8-bit Lloyd-Max (0.330) at 3.4-6.6x less GEMM time on an RTX 4090.
- output_gain_correction stays off: it raised LPIPS at W2A4 (+0.016, 95% interval +0.004 to
  +0.029) and lowered it at no tested width, although it lowers layer output error.
- Pre-rotation for rotation_rounds 2/"auto" runs as one Triton kernel on CUDA and one Metal
  kernel on MPS (was PyTorch), and on the fused block runtime and Krea 2.
- Lloyd-Max codebook generator v3 (Newton solver, codebook_version 3): 8-bit tables in about
  0.1 s per width up to d = 30720; v2 did not converge for d >= 7680.
- ExecuTorch Vulkan W4A8 absmax path: rpbh_a8, absmax_a8 and w4a8 shaders,
  ExecuTorchVulkanW4A8Linear, register_executorch_vulkan_w4a8(); the pre-rotation is exported
  as a dense block-Hadamard matmul. Verified on Mesa lavapipe only.
- README and audits: FLUX.1-dev GenEval subset (W4A4 0.641, BF16 0.615) and CogVideoX-2B
  VBench subset (the extra round gives no measurable gain at W4A6 and costs 7% time).
  Version 0.17.0.
0.16.0 was never tagged or published (the latest release is 0.15.0), so this work ships under the same version.
@iamwavecut iamwavecut changed the title Default to measured improvements over the paper; fused pre-rotation; Lloyd-Max v3; Vulkan W4A8 (0.17.0) Default to measured improvements over the paper; fused pre-rotation; Lloyd-Max v3; Vulkan W4A8 Oct 29, 2026
@iamwavecut
iamwavecut merged commit 993a0a8 into main Oct 30, 2026
4 checks passed
@iamwavecut
iamwavecut deleted the dev/beneficial-defaults branch October 30, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant