Verify window: 2-4 token dense projections read an interleaved copy of the q8_1 activations (fork F4)
A one-int-a-column interleaved copy of the window's q8_1 blocks lets a warp decode each weight block once and apply it to every token with the single-column dot's own expression (the same *_q8_dot_impl calls), walking the chunks of the exact multi-column layout and adding the four virtual warps' sums in warp order, so every output is bitwise the multi-column kernel's. IQ4_XS, Q4_K, Q5_K and Q6_K projections (and the head) of 2-4 tokens use it; the copy is made from xq_ by one small kernel, so the fused HC-read producer works too. STRATA_MMVQ_IL=0 keeps native_mmvq's kernels. CUDA only (HIP keeps its kernels). mmvq_il_parity checks every case bitwise for rows 1/2/4 and the table; --bench times it. Ported by hand from Eddoursul's fork (738e166, b67a291), with the IQ3_S and Q8_0 parts and the 5-8 column widths left out. Co-authored-by: Eddoursul <git@eddoursul.win>
This commit is contained in:
1 parent
5adacbc4e1
commit
ffac97f74f
7 files changed
+632
-8
No files matched your search
@@ -422,6 +422,7 @@ private:
|
||||
float *ple_ = nullptr, *emb_ = nullptr, *R_ = nullptr, *mixed_ = nullptr, *bo_ = nullptr;
|
||||
float *inj_ = nullptr, *inj2_ = nullptr, *lo_ = nullptr, *rs_ = nullptr, *xn_ = nullptr;
|
||||
uint8_t* xq_ = nullptr; // T columns of q8_1
|
||||
uint8_t* xil_ = nullptr; // fork F4: the interleaved copy of xq_'s 2-4 columns
|
||||
uint8_t* sh_xq_ = nullptr; // T columns of q8_1 for shared expert branch
|
||||
float *qkv_L_ = nullptr, *h_L_ = nullptr, *gate_L_ = nullptr, *beta_L_ = nullptr; // per GDN layer
|
||||
float *z_ = nullptr, *y_ = nullptr, *y_dummy_ = nullptr;
|
||||
|
||||
@@ -134,4 +134,21 @@ void native_mmvq(int ggml_type, const void* weights, const void* x_q8_1, float*
|
||||
bool native_mmvq_pair(int ggml_type, const void* w1, const void* w2, const void* x_q8_1, float* y1, float* y2,
|
||||
int n_in, int n_out, int ncols, void* stream);
|
||||
|
||||
// Fork F4 (Eddoursul): 2..4 columns also INTERLEAVED, so one 16-byte load reads a position of every column: CP = 2 (2
|
||||
// columns) or 4 (3-4), zero-padded; nb = n_in / 32 blocks; int32 bm[nb][8][CP] (block-major), int32 pm[8][nb][CP]
|
||||
// (position-major), float d[nb][CP] (each block's scale as the dots read it, __low2float of ds).
|
||||
constexpr int native_q8_1_il_cp(int ncols) { return ncols <= 2 ? 2 : ncols <= 4 ? 4 : 8; }
|
||||
std::size_t native_q8_1_il_bytes(int n_in, int ncols);
|
||||
// Writes the interleaved copy of 2..4 columns of plain q8_1 blocks (native_quantize_q8_1's, or a fused producer's)
|
||||
// to x_il (native_q8_1_il_bytes): the same values in the same bytes.
|
||||
void native_q8_1_interleave(const void* x_q8_1, void* x_il, int n_in, int ncols, void* stream);
|
||||
// True when native_mmvq_il runs its own kernel for this call (IQ4_XS, Q4_K, Q5_K, Q6_K, 2-4 columns, the exact layout).
|
||||
bool native_mmvq_il_supported(int ggml_type, int ncols, int n_out);
|
||||
// native_mmvq for 2..4 columns whose copy native_q8_1_interleave wrote, bitwise native_mmvq's output: kernels in which a
|
||||
// warp takes 1, 2 or 4 rows and reads the columns from the interleaved copy; native_mmvq (x_q8_1) when not supported.
|
||||
void native_mmvq_il(int ggml_type, const void* weights, const void* x_q8_1, const void* x_il, float* y, int n_in,
|
||||
int n_out, int ncols, void* stream);
|
||||
// Tests and benchmarks: every native_mmvq_il call takes `rows` a warp (0: the table).
|
||||
void native_mmvq_il_tune(int rows);
|
||||
|
||||
} // namespace strata::kernels
|
||||
Reference in new issue
Block a user