Repository navigation
vulkan: make mul_mm ALIGNED a spec constant - #24689
Merged
Merged
Conversation
This trims down some of the shader variant explosion and reduces binary size.
0cc4m
approved these changes
Jun 23, 2026
Contributor
|
LGTM @ggml-org/maintainers Another approval needed. |
CISC
approved these changes
Jun 23, 2026
Geminihaha
pushed a commit
to Geminihaha/llama.cpp
that referenced
this pull request
Jun 25, 2026
This trims down some of the shader variant explosion and reduces binary size.
adrianhoehne
pushed a commit
to adrianhoehne/llama.cpp
that referenced
this pull request
Jul 5, 2026
This trims down some of the shader variant explosion and reduces binary size.
gianni-cor
pushed a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Jul 17, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block.
gianni-cor
pushed a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Jul 17, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block.
gianni-cor
added a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 6, 2026
* Remove unused variable 'tensor_name'. Signed-off-by: Marcus Edel <[email protected]> * training: fix LLAMA_LORA_TARGET_ALL for ISO C compliance Signed-off-by: makaveli10 <[email protected]> * ci: disable native CPU optimizations for x64-cpu-low-perf builds Co-authored-by: Lubosz Sarnecki <[email protected]> Signed-off-by: makaveli10 <[email protected]> * Add resume-from-checkpoint support to Metal LoRA fine-tuning Signed-off-by: makaveli10 <[email protected]> * Fix missing parameters for llama_swift_finetune_options Signed-off-by: Italo Nicola <[email protected]> * tests: disable TQ2_0 tests in test-backend-ops due to llvmpipe bug Temporarily disable TQ2_0 quantization tests to work around a bug in llvmpipe. Tests pass successfully on all real Vulkan hardware (Nvidia, ARM GPUs) but fail on llvmpipe with high error values. Co-authored-by: Marcus Edel <[email protected]> Signed-off-by: makaveli10 <[email protected]> Signed-off-by: Marcus Edel <[email protected]> * resume patch removed (#103) * Update Readme (#104) * Check individual leafs to fix parallel GPU fine-tuning crash. Signed-off-by: Marcus Edel <[email protected]> * Fix type mismatch errors in Metal backend. Signed-off-by: Marcus Edel <[email protected]> * Fix Metal shader runtime errors by removing superseded individual unary kernels. Signed-off-by: Marcus Edel <[email protected]> * Use CMAKE_CURRENT_SOURCE_DIR to fix include/ resolution when built as an Android subdirectory. Signed-off-by: Marcus Edel <[email protected]> * Fix duplicate symbol link error on RISC-V by removing tq1_0/tq2_0. Co-authored-by: Lubosz Sarnecki <[email protected]> Signed-off-by: Marcus Edel <[email protected]> * Fix common include paths to use CMAKE_CURRENT_SOURCE_DIR so common/ and vendor/ resolve correctly. Signed-off-by: Marcus Edel <[email protected]> * Add OUT_PROD support to CPU repack backend and fix LoRA buffer allocation to use plain CPU buffers for F32/F16 training tensors. Signed-off-by: Marcus Edel <[email protected]> * Added a build option that will only build and install the dependency ggml. Co-authored-by: Lubosz Sarnecki <[email protected]> * Reduce VMA block size on integrated GPUs and release empty memory blocks on cleanup to prevent OOM. Signed-off-by: Marcus Edel <[email protected]> * ggml-opencl: Add on-disk kernel binary cache for faster startup. Cache compiled OpenCL programs to disk using clCreateProgramWithBinary on subsequent runs, keyed by SHA-256 of source + device + driver + compile opts + GGML version/commit. Cache is automatically invalidated when the library version changes (GGML_OPENCL_CACHE_VERSION is set from GGML_VERSION + GGML_BUILD_COMMIT at compile time). Env controls: GGML_OPENCL_KERNEL_CACHE=0 disable cache at runtime GGML_OPENCL_CACHE_DIR set cache directory (no default; caller must set explicitly via env) Also clarifies the clGetPlatformIDs error message. Retrieves device name and driver name from OpenCL in favor of changing the build_program_from_source function signature. Allows keeping upstream build_program_from_source and makes patch more portable. Co-authored-by: Lubosz Sarnecki <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Assisted-by: OpenAI Codex --- b10069 rebase: - This cycle's audit exercised the OpenCL build with GGML_OPENCL_KERNEL_CACHE at its default ON and it does not compile: the save-binary block sat in build_program_from_binary, which never declared the cache_dir/cache_path locals it reads (they belong to build_program_from_source_ex). Latent since at least the b9952 stack -- no OpenCL-capable environment had built the cache path since. - Move the save into build_program_from_source_ex, right after a successful source compilation: the only scope where the cache path exists, and the only point where a freshly compiled binary is available to persist. Build verified with the cache at its default ON (libggml-opencl.a compiles and links into a running consumer). * lora: Fix SFT loss mask to exclude role tokens from supervised sequence Signed-off-by: makaveli10 <[email protected]> Drop dead code in common_opt_sft_dataset_init(): - The `if (hi <= lo)` branch was unreachable. `hi` is `close + END_TAG.size()` and `lo <= close`, so `hi > lo` always holds; its body also merely recomputed `hi` to the value it already had. - Inline the `next_from` temporary into `from = hi;` — it was assigned and immediately read exactly once. Pure cleanup; no behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01VutzKrn3Ri7N5G9oQfNkrU * Use tiled OUT_PROD shaders on AMD RADV embedded GPUs. This makes the shader be more efficient and perform less work per GPU thread, preventing the AMD RADV driver on many embedded GPUs from considering such threads as hung and thus avoiding VK_ERROR_DEVICE_LOST. Co-authored-by: Lubosz Sarnecki <[email protected]> * ggml-vulkan: Fix NaN outputs on Mali Addresses NaN loss during lora finetuning on Mali. - Fixes Q8: Forces both inputs to dequantize to F16 before using cooperative matrices, bypassing driver bugs. - Fixes TQ1/TQ2: Bypasses the F16 cooperative matrix paths to enforce safe F32 accumulations for these formats. Signed-off-by: makaveli10 <[email protected]> * ggml-vulkan: apply F16 coopmat workaround to Qualcomm Adreno GPUs Signed-off-by: makaveli10 <[email protected]> * Remove broken VMA defragmentation from ggml_vk_cleanup. Signed-off-by: Marcus Edel <[email protected]> * Add load/unload test case. Signed-off-by: Marcus Edel <[email protected]> * log: add opencl memory debug messages Co-authored-by: Guilherme Gallo <[email protected]> --- b9692 rebase: - Demote the buffer FREE/ALLOC message from LOG_INFO to LOG_DEBUG so it no longer spams normal-verbosity output. remove leftover [DEBUG] instrumentation that logged VmRSS/VmSwap from /proc/self/status at INFO on every model teardown (non-portable, log spam) * ggml-opencl: remove Q4_K and Q4_1 from GPU supports_op Rebase on b8828: Conflicts due to upstream introducing GGML_TYPE_Q5_K. Co-authored-by: Lubosz Sarnecki <[email protected]> * ggml-opencl: remove Q4_0, Q4_1, Q6_K from L4_LM dispatch Rebase on b8828: Conflicts due to upstream introducing GGML_TYPE_Q5_K. Co-authored-by: Lubosz Sarnecki <[email protected]> * Convert bf16 projector weights to f16 on load when the GPU backend lacks bfloat support. Co-authored-by: Lubosz Sarnecki <[email protected]> Signed-off-by: Marcus Edel <[email protected]> * Probe simdgroup intrinsic support at init and skip Metal devices that lack it. Signed-off-by: Marcus Edel <[email protected]> * metal: Fall back to a temporary shared buffer. When newBufferWithBytesNoCopy returns nil in get_tensor_async, so unaligned host destinations and paravirtualized devices no longer trip. Signed-off-by: Marcus Edel <[email protected]> * vulkan: fix F16 coopmat1 corruption on ARM Mali/Adreno by using non-coopmat fp32 shaders Signed-off-by: makaveli10 <[email protected]> * Mark read_alignment/has_direct_io as override to silence clang -Werror,-Winconsistent-missing-override on macOS. Signed-off-by: Marcus Edel <[email protected]> * Route llama_file_disk::read_aligned_chunk through pimpl->read_raw on Windows; the Win32 impl has no aligned-chunk reader. Signed-off-by: Marcus Edel <[email protected]> * Fix Metal soft_max_back/rms_norm_back precision by dropping the nth=std::min(nth, ne00[/4]) clamps. Signed-off-by: Marcus Edel <[email protected]> * Fix mtmd PRIVATE_HEADER path so cmake --install can find debug/mtmd-debug.h from any source dir. Signed-off-by: Marcus Edel <[email protected]> * ci fix: Include scripts pkgs into requirements-all requirements/requirements-all.txt should have all the packages in the repository. It already includes the `../examples` packages, so let's also add a new file `scripts/requirements.txt`, so the CI pyright workflow can find the required modules. Also uprev the pytest version requirements from 8.3.3 to 8.4.2 to avoid divergencies. Signed-off-by: Guilherme Gallo <[email protected]> * common: Split jinja headers, add aux functions TODO: commit-split the common/chat.cpp changes Fix IQ1_S sharded model UAF and Linux Vulkan build, plus create_split_backend_buffers now moves per-split ggml_contexts into ml.ctx_map so create_backend_buffers can transfer ownership into pimpl->ctxs_bufs, the bundled vulkan_cpp_wrapper include is now gated on ANDROID to avoid clashing with the system vulkan.hpp on desktop, and the existing common/chat thinking_forced_open + 2-arg common_init_from_model_and_params overload. Signed-off-by: Marcus Edel <[email protected]> restore the delete-lora backstop in ~llama_model; nulling lora->model instead leaked every adapter still registered at model teardown (training relies on this backstop, and llama_adapter_lora_free already erases freed adapters from the set) * vulkan: Force f32 src1 through the strided cpy path which uses correct strides Signed-off-by: makaveli10 <[email protected]> Signed-off-by: Marcus Edel <[email protected]> * Keep TQ1_0/TQ2_0 on F32-src1 matmul path on Mali coopmat1. Signed-off-by: Marcus Edel <[email protected]> * ggml-metal: Guard against NULL return from ggml_metal_buffer_init / ggml_metal_buffer_map in the backend buffer-type allocators, so iOS allocation failures surface as clean error returns instead of a null-deref crash. Signed-off-by: Marcus Edel <[email protected]> * ggml-backend: assert hash_set.used/keys are non-NULL on entry to sched_reserve, sched_split_graph and hash_set_reset, so the next iOS Gemma 4 mtmd crash points to the exact lifecycle violation instead of dereferencing NULL inside an inlined bitset access. Signed-off-by: Marcus Edel <[email protected]> * ggml-metal: cache ggml_metal_device_get by index so each device's embedded Metal library is compiled exactly once. Signed-off-by: Marcus Edel <[email protected]> * ggml-metal: gate the simdgroup_mm probe behind MTLGPUFamilyApple1 so it only fires on Apple GPUs, Intel/AMD Mac GPUs cannot compile simdgroup_half8x8 and the pipeline compiler's GGML_LOG_ERROR() on failure aborts test harnesses that pattern-match ERROR lines. Signed-off-by: Marcus Edel <[email protected]> * ggml-backend: log the offending tensor's name, op and buffer/data/view_src state before the GGML_ASSERTs in ggml_backend_tensor_alloc, so an iOS Heavy9-Gemma4 abort in the CLIP image-encode allocator points at the specific tensor that violated the precondition instead of just a bare assert line. Signed-off-by: Marcus Edel <[email protected]> * mtmd-clip: drop the Gemma 4 set_warmup_n_tokens(256) override So warmup_image_size stays at the set_limit_image_tokens(252, 280) upper bound, fixing the iOS Heavy9-Gemma4 abort in ggml_backend_tensor_alloc where the gallocr reserved a buffer sized for 256 tokens during warmup. Signed-off-by: Marcus Edel <[email protected]> * Revert "fix: keep output tensor on CPU for iOS to avoid Metal buffer limits" This reverts commit ea81b60ebc0da9a86f1fa8139beca5eba299e7b6. Signed-off-by: Marcus Edel <[email protected]> * ggml-metal: drop the residency-set keep-alive default from 3 minutes to 1 second so Metal buffers can be reclaimed under iOS memory pressure. Signed-off-by: Marcus Edel <[email protected]> * ggml-vulkan, llama, common, mtmd: SSM_CONV dispatch fix b9341 API-compat shims against fb7695507 Upstream b9341 reshaped several APIs; this commit keeps qvac building and running against those interfaces without a full per-arch migration yet. The only functional behaviour change is the Vulkan SSM_CONV dispatch fix — the rest restores or shims qvac-side surfaces the rebase dropped. ggml-vulkan: - SSM_CONV binds four buffers, with a dummy bias buffer (src0) at the bias slot, to match the fused BIAS+SILU shader's 4-binding layout. Previously the dispatch bound 3 buffers, leaving dst (binding 3) unbound, so the conv output was never written. (APPLY_BIAS/SILU stay false.) llama-model: - virtual load_*/build_arch_* methods get no-op defaults so the monolithic switch(arch) path keeps compiling against b9341's polymorphic interface without splitting every arch into a subclass yet. - load_arch() and the flat attention-bias fields (bq/bk/bv/bo/bqkv) are restored. - build_graph() aborts if an arch has no polymorphic build_arch_graph(). llama-io / llama-context: - adopt read(size)/read_to() and const write_tensor (b9341 zero-copy read + read-only IO); add a read(dst) shim and a base read_tensor so kv-cache/memory serialization callers need no mass rewrite (the host/device readers still override read_tensor, so it stays virtual). - declare llama_memory_breakdown_print; default get_opt_pars to ggml_opt_get_default_optimizer_params. common / include/llama.h: - restore qvac surfaces dropped in b9341: llama_params_fit (+ status enum), build-info macros/externs, the llama-common CMake alias, and generation_prompt in the chat auto-parser. mtmd/clip.h: - re-expose clip_get_mem_usage (behind __cplusplus) and declare clip_has_whisper_encoder for common/fit.cpp's memory heuristics; guard the <map> include behind __cplusplus. tools/cli: - string_starts_with takes a string literal, not a char (build fix). tests: - test-backend-ops.cpp: add trailing newline only (no functional change). b9840 rebase: - Drop dead build-info declarations from common.h: the `print_build_info()` macro, the `LLAMA_BUILD_NUMBER` / `LLAMA_COMMIT` / `LLAMA_COMPILER` / `LLAMA_BUILD_TARGET` externs, and the `build_info` string are never referenced anywhere in the tree. They duplicate the `llama_print_build_info()` / `llama_build_info()` provided by common/build-info.h, which is what the codebase actually uses. b9952 rebase: - Drop the `llama_params_fit` public API (the `llama_params_fit_status` enum and `llama_params_fit` declaration) from `llama.h`; it is unused in the fork. * ggml-vulkan: align host buf alloc to minMemoryMapAlignment VMA can return a mapped pointer below the device minimum; ggml-alloc's base-align then eats unreserved slack. Use max(TENSOR_ALIGNMENT, minMemoryMapAlignment) when creating host buffers. * ggml-vulkan: disable ROPE+VIEW+SET_ROWS fusion on Mali/Adreno coopmat1 The b9341 rebase introduced a fusion that lets the ROPE compute shader write its output directly into the KV cache buffer (a permuted view 6+ MiB long) instead of into a small intermediate compute buffer followed by a separate SET_ROWS op. On Mali-G715, this fused dispatch corrupts subsequent GPU state — the next attention op's mul_mat_q_f16 descriptor-pool submit fence-waits and gets vk::Device::getFenceStatus: ErrorDeviceLost. Pre-b9341 source (f686a1324) on the same Mali-G715 hardware ran the un-fused two-op sequence (ROPE→compute buffer, SET_ROWS→cache) cleanly at ~19.6 t/s with bitnet TQ2_0 fully on the GPU. The compiled SPIR-V binaries for matmul/rope/set_rows shaders are md5-byte-identical between the two builds, so the regression is purely the fusion pattern, not the shader code. Gate the fusion off for Mali/Adreno KHR_coopmat1 (VK_VENDOR_ID_ARM or VK_VENDOR_ID_QUALCOMM with coopmat_support and !coopmat2). Desktop GPUs (NVIDIA/AMD/Intel) and coopmat2 hardware keep the optimization. The 5-op RMS_NORM+MUL+ROPE+VIEW+SET_ROWS fusion also routes through this guard via its ggml_vk_can_fuse_rope_set_rows check, so both fused paths fall back to the un-fused sequence on Mali. Signed-off-by: Marcus Edel <[email protected]> * ggml-vulkan: route TQ1_0/TQ2_0 MUL_MAT to CPU on Mali/Adreno coopmat1 The bitnet TQ2_0 inference path (matmul_tq2_0_f32 shader, added in the b9341 rebase with the TurboQuant import + TQ2_0 mul_mat_vec/mul_mm commits) hangs the GPU on Mali-G715. Symptom: first llama_decode submit returns vk::Device::getFenceStatus: ErrorDeviceLost; the resulting uncaught vk::DeviceLostError is rethrown from ~llama_context() during teardown, aborting the whole process. Pre-b9341 (b8828) the Vulkan backend had no GPU TQ matmul, so these ops graph-split to CPU and bitnet inference worked end-to-end on the same Mali-G715 at ~17.9 t/s. Restore the hybrid behavior on Mali/Adreno coopmat1 (KHR_coopmat) only — desktop GPUs (NVIDIA/AMD/Intel) and coopmat2 hardware are unaffected and keep the full GPU TQ path. Mirrors the existing GGML_OP_MUL_MAT_ID guard a few lines below, which already routes TQ2_0 MoE to CPU unconditionally. Verified on Pixel 9 (Mali-G715): bitnet_b1_58-large-tq2_0 now generates clean tokens with -ngl 999 (7.79 t/s gen) instead of device-lost on the first decode. Signed-off-by: Marcus Edel <[email protected]> * common: declare common_chat_msg_diff_to_json_oaicompat in chat.h Signed-off-by: Marcus Edel <[email protected]> * llama : skip gemma4 sliding_window_pattern read on vocab-only ggufs Signed-off-by: Marcus Edel <[email protected]> * ggml-vulkan: Add debug log for coopmat-v1 flags * ggml-vulkan: fix VkCooperativeMatrixPropertiesKHR list selection On Mali GPUs, vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR outputs entries that are not ordered the same way as other vendors or not ordered at all. The VkCooperativeMatrixPropertiesKHR selection code picks out the first found which will results in choosing options less optimal optionals e.g. f16xf16xf32 4x8x8. This fix sorts this list by largets to smallest volume, shape & type. * ggml-vulkan: workaround-fix for coopmat properties with large shape sizes The current cm1 code path doesn't handle VkCooperativeMatrixPropertiesKHR options with shapes larges than 16, e.g. on Mali G715 f16xf16xf32 16x32x32 This workaround filters these entries out from selection. * ggml-vulkan: add new cm1 multi-mat path for f32 coopmat inputs The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d374 ("vulkan: make mul_mm ALIGNED a spec constant", #24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block. * ggml-vulkan: fix tile sizes for coopmat shape sizes greater than 16 (per axis) * Fixes not handling subgroup sizes other than 8/32 (e.g. Mali-G715 subgroup size is 16) * Fixes incorrect tile sizes for coopmat shape sizes greater than 16 (per axis), which caused out-of-bounds memory access and incorrect results on GPUs with subgroup sizes of 16 (e.g. Mali-G715 coopmat f16xf16xf32 16x32x32) * ggml-vulkan: remove Mali/Andreno specific workaround fixes for coopmats * ggml-opencl: restore Adreno kernels lost in b9341 rebase The b9341 rebase pulled the upstream renames for the Adreno q4_0/q4_0_spec/ q8_0/q4_0_gemm kernels (the file rename portion of ggml-org/llama.cpp ff806a110) but kept the unported ggml-opencl.cpp call sites that still look up the old symbol names (kernel_gemv_noshuffle, kernel_mul_mat_Ab_Bi_8x4, kernel_mul_mm_q8_0_f32_8x4). With GGML_OPENCL_EMBED_KERNELS=ON the build fails before link because the four old .cl.h includes have no source. Restore the four kernel files from tetherto/master so the existing call sites resolve, add them to the embedded-kernel list, and switch the q8_0 include to the post-rename name (the file is a pure rename — same symbol kernel_gemv_noshuffle_q8_0_f32 — so the call site already matched). Signed-off-by: Marcus Edel <[email protected]> * ggml-metal: drain residency set at teardown instead of asserting. Signed-off-by: Marcus Edel <[email protected]> * ci: disable native CPU optimizations for low-perf builds * ggml-opencl: support quantized KV cache rows Add OpenCL set_rows/get_rows coverage and Flash Attention kernels for q4_0/q8_0 KV cache so quantized cache can remain on GPU when supported. Co-authored-by: Cursor <[email protected]> * llama : exclude QWEN3NEXT/QWEN35/QWEN35MOE from SPLIT_MODE_TENSOR Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 416dc51d91bb9f34d6aa556f88897e1ea3071c75) * hip: allow-list gated_linear_attn_f32<64> VGPRs The b9518 rebase instantiates gated_linear_attn_f32 at head_dim 64 (linear-attention path, eg qwen3next gated-delta-net): 283 VGPRs, over the 256 threshold of the HIP quality check. The <128> variant is already allow-listed (upstream #20430); the <64> variant is the same register-heavy sequential kernel, so ignore it the same way. Signed-off-by: Guilherme Gallo <[email protected]> * ui: Uprev playwright to 1.60 and add timeouts There is an issue with Node 26 with playwright < 1.60.0, that makes the UI jobs hang during installation process. Example job: github.com/tetherto/qvac-fabric-llm.cpp/actions/runs/27588826171 Related issue: https://github.com/microsoft/playwright/issues/28189 Also add timeouts in affected jobs to prevent eventual regressions. Signed-off-by: Guilherme Gallo <[email protected]> * tests: download test model with retry + backoff The test-download-model fixture did a single file(DOWNLOAD); a HuggingFace HTTP 429 (per-IP rate limit) failed it outright and took test-thread-safety down with it as a FIXTURES_REQUIRED dependent. HF seems to answer 429 with a short "Retry-After: 1" header, which curl/wget honor over their own backoff, so a downloader's built-in retries fire ~1s apart and burn out within seconds while the limit is still active. Keep the cmake-native file(DOWNLOAD) (no internal retry to be talked out of by the header) and wrap it in an explicit loop with our own exponential backoff (15,30,60,120s) plus jitter -- a wait floor the server cannot shorten. The hash is verified afterwards in cmake, and an already-valid local copy is reused. The source URL is overridable via -DMODEL_URL (mirror/proxy, or httpbun when testing the retry path), e.g.: rm -f /tmp/mock-model.gguf cmake -DDEST=/tmp/mock-model.gguf -DNAME=x \ -DHASH=SHA256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 \ -DMODEL_URL=https://httpbun.com/mix/delay=3/s=503,501,429,200,200 \ -P cmake/download-models.cmake Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Guilherme Gallo <[email protected]> * ggml-cpu: Add portable CPU prefetch hint macro (cherry picked from commit 7ca6374fb2070401487990206528350d53356ce3) * ggml,ggml-cpu: TurboQuant core/cpu api changes Modified OG commit message (minus Vulkan changes): ggml,vulkan: import TurboQuant (PR #133) onto qvac-b8828 Lossy rebase of tetherto/qvac-fabric-llm.cpp#133 ("QVAC-18665: TurboQuant (Vulkan) rebased into 8189") onto lubosz/qvac-b8828. Net effect: adds the TurboQuant (TBQ3_0/TBQ4_0, block=128 and block=64) and PolarQuant (PQ3_0/PQ4_0, block=128 and block=64) quantization formats, CPU reference implementations, KV cache integration. Resolution notes (lossy fast-path): - ggml_type enum: kept qvac-b8828's NVFP4 (40) and Q1_0 (41); renumbered the TBQ/PQ family to 42..49 so GGML_TYPE_COUNT is now 50. Symbolic references in TBQ shaders/code are unchanged; only numeric slots shifted by +2. - llama-context: fixed PR's direct-compare against n_embd_head_k against the qvac-b8828 indexed-accessor API (n_embd_head_k() with default il=0). - llama-graph: kept HEAD's self_k_rot / self_v_rot[_swa] members and mctx->set_input_*_rot routing instead of PR's direct set_input_hadamard writes; ggml_rotate_hadamard callsites updated. (Partial) squashed commits: - kv-cache: route TBQ/PQ K/V to CPU buft when the chosen Vulkan device's SET_ROWS pipeline for the requested cache type is null. - fix: default attention rotation to off; opt-in via LLAMA_ATTN_ROT_ENABLE=1. - ggml-vulkan,kv-cache: support TBQ/PQ head_dim multiples Allow Qwen3.5-style 256-wide KV heads to use base TBQ/PQ blocks and apply TBQ QJL correction per 128-wide sub-block in Vulkan flash attention. - fix: enable attention rotation by default only for low-bit TBQ/PQ KV caches. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 33d96b7eb8eafa05577ca14990890b498a080d4c) * ggml-vulkan: TurboQuant vulkan backend and shader integration Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc2f7bee74721de2003435d031a7a7bb116) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d374 ("vulkan: make mul_mm ALIGNED a spec constant", #24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd61002 "vulkan/cpu: Support f16 as SET_ROWS src" (#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green. * cmake: install convert_hf_to_gguf.py alongside vulkan_profiling_analyzer.py Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 3a7689f9ac8f22e422443deb4cca7cfe440b72af) * feat: support M-RoPE K-shift (#146) * feat: support M-RoPE K-shift Co-authored-by: Cursor <[email protected]> * test: cover image-token M-RoPE K-shift Co-authored-by: Cursor <[email protected]> * fix: guard image M-RoPE temporal positions Co-authored-by: Cursor <[email protected]> * fix: guard quantized K-shift rotation Co-authored-by: Cursor <[email protected]> * test: cover quantized M-RoPE K-shift Co-authored-by: Cursor <[email protected]> * test: name M-RoPE K-shift fixtures Co-authored-by: Cursor <[email protected]> * fix: guard empty mtmd image chunks Co-authored-by: Cursor <[email protected]> * fix: support quantized CPU copy views Co-authored-by: Cursor <[email protected]> * fix: support TBQ/PQ CPU copy views Co-authored-by: Cursor <[email protected]> * fix: align quantized K-shift views Co-authored-by: Cursor <[email protected]> * test: add K-shift cache coverage Co-authored-by: Cursor <[email protected]> * fix: link KV cache test with CPU backend Co-authored-by: Cursor <[email protected]> * fix: handle CPU variant targets in KV cache test Co-authored-by: Cursor <[email protected]> * fix: avoid CPU backend init in KV cache test Co-authored-by: Cursor <[email protected]> * fix: address K-shift review feedback Co-authored-by: Cursor <[email protected]> * fix: simplify K-shift support check Co-authored-by: Cursor <[email protected]> * fix: guard M-RoPE seq_div Co-authored-by: Cursor <[email protected]> * fix: keep M-RoPE div guard active Co-authored-by: Cursor <[email protected]> * fix: clarify quantized copy stride guard Co-authored-by: Cursor <[email protected]> --- Co-authored-by: Cursor <[email protected]> (cherry picked from commit 4b850a920f0ed448eb51cbc2ff0476d8b4433e0a) b8852 rebase: - GCC16 (-O3 -Werror) flags a false-positive stringop-overflow on `data.output.resize(n, 0)`: the `int8_t` fill-append path instantiates __uninitialized_move_if_noexcept_a and its range analysis goes wrong b9952 rebase: - Deduplicate the M-RoPE k-shift test: factor the repeated `ggml_rope_multi` calls into a `mrope_shift` lambda, the p0/pd/p1 position setup into `make_shift_positions`, and the per-element diff/sum error loops into a shared `rel_err()` helper. * ggml-vulkan,common,cmake: fix TurboQuant copy_to_quant codebook swap, restore reasoning_budget, fix llama install include path Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit e763aca4e160b46363af1a56b853966ecef3eaf7) * ggml-opencl: serialize lazy device-context and kernel-program init to fix a multi-instance clBuildProgram race that corrupts the Adreno driver heap. Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 6d9210b029dd658ebbf5c3bd3a19f4d4ad98fcd9) * docs: update lora finetuning documentation. Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 1b3958bc5a2b264afcaaab5cef766f226d26382a) * Eval scripts for longbench, ZeroSCROLLS, L-Eval, NIAH added (cherry picked from commit ec64a4a6deb9e548a849f2b5741b185a10f86d3e) * NIAH eval removed (cherry picked from commit 391dd8a36b7f825187b5601f2f0de32d46e4c825) * Code refactored, tests: extract shared KV-cache eval helpers into kv_cache_{eval,bench}_common (cherry picked from commit 44b5152d1de4384f5e860dfb7a3e91ae810e3abb) Co-authored-by: Guilherme Gallo <[email protected]> --- b9952 rebase: - Fold `ruler-bench.sh` onto the shared `kv_cache_bench_common.sh` helper: it now sources the common file and drops its own duplicated uv/venv bootstrap - Add llama-2 / phi tokenizer detection to the shared helper along with shellcheck directives. * tests: add gkamradt-style NIAH KV-cache eval; fix ARG_MAX in _kv_infer_completion for >16k ctx (cherry picked from commit 137df7393a5a859d00c7d79f6717f39c07ae2bbb) * common: fix use-after-free when adopting an externally-loaded model The common_init_from_model_and_params(llama_model*, common_params&) overload built its result with the file-based common_init_result(params) constructor, which loads a model from params.model.path and creates a context + samplers bound to it. It then overwrote pimpl->model with the caller-provided model, freeing the file-loaded model while its context and samplers still referenced it. Destroying that stale context (~llama_context via llama_free) then read the freed model -- a heap-use-after-free. It also ran the EOG logit-bias and sampler setup twice (once per model). Add a private empty common_init_result() constructor and use it in this overload so the externally-loaded model is adopted into a fresh result, with the context and samplers built only from that model. (cherry picked from commit 2895aa434d8e0f606e315efc450c164792913b26) * common: fix common_init_from_model_and_params returns nullptr on load failure The common_init_from_model_and_params(llama_model*, common_params&) overload mirrored common_init_from_params, which loaded a model from params.model.path and built a context + samplers bound to it. If the model load failed, it returned a null common_init_result_ptr, which callers dereferenced and crashed. Mirror common_init_from_params: on load failure return a *valid* empty result (model()/context() == nullptr), never a null pointer. Callers adopt this result and inspect model()/context() to detect failure (e.g. and then throw). (cherry picked from commit 2098f56c184ac291496ed52264eb241ba408ae1b) Co-authored-by: Guilherme Gallo <[email protected]> --- b9952 rebase: - Collapse the duplicated context-setup tail (context check, control vectors, rerank validation, LoRA, warmup) in `common_init_from_params` into a single delegation to `common_init_from_model_and_params` - Route the shared path's logging through the `COM_*` macros. * model-load: register split tensors in tensors_by_name during incremental load When loading a sharded model via the incremental split-future path, a TENSOR_DUPLICATED reference (e.g. a model with tied embeddings, where output.weight aliases token_embd.weight) failed with: file not found for tensor 'token_embd.weight' at split-index N create_tensor resolves a TENSOR_DUPLICATED reference by first looking the original up in tensors_by_name (so the duplicate aliases the already-loaded tensor instead of re-reading it). Its comment claimed tensors_by_name was populated by create_split_backend_buffers, but it never was: the only population site iterates ml.ctx_map after loading, and on the incremental path ml.ctx_map is already empty by then (each split's contexts are moved into ctxs_bufs and erased per-split as they upload). The non-incremental path still has its contexts in ml.ctx_map, so it was unaffected. With tensors_by_name empty, the duplicate fell through, was re-created bound to its source split, and triggered a second create_split_backend_buffers for that split after release_split() had already freed its file -- hence the "file not found" error. This fix populates tensors_by_name inside create_split_backend_buffers, capturing each split's tensor pointers while the file is still mapped (the pointers stay valid across the subsequent ownership move into ctxs_bufs). The duplicate lookup now resolves the original and no longer re-reads a released split. Reproduced and verified with tests/test-model-load-memory-split on the 8-shard tied-embedding Llama-3.2-1B-Instruct-Q4_0 model; 3-shard Qwen3 and 8-shard bitnet split models continue to load. (cherry picked from commit e4e2aa523d21b5e32abbbf99b5a822bd763e872e) * opencl : add CONV_2D_DW, POOL_2D, HARDSWISH, HARDSIGMOID kernels Add the ggml-opencl kernels DocTR's MobileNetV3 detector + CRNN recognizer need so the whole OCR graph runs end-to-end on the Adreno OpenCL backend instead of asserting on an unsupported op (the OCR pipeline runs the graph on a single backend, so any missing op is a hard abort, not a CPU offload). - HARDSIGMOID / HARDSWISH (UNARY): MobileNetV3 activations + SE blocks - POOL_2D (AVG): global average pool in SE blocks - CONV_2D_DW: depthwise conv, F32 weights (DocTR promotes depthwise weights to F32 so the direct op runs on every backend) Regular convs use the existing conv2d_f16_f32 direct kernel (no new op). Numerically validated on a Galaxy S25 (Adreno 830): identical region count and OCR output vs CPU. (cherry picked from commit 4e981bc48403877e41a94492b7a457098f0c08ef) * kv-cache : cover GGSQ M-RoPE ext restore Co-authored-by: Cursor <[email protected]> (cherry picked from commit 0e36ea55cc11a4df6a334ba9a764b9d89a70d234) * ggml-vulkan: remove TQ MUL_MAT -> CPU fallback on Mali/Adreno coopmat1 (cherry picked from commit ea0bf3203de8d7bd55ddb8e213db5ed597c6ef7b) * test : extend test_conv_2d_dw coverage (5x5, dilation, batch) Add backend-ops cases for the conv_2d_dw kernel that the existing 3x3 / dilation=1 cases don't reach: 5x5 kernels (MobileNetV3-style), dilation>1, and batched inputs (N>1), each in both whcn and cwhn layouts. Checked against the CPU reference. * ggml: add GGML_OP_SIGMOID_BACK op * ggml-cpu: implement sigmoid_back * ggml-vulkan: implement sigmoid_back * test-backend-ops: add sigmoid_back test * ggml: Add stop-gradient backward for SSM, L2_NORM, GATED_DELTA_NET ops Signed-off-by: makaveli10 <[email protected]> * ggml: Add concat cpu backward pass Add backward case for GGML_OP_CONCAT in ggml_compute_backward. Splits the upstream gradient into two views along the concat dimension and accumulates them into the gradients of src0 and src1. Signed-off-by: makaveli10 <[email protected]> * ggml: Add TANH backward pass for cpu Signed-off-by: makaveli10 <[email protected]> * ggml: add GELU backward Signed-off-by: makaveli10 <[email protected]> * ggml: add MUL_MAT_ID backward (back_a, back_b) Signed-off-by: makaveli10 <[email protected]> * ggml: generalize get_rows_back to N-D tensors ggml_get_rows() supports up to 4-D forward but ggml_get_rows_back() asserted matrix(a) && vector(b) and emitted a 2-D output. This blocked any backward pass that walked through a get_rows call with batched indices, for e.g. MoE router-weight gather where probs is reshape_3d to [1, n_expert, n_tokens] before get_rows on selected_experts. Signed-off-by: makaveli10 <[email protected]> * ggml-vulkan: implement gelu_back * test-backend-ops: add gelu_back test * ggml: add L2_NORM_BACK op with CPU implementation * ggml-vulkan: implement L2_NORM_BACK * ggml: stop using stop-grad for L2_NORM_BACK * test-backend-ops: add L2_NORM_BACK test * tests: fix crash for GET_ROWS_BACK * ggml-vulkan: implement MUL_MAT_ID_BACK_A * test-backend-ops: add MUL_MAT_ID_BACK_A test * ggml-vulkan: implement MUL_MAT_ID_BACK_B * test-backend-ops: add MUL_MAT_ID_BACK_B test * test-backend-ops: add MUL_MAT_ID_BACK perf cases * ggml-rpc: account for new backward ops (GGML_OP_COUNT 100->105), bump proto patch version Signed-off-by: Marcus Edel <[email protected]> b10069 rebase: - Upstream b9952..b10069 added new graph ops (DeepseekV4 fused hyper-connection ops, GGML_OP_LIGHTNING_INDEXER), growing the fork's serialized op table from 109 to 113 entries and shifting the op IDs on the wire; the header's static_assert caught it as designed. - Bump the patch version 3->4 so the fork's protocol string no longer collides with two different op tables that also claim 4.0.3: stock b10069 (101 ops) and the previous b9952 fork (109 ops). (Superseded later this cycle by the 5.0.0 major bump, once the audit showed patch differences never reject a peer.) Assisted-by: Codex Assisted-by: Claude Fable 5 b10069 rebase: - The post-rebase audit flagged that the patch bump taken earlier this cycle protects nobody: the handshake rejects peers only on a major-version mismatch, so a 4.0.4 fork would still interoperate with the 4.0.3 peers (stock b10069, the b9952 fork) whose serialized op IDs differ. - Upstream b9952..b10069 added new graph ops (DeepseekV4 fused hyper-connection ops, GGML_OP_LIGHTNING_INDEXER), shifting the fork's op table from 109 to 113 entries -- a breaking wire layout, so treat it as one: move to protocol 5.0.0 and let the existing major-version check reject incompatible peers in both directions. - Verified against a fake 4.0.3 server: the client prints 'RPC server version mismatch: 4.0.3' and refuses cleanly; a real 5.0.0 rpc-server connects and the tp-tier loopback passes. Assisted-by: OpenAI Codex Assisted-by: Claude Fable 5 * ggml-metal: implement gelu_back, l2_norm_back, and mul_mat_id_back_a/b backward ops, cont the rms_norm_back gradient for QK-norm graphs, and log the outdated-gemma4-template warning once. Signed-off-by: Marcus Edel <[email protected]> * gml-vulkan: implement GATED_DELTA_NET_B. Signed-off-by: Marcus Edel <[email protected]> * ggml: add SSM_CONV_BACK_SX and SSM_CONV_BACK_C ops Replace the SSM_CONV stop-gradient stub with analytical backward, wiring grad-sx and grad-c through two new ops. CPU/Vulkan kernels follow in later commits. Assisted-by: Claude Opus 4.8 * ggml-cpu: implement SSM_CONV_BACK_SX and SSM_CONV_BACK_C Assisted-by: Claude Opus 4.8 * ggml-vulkan: implement SSM_CONV_BACK_SX and SSM_CONV_BACK_C Assisted-by: Claude Opus 4.8 * test-backend-ops: add SSM_CONV_BACK tests and enable ssm_conv grad check Assisted-by: Claude Opus 4.8 * ggml-metal: implement ssm_conv_back_sx/_c and gated_delta_net_back backward ops. Signed-off-by: Marcus Edel <[email protected]> Co-authored-by: Cursor <[email protected]> * feat(mtmd/qwen3vl): multi-tile batching with --image-tile-mode Qwen3.5-VL multi-tile vision encoding, controlled by --image-tile-mode (env LLAMA_ARG_IMAGE_TILE_MODE): 0 = batched — all tiles in one forward pass (default) 1 = sequential — tile-by-tile encoding (benchmarking) 2 = disabled — single tile via dyn_size (original behaviour) New types: common_image_tile_mode (common.h), clip_image_tile_mode (clip.h), mtmd_image_preprocessor_qwen3vl (mtmd-image.h/.cpp), grid_x/grid_y in mtmd_image_tokens and clip_image_f32_batch. Encoder / preprocess: - clip.cpp: Qwen3VL batch_size>1 path; per-tile attention with M-RoPE; sequential mode encodes tiles one-by-one; tile-size mismatch logs instead of aborting - mtmd-image.cpp: aspect-ratio-aware grid selection over all col×row ≤ max_tiles pairs; dyn_size fallback for sub-tile images - mtmd.cpp: tile-major decoder position mapping; full-image nx/ny = tile×grid - qwen3vl.cpp: batched inp_raw; per-tile M-RoPE views; attn_out accumulation Squashes the review / robustness fixes that shipped on top of the feature: - fall back to sequential on batched-encode OOM (check the previously ignored ggml_backend_sched_alloc_graph return) - honor preproc_max_tiles; drop inert per-tile M-RoPE offsets; extract pick_grid_by_log_ratio; crop via img_tool::crop; broadcast pos embedding - extract preprocess_dyn_size_aligned shared by dyn_size and the qwen3vl small-image fallback; align via patch_size*n_merge Part of the qvac fork's mtmd feature set carried across the b9518 -> b9840 rebase. Cherry-picked upstream sources folded here: d70b884dac53 feat: multi-tile batching 730c14ce8581 fix: OOM -> sequential fallback e02fa8aa9d2b fix: review comments fd8011798399 fix: dedup dyn_size / small-image preprocessing Co-Authored-By: Claude Opus 4.8 <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> --- b9952 rebase: - Share one local-coordinate M-RoPE positions block across all tiles (every tile uses identical local coords) instead of building a per-tile tile-major array, and pass it straight to each tile's rope. - Reuse the single-tile encode buffers across the batch loop, accumulate attention in place via `ggml_set_2d_inplace` (returning `out_b` directly when batch_size == 1), and default `image_tile_mode` to 1 (sequential) to match common_params. * feat(mtmd/qwen3vl): global overview thumbnail for multi-tile encoding Multi-tile hard-crops the image with no overlap, so text on a tile seam is split across tiles and only a fragment reaches the LM (e.g. "$975.00" read as "$97"). Add a LLaVA-NeXT-style global overview: a downscaled full image (tile_px × tile_px) prepended to the batch and encoded as its own 1×1 chunk before the tile grid, so seam-split text stays readable while the tiles are left untouched. DocVQA ANLS (batched, n=50): 0.816 -> 0.917. - clip_image_f32_batch.has_overview marks entries[0] as the overview - qwen3vl preprocessor builds the thumbnail for the multi-tile path (disabled / small-image dyn_size paths unaffected) - mtmd.cpp emits the overview as a 1×1 mrope chunk, then the tile grid Squashes the fixes that shipped on top of the overview: - clear has_overview after splitting the overview chunk; guard front(); assert remaining entries == grid_x*grid_y so future layout drift fails loud - replace the raw-dim (img ≤ tile_px) threshold with a canvas upscale guard: pick grid, compute the target canvas, fall back to dyn_size only if the canvas would upscale the image in either dimension - default --image-tile-mode to sequential - adapt to this branch's private clip_image_u8 nx/ny: read dimensions via img.get_size() and drop an unused batch_size local, so mtmd compiles on the fork (branch-local, not from upstream) Part of the qvac fork's mtmd feature set carried across the b9518 -> b9840 rebase. Cherry-picked upstream sources folded here: 19697714d024 feat: global overview thumbnail 90d6b2bb8638 fix: clear has_overview after splitting the chunk e34f9e3155ec fix: canvas upscale guard f240036eaddf fix: default tile-mode sequential Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LtvDtVczc9j3gmCS4JUS7f --- b9952 rebase: - Drop the `has_overview` flag from `clip_image_f32_batch` and instead carry the "entries[0] is the downscaled overview thumbnail" signal on `mtmd_image_preproc_out::overview_in_entries`, propagating it through the tokenizer. The clip emit path reads a local `has_overview_entry` rather than mutating the batch. * llama: add sequence token count memory API Co-authored-by: Cursor <[email protected]> (cherry picked from commit 2d5615be9ca306ddf4be5fe5bcb86ab898eb272f) * llama: add seq_token_count override for the DSA KV cache Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 0eeebe0bdefc915f5906493f63d9ec779775e76e) --- b9840 rebase: - seq_token_count() is a pure-virtual on llama_memory_i (added by "llama: add sequence token count memory API"), so every memory implementation must override it or it stays abstract. - upstream 8c146a836 ("DeepSeek V4", #24162) introduced a second DSA cache class, llama_kv_cache_dsv4, alongside llama_kv_cache_dsa. The target commit only added the override to llama_kv_cache_dsa and missed dsv4, so on b9840 dsv4 is abstract and the tree fails to build. Co-authored-by: Guilherme Gallo <[email protected]> * Document TurboQuant benchmarks Highlight TurboQuant support in the README and add the full benchmark report for reviewers. Co-authored-by: Cursor <[email protected]> * Link TurboQuant test coverage Point the README coverage summary at the relevant correctness, performance, backend, and benchmark files. Co-authored-by: Cursor <[email protected]> * Mention TurboQuant validation scripts Limit the README coverage links to the perf, perplexity, and eval scripts used for TurboQuant validation. Co-authored-by: Cursor <[email protected]> * Update TurboQuant eval script links Include the new KV-cache eval orchestrators in the README coverage summary. Co-authored-by: Cursor <[email protected]> * Add PQ rows to Qwen benchmark highlights Include the Qwen3.5 pq4_0/pq4_0 and pq3_0/pq3_0 results in the README highlight table. Co-authored-by: Cursor <[email protected]> * Use LongBench in TurboQuant quality summary Replace the NIAH grid callout with the Qwen3.5 LongBench result in the README. Co-authored-by: Cursor <[email protected]> * Add Qwen3.5 f16 benchmark baseline Co-authored-by: Cursor <[email protected]> * Add Qwen3.5 8k f16 benchmark baseline Co-authored-by: Cursor <[email protected]> * Avoid URL substring assertion in MCP test Use structured request and response URLs in the diagnostic logging test so CodeQL does not flag substring URL matching. Co-authored-by: Cursor <[email protected]> * flake8 lint fix * flak8 noprint lint fix, ty check fix * ggml: gemma 4 chat template parsing for LoRA finetune Signed-off-by: makaveli10 <[email protected]> * llama-lora-training: MoE expert LoRA & tighten module matcher Signed-off-by: makaveli10 <[email protected]> * llama-graph: training-mode workarounds for MoE backward in build_moe_ffn Signed-off-by: makaveli10 <[email protected]> * ggml-metal: implement the sigmoid_back backward op Signed-off-by: Marcus Edel <[email protected]> * mtmd: use the M-RoPE position type in mtmd_test_create_input_chunks so test-mtmd-c-api's decoder-pos assertions match the fixture layout Signed-off-by: Marcus Edel <[email protected]> * ggml: fixes bugs in GATED_DELTA_NET_BACK op through autograd path The backward kernel for gated-delta-net (used in LoRA training of models like Qwen3.5/Kimi-Linear) had six bugs, present in all three compute backends. They were never caught because the op was only reachable indirectly via the autograd path, which happened to mask several of them. - K (snapshot slot count) was read from state->ne[1], which is always == head_size, not K. Caused crashes/hangs whenever K != head_size. Fixed by deriving K from the incoming gradient tensor's shape instead (CPU, Metal, Vulkan). - CPU used the wrong memory stride (per-head instead of per-sequence) when locating a sequence's initial state, silently reading the wrong sequence's data whenever n_seqs > 1. - Vulkan/Metal multiplied a state offset by K where the state tensor has no K dimension at all; invisible when K=1, wrong otherwise. - CPU/Vulkan/Metal had a leftover loop zeroing out non-existent "extra" state-gradient slots for K>1, corrupting adjacent scratch memory. - CPU/Vulkan/Metal mapped tokens to snapshot slots in the reverse order the forward op uses. Every prior check injected a uniform gradient (e.g. via a SUM reduction) across all slots, so the reversal never changed the result and went undetected. Only caught by feeding distinct gradient values per slot against an independent from-scratch reference implementation. Verified against cross-backend agreement (CPU vs Vulkan), the existing finite-difference gradient checks, and a hand-written independent Python/numpy reference implementation of the delta-rule recurrence (forward values, and backward gradients via finite differences on that same reference) for hand-picked and randomized cases including K=1, K>1 exact-match, K>1 overflow, and n_tokens<K. Assisted-by: Claude Sonnet 5.0 Assisted-by: Claude Opus 4.8 * tests: add test for gated_deltanet_back op Assisted-by: Claude Sonnet 5.0 * ggml-vulkan: optimize gated_delta_net_back with subgroup ops Switch to explicit subgroup operations over pure shared memory read/writes. Assisted-by: Claude Sonnet 5.0 --- b9952 rebase: squash `ggml-vulkan: remove sc_carry scratch region (S_v * S_v) alloc/stride of GDN-back op` to make rebases easier > After the optimizations applied to gated_deltanet_back op in the "optimize gated_delta_net_back with subgroup ops" commit, the sc_carry scratch region (S_v * S_v) is no longer used so it can be removed from scratch allocation / stride offets. * vulkan: fix count_equal_masked device-lost hang on RADV/GFX1151 by reducing in shared memory and accumulating with a 32-bit atomic instead of a 64-bit one. Signed-off-by: Marcus Edel <[email protected]> * tests: cover sequence token count memory API Co-authored-by: Cursor <[email protected]> * ci : functionally test the OpenCL ops on an Intel CPU ICD The opencl-adreno job only builds (its Test step is gated on x64 while the build is arm64), and test-backend-ops was only built for wasm — so nothing executed these kernels in CI. Add a Linux job that builds with GGML_OPENCL=ON (Adreno kernels off → portable OpenCL C), installs intel-opencl-icd, and runs test-backend-ops for CONV_2D, CONV_2D_DW, POOL_2D, HARDSWISH and HARDSIGMOID against the CPU reference. Catches kernel math / indexing / dtype regressions. A CPU ICD does not reproduce Adreno-compiler bugs; full device confidence still relies on the manual Firebase Test Lab run. * ci : drop -DLLAMA_FATAL_WARNINGS from opencl test job (upstream fall-throughs) * ggml-vulkan: opt/cut gated_delta_net_back scratch traffic and lift occupancy - Rewrite phase B as a coalesced row-parallel pass and reconstruct exp(g)*S_prev instead of reloading it, cutting per-token scratch traffic (6 -> 4 streams) with coalesced reads - Store u/sd from the scans instead of recomputing, dropping a matrix read and reduction in phase A2 - Remove the per-token workgroup barriers from the serial scans - Run several subgroups per workgroup to hide the token loop's latency - Factor out the shared clustered-add reduction helper (no behavior change) * ggml-vulkan: avoid subgroupClusteredAdd in gated_delta_net shaders on Adreno Signed-off-by: Marcus Edel <[email protected]> * ui: pin HF asset version to the upstream base tag, not the commit count LLAMA_BUILD_NUMBER is derived from `git rev-list --count HEAD`, which in this fork also counts every downstream commit (e.g. b9952 + 271 downstream commits -> 10223). The prebuilt-UI download then asks the ggml-org/llama-ui bucket for the never-published tag b10223 (as of 26-07-17), 404s, and falls back to 'latest' whose bundle no longer ships loading.html. llama-ui-embed requires that asset and exits 1, which is a FATAL configure-time error: every networked build that reaches the llama-ui-assets target dies, even with -DLLAMA_BUILD_UI=OFF. Resolve the version from the nearest reachable upstream release tag instead. Co-Authored-By: Claude Opus 4.8 <[email protected]> * model: drop unused params from the model-load path (post-#22004 cleanup) Remove the unused `metadata`, `set_tensor_data`, `set_tensor_data_ud` and `file` parameters (and their b9310-rebase `(void)` silencing casts) from `llama_model_load` and update its call site; mark the now-unused `set_tensor_data` / `set_tensor_data_ud` parameters of `llama_model_load_from_file_impl` `[[maybe_unused]]` to keep -Werror happy. Downstream fixup on top of upstream PR #22004 ("model: move load_hparams and load_tensors to per-model definition", landed at b9019). Its target is upstream, so it can never autosquash into a downstream commit; carry it as a standalone downstream patch instead of a dangling squash!/fixup! pair. * common: extract SFT dataset builder into common/finetune.{h,cpp} Move common_opt_sft_dataset_init out of common.cpp into a dedicated finetune translation unit, dropping the nlohmann include from common.cpp. Unify the per-template assistant span scanners into one tag-driven loop and write samples directly into the dataset instead of staging vectors. Assisted-by: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S28Qf144zq87KN8AdbJf5z * Serialize lazy OpenCL Flash Attention compilation Guard the per-device FA maps and shared kernel argument state at both entry points that can access them. Keep compilation serialization in the existing helper locks. Assisted-by: OpenAI Codex * Load the exported OpenSSL dependency Assisted-by: OpenAI Codex * ci : disable OpenMP in wasm webgpu build Upstream master's ubuntu-wasm job is red with the same error: github.com/ggml-org/llama.cpp/actions/runs/29361861822/job/87183687962 Signed-off-by: Guilherme Gallo <[email protected]> * tests: skip test-recurrent-state-rollback on WebGPU builds Signed-off-by: makaveli10 <[email protected]> * vulkan: give the TBQ QJL correction its own push-constant struct matching its shader layout Signed-off-by: Marcus Edel <[email protected]> * common: disable weight repacking for training loads, backward ops can't read repacked layouts Signed-off-by: Marcus Edel <[email protected]> * fix: repair MoE/GDN LoRA finetuning on the Metal backend Enable training loss scaling for mixture-of-experts architectures, also correct SGD weight decay under loss scaling, dropping the loss scale env var Signed-off-by: Marcus Edel <[email protected]> * fix: persist the training loss scale with the optimizer state Signed-off-by: Marcus Edel <[email protected]> * hip: allow-list rwkv_wkv_f32<128> VGPRs GPUs have a limited number of fast registers (VGPRs) CI checks fail when any HIP kernel that uses more than 256 of them, unless that kernel is on a known-ok list Two kernels were over the limit (rwkv_wkv_f32 and a Q2_K matmul tile) Similar kernels were already on that list, so this commit just adds these two names too. So we also don't fail the build because of these two Signed-off-by: Guilherme Gallo <[email protected]> * vulkan: compile pipelines on a big-stack thread on macOS Signed-off-by: Marcus Edel <[email protected]> * vulkan: bounds-check the padded row index in norm/sum-family shaders Signed-off-by: Marcus Edel <[email protected]> * Revert the CI/requirements/mtmd-test fixups (gg_wget curl fallback, explicit jinja2, torch py<3.10 marker, mtmd M-RoPE test-input) Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit c9c63fbb357a4b8088cd794f43556edb3790d407) * doc: document the rope type setting Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 395d168e0682d2c7f20f2e57959855b6b1a63dcd) * ci: setup-node in the GPU-container build legs so the web UI builds from source (fixes llama-ui-embed missing loading.html from the stale prebuilt dist) Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit 47bc924e138ed51a92c0e2f8bb9de5ab335de449) * ui: overlay the source static/ tree onto the dist so llama-ui-embed always has loading.html even when the prebuilt HF dist is stale Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit bde76f6b4f0df9f61eeacdc1ae0d8219ddeaab3d) * ggml-cpu: drop SVE/SVE2 from linux-arm64 CPU variants (keep SME, i8mm) SVE/SVE2 per-microarch kernels are numerically broken on real linux-arm64 (Graviton3/Neoverse-V1) under GGML_CPU_ALL_VARIANTS: vla/pi05 integration diverges from the PyTorch reference (cos ~0.77 vs ~0.999) only when an SVE variant is runtime-selected. Strip only SVE/SVE2 from the linux-arm64 list, keeping DOTPROD/FP16/MATMUL_INT8(i8mm) and SME (not implicated). Variants that become exact duplicates after the strip are dropped. Android/Apple/other platforms are untouched. (cherry picked from commit 29578a222ae8a12482f42be1a73c996fcbd39e13) * ggml-config: don't require find_dependency(Vulkan) under GGML_BACKEND_DL (cherry picked from commit d048779181841cd498d08584fdf70f283fb40959) * ggml-cpu: lower AMX MMQ optimization level for DL build (cherry picked from commit 74ebd8f9c2ecdd3c3d4acb6501f8ccaf9bbea8e1) * ggml-cpu: scope AMX mmq -O1 to the sapphirerapids DL variant Review feedback (gianni-cor): the -O1 workaround was applied to ggml-cpu/amx/mmq.cpp for every non-MSVC build. The clang-22 -O3 blow-up only affects the AMX TU of the sapphirerapids variant under GGML_CPU_ALL_VARIANTS in the DL build, so guard it on exactly that path (NOT MSVC AND GGML_BACKEND_DL AND GGML_CPU_ALL_VARIANTS AND tag_name STREQUAL "sapphirerapids"). Every other build keeps -O3 — no unnecessary AMX de-optimization. (cherry picked from commit 851df87c06064cff24ffa43515d0f879e9852a2e) * ggml-cpu: add NOSVE to linux-arm64 armv9.2_1 variant Review feedback (gianni-cor): dropping SVE/SVE2 from the feature list is not enough for armv9.2_1 — ARMv9-A mandates SVE2, so -march=armv9.2-a+sme still exposes SVE/SVE2 code paths (kernels gated on __ARM_FEATURE_SVE), leaving the numerically-broken SVE variant reachable. Add explicit NOSVE (processed as +nosve, mirroring the apple_m4 NOSVE+SME variant) so SVE is actually stripped while SME is kept. armv8.6_1 is unaffected — ARMv8 does not imply SVE. (cherry picked from commit 678fc8986af584ac690ff3fbca7b2a929c37c586) * ggml-cpu: scope AMX mmq -O1 to the sapphirerapids target via genex Follow-up to f65920d5: set_source_files_properties COMPILE_OPTIONS is directory-scoped, so guarding the call on tag_name did not actually limit the flag — once set, -O1 applied to mmq.cpp across every variant library built in this directory, not just sapphirerapids. Gate on the consuming target with a generator expression instead ($<$<STREQUAL:$<TARGET_PROPERTY:NAME>, ggml-cpu-sapphirerapids>:-O1>), so only the ggml-cpu-sapphirerapids variant compiles mmq.cpp at -O1 while every other variant keeps -O3. (cherry picked from commit d630c747d10fef365c9484bb64b51d2ec11e5382)…
gianni-cor
pushed a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 6, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block.
gianni-cor
pushed a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 6, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd610 "vulkan/cpu: Support f16 as SET_ROWS src" (ggml-org#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green.
gagallo7
pushed a commit
to gagallo7/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 10, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block.
gagallo7
pushed a commit
to gagallo7/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 10, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd610 "vulkan/cpu: Support f16 as SET_ROWS src" (ggml-org#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green. b10297 rebase: - Merge the coopmat1/coopmat2 FA shmem-support helpers with upstream's new k_type/v_type parameters and iq_shmem accounting: the QJL projection/correction scratch is added on top of upstream's per-type shmem totals. - Keep the fork-wide scalar-FA MMQ disable and the fork's per-K-type FA allow-list in supports_op; upstream's relaxed fa_kv_ok list (BF16 KV, unconditional Q4_1/Q5_0/Q5_1/IQ4_NL) is intentionally not adopted yet (follow-up).
zommiommy
pushed a commit
to zommiommy/llama.cpp
that referenced
this pull request
Aug 18, 2026
This trims down some of the shader variant explosion and reduces binary size.
gagallo7
pushed a commit
to gagallo7/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 21, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block.
gagallo7
pushed a commit
to gagallo7/qvac-fabric-llm.cpp
that referenced
this pull request
Aug 21, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd610 "vulkan/cpu: Support f16 as SET_ROWS src" (ggml-org#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green. b10297 rebase: - Merge the coopmat1/coopmat2 FA shmem-support helpers with upstream's new k_type/v_type parameters and iq_shmem accounting: the QJL projection/correction scratch is added on top of upstream's per-type shmem totals. - Keep the fork-wide scalar-FA MMQ disable and the fork's per-K-type FA allow-list in supports_op; upstream's relaxed fa_kv_ok list (BF16 KV, unconditional Q4_1/Q5_0/Q5_1/IQ4_NL) is intentionally not adopted yet (follow-up).
korcan-h
added a commit
to korcan-h/qvac-fabric-llm.cpp
that referenced
this pull request
Sep 1, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block. (cherry picked from commit 11476ac)
korcan-h
pushed a commit
to korcan-h/qvac-fabric-llm.cpp
that referenced
this pull request
Sep 1, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd610 "vulkan/cpu: Support f16 as SET_ROWS src" (ggml-org#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green. b10297 rebase: - Merge the coopmat1/coopmat2 FA shmem-support helpers with upstream's new k_type/v_type parameters and iq_shmem accounting: the QJL projection/correction scratch is added on top of upstream's per-type shmem totals. - Keep the fork-wide scalar-FA MMQ disable and the fork's per-K-type FA allow-list in supports_op; upstream's relaxed fa_kv_ok list (BF16 KV, unconditional Q4_1/Q5_0/Q5_1/IQ4_NL) is intentionally not adopted yet (follow-up). (cherry picked from commit 3de593b)
JenySadadia
pushed a commit
to JenySadadia/qvac-fabric-llm.cpp
that referenced
this pull request
Sep 7, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block. (cherry picked from commit 11476ac) (cherry picked from commit 9da7890)
JenySadadia
pushed a commit
to JenySadadia/qvac-fabric-llm.cpp
that referenced
this pull request
Sep 7, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd610 "vulkan/cpu: Support f16 as SET_ROWS src" (ggml-org#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green. b10297 rebase: - Merge the coopmat1/coopmat2 FA shmem-support helpers with upstream's new k_type/v_type parameters and iq_shmem accounting: the QJL projection/correction scratch is added on top of upstream's per-type shmem totals. - Keep the fork-wide scalar-FA MMQ disable and the fork's per-K-type FA allow-list in supports_op; upstream's relaxed fa_kv_ok list (BF16 KV, unconditional Q4_1/Q5_0/Q5_1/IQ4_NL) is intentionally not adopted yet (follow-up). (cherry picked from commit 3de593b) (cherry picked from commit 5f7ead8)
zbrad
pushed a commit
to zbrad/llama.cpp
that referenced
this pull request
Sep 10, 2026
This trims down some of the shader variant explosion and reduces binary size.
gianni-cor
pushed a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Oct 1, 2026
The Mali G715 had issues with the non-coopmat f32 input types path where it was causing NaN loss values, this has been fixed with a workaround to force an explicit (de)quant pass to do the matmulti in f16 but is not ideal. Mali does support f32xf32xf32 16x16x16 coopmats, this commit adds a new cm1 path to generate and use cm1 matmul shader for f32 input. Not requiring any conversion pass. --- b9840 rebase (fixup folded in): The cm1 f32 path was originally written against b9692, where aligned pipelines loaded a separate _aligned SPIR-V -- the pipeline-creation counterpart to the shader-gen changes in this commit. - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) made alignment a runtime spec constant chosen by ggml_vk_mul_mm_spec, so aligned and unaligned pipelines now share one shader. Rebased onto b9840, the CREATE_MM_FP32 macro still referenced the _aligned_cm1_fp32 symbols (no longer emitted after the shader-gen fixup) and passed a bare warptile spec. - Fold this in so both pipelines select alignment via ggml_vk_mul_mm_spec(WARPTILE, aligned) and reuse the single cm1_fp32 shader, matching upstream's _128 block. (cherry picked from commit 11476ac) (cherry picked from commit 9da7890) (cherry picked from commit 6fec346)
gianni-cor
pushed a commit
to tetherto/qvac-fabric-llm.cpp
that referenced
this pull request
Oct 1, 2026
Vulkan backend for the TurboQuant (TBQ3_0/TBQ4_0) and PolarQuant (PQ3_0/PQ4_0) KV-cache quant formats (block=128 and block=64), ported onto the b9518 flash-attention architecture. b9518 already carries a per-K/V-type quantized-KV flash-attention design (the FaTypeK/FaTypeV runtime spec-constant model), which differs from the b9341-era TurboQuant import's compile-time per-type model. Rather than revert b9518's FA, this integrates both: - Generic FA (F16/BF16/Q4_0/Q4_1/Q5_0/Q5_1/Q8_0/Q1_0) keeps b9518's runtime FaTypeK/V decode unchanged. The shared FA shaders gate it behind LLAMA_UPSTREAM_FA_MIXED_TYPES, which vulkan-shaders-gen.cpp defines for the generic variants. - TBQ/PQ ride on dedicated per-type compile-time SPIR-V modules (flash_attn_f32_f16_<k>[_<v>][_cm1|_cm2]) that include turbo-quant/flash_attn_base.glsl for the bit-packed codebook decode and the QJL (Johnson-Lindenstrauss) Stage-2 correction. ggml-vulkan's three FA pipeline loops select these per (k_type, v_type) via CREATE_FA_TBQ. The QJL correction is applied to the Q*K^T score for TurboQuant K only (matching the CPU vec_dot reference); PolarQuant and all V decode are Stage-1 (codebook x scale). Same-type and mixed K/V (TBQ/PQ on K; PQ, Q4_0, Q8_0 or F16 on V) are supported on scalar, coopmat1 and coopmat2. Also includes: TBQ/PQ mul_mat (mul_mat_vec FHT/QJL epilogue + standalone mul_mm QJL correction pass), dequant, copy_to/from_quant + set_rows (incl. cooperative TBQ_COOP and norm-correction variants), the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ, llama-bench cache-type parsing, the test-backend-ops TBQ/PQ MUL_MAT + FLASH_ATTN_EXT sweeps, and the test-turboquant.sh / test-copy-tbq-subgroups / kv-cache perf+perp harness. The scalar FlashAttn MMQ (_int8) path is disabled fork-wide: the import reworked the scalar shader's MMQ path into the compile-time turbo-quant decode, so the generic _int8 module no longer compiles; the non-MMQ FA path covers the integer-dot quant types on every backend. Validated on RTX 4090 (Vulkan, coopmat2): test-backend-ops MUL_MAT and FLASH_ATTN_EXT for tbq*/pq* all pass against the CPU reference at the 5e-4 NMSE threshold. Co-authored-by: Marcus Edel <[email protected]> Co-authored-by: gianni-cor <[email protected]> Co-authored-by: Guilherme Gallo <[email protected]> Signed-off-by: Marcus Edel <[email protected]> (cherry picked from commit beddffc) --- b9692 rebase: - Gate the TBQ/PQ _64 shader emission on !dot2: on the dot2 passes this block re-emits the non-dot2 names and double-defines every _64 shader. b9840 rebase: - upstream 0eb874d ("vulkan: make mul_mm ALIGNED a spec constant", ggml-org#24689, lands at b9771) collapsed those into a single shader per type -- alignment is now a runtime ALIGNED spec constant, and mul_mm.comp gained a B_TYPE_SCALAR / B_SCALAR binding so the one shader can do both the vectorized (aligned) and scalar (unaligned) B loads. Rebased onto b9840, the TurboQuant block still emits the old _f32/_f32_aligned/_f16/_f16_aligned variants with load_vec_a_unaligned, which no longer matches the shared mul_mm.comp. - Fold this in so each TQ/PQ type emits one shader carrying B_TYPE_SCALAR and drops the _aligned variant, exactly like upstream's _128 block. b9899 rebase: - upstream wrapped the SET_ROWS accepted-type switch in ggml_backend_vk_device_supports_op in an outer `if (op->src[0]->type == GGML_TYPE_F32)` guard and keeps a direct `return true;` for the standard quant types. Re-slot the TBQ/PQ pipeline-null gating cases into the new switch and drop the old `break;` + trailing-`return true;` fallthrough, which no longer fits. b9952 rebase: - Collapse the four `SET_ROWS_TQ*` pipeline macros into one parameterized macro and replace the 4-way TBQ/PQ-64 type test with `ggml_is_tbq_or_pq_64()`; skip emitting `fa_mixed` shaders where K/V share a type (already covered by the single-type pipelines) - dedup the kv-quant perf/perp test scripts into the shared `kv_quant_common.sh` / `kv_quant_agg_common.py`. - Compute the TBQ QJL correction-pass gate and its B-source choice once (`tbq_qjl_pass` / `qjl_use_f32_b_from_src1` / `qjl_b_is_f16`) and share them between the descriptor pre-request and the dispatch, including the new `!do_tiling` condition. Keeps the two sites in lock-step so they cannot disagree - Leave the dispatched pipeline without a descriptor set (which would crash with a VK_NULL_HANDLE layout). b10069 rebase: - Upstream 7cbd610 "vulkan/cpu: Support f16 as SET_ROWS src" (ggml-org#25432, in b9952..b10069) rehomed the Vulkan set_rows pipelines into a 2D [src][dst] table and made f16-source SET_ROWS reachable; the initial replay slotted the TBQ/PQ pipelines into the f32 slot only, so every f16-source SET_ROWS into a TBQ/PQ tensor fell back to CPU. Generate f16_-prefixed shader variants, register them at source slot 1, and cover f16->TBQ/PQ set_rows in test-backend-ops with a 1e-6 NMSE bound. - Post-rebase review: supports_op gated TBQ/PQ SET_ROWS on the pipeline pointers being non-null; replace with an explicit subgroup_basic/arithmetic (+ ballot for TBQ) feature predicate. - Post-rebase review: on drivers without subgroup size control the TBQ copy pipelines silently kept the shader's SG_SIZE=32 default; specialize SG_SIZE to the device's native subgroup size instead. - Post-rebase review: test-copy-tbq-subgroups spawned its probe/child processes with POSIX-only 'VAR=val cmd' env syntax; add a _WIN32 branch using cmd.exe 'set "VAR=..." &&' so the harness runs on Windows. - Route both legs through run_fa_leg(), which additionally requires that the leg emitted case lines. A zero-pass count is deliberately still accepted: for the fp16-disabled PQ leg, supports_op rejecting the op so the scheduler falls back to CPU is one of the two outcomes that leg's own comment names as correct. - Verified on the 7900 XTX: the f16 leg selects 8 cases and the fp16-disabled PQ leg 24, where previously the latter was 0/0-green. b10297 rebase: - Merge the coopmat1/coopmat2 FA shmem-support helpers with upstream's new k_type/v_type parameters and iq_shmem accounting: the QJL projection/correction scratch is added on top of upstream's per-type shmem totals. - Keep the fork-wide scalar-FA MMQ disable and the fork's per-K-type FA allow-list in supports_op; upstream's relaxed fa_kv_ok list (BF16 KV, unconditional Q4_1/Q5_0/Q5_1/IQ4_NL) is intentionally not adopted yet (follow-up). (cherry picked from commit 3de593b) (cherry picked from commit 5f7ead8) b10796 squash: folded 2 commits. - squash! ggml-vulkan: TurboQuant vulkan backend and shader integration - squash! ggml-vulkan: TurboQuant vulkan backend and shader integration --- From 380b669: ARM-gate the TQ1/TQ2 mul_mm f32acc forcing: only Mali needs it (lora NaN fix), and forced f32acc runs at half the f16acc tensor rate on NVIDIA GeForce. --- Originally squash! ggml-vulkan: Fix NaN outputs on Mali; retargeted here because the TurboQuant integration rewrote the coopmat2 branch this change patches, so it cannot sit adjacent to (or fold into) the Mali NaN commit without conflicts. --- From 18ac6f3: metal: also reject TBQ/PQ in the MUL_MAT supports_op The commit message promises "the Metal MUL_MAT/MUL_MAT_ID reject for TBQ/PQ", but only MUL_MAT_ID got it. Metal has no TBQ/PQ mul_mv/mul_mm kernels, so the standalone-MUL_MAT sweep added in the same commit aborts in the pipeline lookup on Metal. That is the exact failure mode the sweep's comment documents for NV coopmat2. Squashed-with: 380b669 Squashed-with: 18ac6f3 Assisted-by: Claude Opus 5 (cherry picked from commit 8d7d636)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This trims down some of the shader variant explosion and reduces binary size.
Requirements