cpu experts: AVX2 Q8_K activation quantizer for the native i-quant layers (#851)
Byte-identical to ggml's quantize_row_q8_K (q8k_quant_parity checks it, including the avx-only run). STRATA_NO_Q8K_AVX2=1 keeps ggml's.
This commit is contained in:
1 parent
6f21c9d912
commit
5208b320dd
5 files changed
+236
No files matched your search
@@ -68,11 +68,24 @@ bool native_fmt(int gu_type, int d_type, int64_t n_embd, int64_t n_ff, NativeFmt
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Q8_K (the activations of every i-quant row): ggml-cpu's x86 quantizer is the scalar reference, ~3 us per token
|
||||
// and layer on the host before the pool can start; q8k_quant_avx2 writes the same bytes. cpu_avx2_ok() too:
|
||||
// iq_avx2.cpp is compiled for AVX2 (an AVX-only CPU, or STRATA_FORCE_ISA=avx, keeps ggml's). STRATA_NO_Q8K_AVX2=1:
|
||||
// ggml's on any CPU.
|
||||
bool q8k_avx2(int type) {
|
||||
static const bool on = cpu_avx2_ok() && std::getenv("STRATA_NO_Q8K_AVX2") == nullptr;
|
||||
return on && type == (int) GGML_TYPE_Q8_K;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void native_quant_act(const NativeFmt& f, const float* x, void* dst) {
|
||||
if (q8k_avx2(f.gu_act)) { q8k_quant_avx2(x, dst, f.n_embd); return; }
|
||||
traits(f.gu_act)->from_float(x, dst, f.n_embd);
|
||||
}
|
||||
|
||||
void native_quant_h(const NativeFmt& f, const float* h, void* dst) {
|
||||
if (q8k_avx2(f.d_act)) { q8k_quant_avx2(h, dst, f.n_ff); return; }
|
||||
traits(f.d_act)->from_float(h, dst, f.n_ff);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user