* ggml: add tensor scaling (per-tensor, per-channel, per-expert, per-expert-per-channel) support
* add meta backend scale split
* add optional activation scales to mul_mat and mul_mat_id tensors
* handle bitnet scales too, disable in backends
* Don't treat single expert as per-channel-per-expert
* Temp workaround for moe-cache with scaled data-types
* Also apply scales in CPU backend 's tiled mul_mat
* Handle strided views on scales
* Make *scale tensors use existing GGML_OP_MUL buffer probe
* Make scale tensors required for ggml_type with needs_scale=true
* Make needs_scale=true for FP8
* Use ggml_need_scale in code-base
* Transform companion FP8 scales
* Add comment explaining intended use of activation scales
* Fix pre-existing view-handling failure in meta backend
eae135bd4 exposed an issue with single-ton dimension ambiguitiy + views
in meta backend, see https://github.com/ggml-org/llama.cpp/actions/runs/39765669007/job/119780422102
* Enforce scale side-cars for scaled data-types during conversion
* tq quants also need scales
* llama: use map for scale tensors instead of manual handling
Assisted-by: Codex
* Fix conversion edge-case for FP8 block-scales
* Revert "tq quants also need scales"
This reverts commit 5920e55b0170bf376318935dd814a47823e5efb3.
* Disable dedicated kernels also for kleidiai in requant test
We want to test requant errors so we should be using the same kernels
to avoid a cofounder
* Add separate tests for scaled and unscaled DSV2
* Also remove IQ from needs_scale related tests/behvaior
* Wire activation scales and disallow broadcasting over K
* Adjust build_* in lfm3.cpp
* Avoid internal includes in test-llama-arch for moe scales
see https://github.com/ggml-org/llama.cpp/pull/27512#discussion_r4410518158
* djust build_* in limite.c
pp as well
* Adjust build_* for mistral 4
* More build_*_ffn changes
* fp8 : fix integration after rebase
* Another round of model scale map fixes
* Only read scales for valid experts
* handle input scales through cache similar to weight scales
* check supports_op in cache slots
* use is_scalar/is_vector functions
* fix Windows CI cleanup failure
* exclude BLOOM, JAIS and REFACT from sm_tensor due to Alibi not handled in TP correctly yet
* increase error threshold for hunyuan and maincoder context shifting
* adapt CUDA fusion code to scale change
* fix MoE cache too small error
* increase error threshold for hrm_text
* replace missing model matmul cases
* clean up unused CUDA code
* more missed matmuls
* handle per-tensor (scalar) scales in moe cache
* place scales with their weights
* increase error threshold for moe scales check
* restore CUDA cublaslt scale path
* convert model matmuls, handle weight views, add tests
* fix comments and error style
* cuda: use global scale functions
* fix kleidiai
* cuda: honour f32 prec in cublaslt call
* update Metal fusion count
* fix gemma4 scale issue
* don't remove trivial scale if required
* adapt new models changes
* adapt conversion qwen4exp changes and tests
* improve error message when scale unsupported
* address feedback
* adapt new models
* metal : apply the weight scale of MUL_MAT and MUL_MAT_ID
* ggml : avoid `ggml_type_traits` ABI change + TODOs
* metal : drop the comments of the weight scale epilogue
* undo moe-cache-specific changes
* tests : update the Metal fusion baseline
* handle scale in repack and kleidiai, fix scale buffer placement in loader
* llama : fix weight scale lookup, validate MUL_MAT_ID scales
- only look up a weight scale for .weight tensors (k_scale/v_scale
tensors were checked against the weight scale and failed to load)
- check MUL_MAT_ID weight scale shapes at load time instead of asserting
- llama-quantize: error out on nvfp4/f8_e4m3 targets (no scale computed)
- llama-quant: NULL -> nullptr
* clean up unnecessary tests
---------
Co-authored-by: Oliver Simons <osimons@nvidia.com>
Co-authored-by: Pascal <admin@serveurperso.com>
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>