Skip to content

Port ExLlamaV3 native half-bit EXL3 (2.5/3.5, etc) - #5619

Merged
Qubitium merged 5 commits into
mainfrom
perf/exl3-upstream-1.6.7
Nov 20, 2026
Merged

Qubitium merged 5 commits into
mainfrom
perf/exl3-upstream-1.6.7

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Port the ExLlamaV3 1.6.7 CUDA kernel and packed-format updates from upstream 8c593e4.

What Changed

  • Add configuration-selected FP16 GEMV, fused GEMM, and plain or error-feedback INT8 GEMV through the existing Torch operator extension. Use call-private CUDA scratch for graph replay.
  • Add native mul1 1.5, 2.5, and 3.5 bpw tiles through quantization, checkpoint save/reload, CUDA inference, and the portable Torch decoder. Integer rates support 3inst, mcg, and mul1.
  • Expose an explicit routed EXL3 decode operator for aligned NVIDIA shapes with caller-owned scratch.
  • Preserve the original integer arithmetic by default and expose the fast modes through EXL3CUDAConfig. Half-bit checkpoints use the native fused path.

Tests

  • New targeted configuration, packed-layout, CUDA replay, and model round-trip tests.
  • Independent Torch oracle checks and real A100 runs.
  • Full format gate and git diff --check.
PYTHON_GIL=0 python -m pytest -q tests/kernels/test_exllamav3_kernel.py tests/kernels/test_exllamav3_kernel_map_packed.py tests/kernels/test_exllamav3_native_decode.py tests/kernels/test_exllamav3_quantize_tiles.py tests/test_backend_config.py tests/test_exl3_dispatch_concurrency.py tests/test_exl3_routed_cuda.py tests/test_exl3_wide_input.py tests/test_exllamav3_jit.py tests/test_kernel_config.py
PYTHON_GIL=0 CUDA_VISIBLE_DEVICES='' python -m pytest -q tests/qcfg/test_config_serialization.py tests/test_backend_config.py tests/test_config_unapplied_options_5583.py tests/test_dynamic_config_invalidation_4475.py tests/test_exl3_fractional_bits.py tests/test_exllamav3_jit.py tests/test_exllamav3_torch_padding.py tests/test_kernel_config.py
PYTHON_GIL=0 CUDA_VISIBLE_DEVICES='' python -m pytest -q tests/qcfg/test_config_validation_4668.py tests/test_smooth_mse_endpoint_baseline.py
bash format/check.sh
git diff --check origin/main..HEAD

The integrated A100 suite passed 148 tests. After the config-base rebase, 15 focused native tests passed and the CPU suite passed 243 with 52 hardware or optional skips. The final base update changed two smoother test files. Their targeted run passed all 63 tests on the pushed head. The integer default matched all 20 logits tensors on a real W3 mcg Llama 3.2 1B checkpoint. The W2.5 model passed quantization, safetensors save, and native reload. The routed port matched upstream bit-for-bit at W2.5, W3, and W4 for 1, 6, 12, and 24 rows.

Model Support and Logic Flow

The real-model checks use the existing Llama 3.2 definition. Dispatch and scratch ownership are illustrated in native decode and routed decode. Packed weight lifecycle and compatibility

Kernel Accuracy and Performance

On an A100, W3 gate+up at one row went from 73.67 µs to 31.35 µs with FP16 GEMV, 28.50 µs with residual INT8, and 26.40 µs with plain INT8. The fast modes are explicit because QTIP's short FP16 accumulations overflowed on deliberately extreme activations. Both GEMM paths stayed finite in that fixture. Measured limits and dispatch policy

Carry exact per-projection rates through configuration, Viterbi encoding, packed checkpoint metadata, and native and Torch inference. Snapshot the caller kernel policy in EXL3 modules.
@Qubitium
Qubitium marked this pull request as ready for review November 20, 2026 03:11
@Qubitium Qubitium changed the title Port ExLlamaV3 1.6.7 CUDA kernels and native half-bit EXL3 Port ExLlamaV3 native half-bit EXL3 (2.5/3.5, etc) Nov 20, 2026

Qubitium commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

Llama 3.2 1B Instruct W3.5 end-to-end results

I quantized the full model on an A100 at 59f4cd5e with native EXL3 mul1, saved the safetensors, and reloaded through the native CUDA backend. All 112 transformer projections used 3.5 bpw with 56 int16 words per 16×16 tile. The tied embedding and output head used BF16. Calibration used 256 C4 training windows of 512 tokens each.

Held-out metric BF16 EXL3 W3.5 Change
WikiText-2 test perplexity, 289,075 scored tokens 11.6343 12.2846 +5.59%
GSM8K exact match, 256 paired questions 125/256 (48.8%) 116/256 (45.3%) −3.52 points
Safetensors size 2.472 GB 0.953 GB −61.46%

Both arms received identical tokenized inputs. WikiText used 2,048-token contexts and a 1,024-token stride. GSM8K used seed 1618, greedy generation, and a 256-token cap. The paired 95% interval for the GSM8K change was −9.38 to +2.34 points.

On the same saved W3.5 checkpoint, native CUDA and the portable Torch reference differed by 0.071% in perplexity on a 2,048-token probe. All eight checked single-token decode choices agreed.

WikiText-2 · GSM8K test split

Regression coverage

The full pytest integration passed on one A100 in 10m 31s. It reproduced both quality scores in the table, verified all 112 packed projections after reload, and passed the same-weight Torch comparison for prefill loss and cached decode logits.

All 43 focused tests passed in the regular run. The W3.5 tiny Llama round-trip also failed on current main at the expected integer-only bitrate check.

Select the full test with -m exl3_cuda_e2e. It uses a local BF16 checkpoint and pinned evaluation assets. Reproduction instructions

Comment thread tests/models/test_llama3_2_exl3_cuda.py Dismissed
@Qubitium
Qubitium merged commit aef9788 into main Nov 20, 2026
6 checks passed
@Qubitium
Qubitium deleted the perf/exl3-upstream-1.6.7 branch November 20, 2026 03:57
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