One weight row against a quantized activation. sum_j (c_j - 1) d_w xhat_j d_x == d_w * ( d_x*sum(c*xhat) - d_x*sum(xhat) ) split per 32-chunk because `d_x` changes at the chunk boundary while `d_w` does not. The accumulator stays a FLOAT VECTOR for the whole row and is reduced once at the end. Reducing per 64-weight block (two 8-lane horizontal sums: a store plus 16 scalar adds) cost far mor
| 209 | /// 64-weight block (two 8-lane horizontal sums: a store plus 16 scalar adds) cost far more than the dot |
| 210 | /// products themselves - it made the kernel compute-bound at 21 GB/s instead of DRAM-bound at 32. |
| 211 | inline float row_dot(const uint8_t* codes, const uint8_t* scales, const ActQ& a, int nblocks) { |
| 212 | if (kZmm) return row_dot_z(codes, scales, a, nblocks); |
| 213 | __m256 acc = _mm256_setzero_ps(); |
| 214 | // The -sum(xhat) term is a SCALAR: broadcasting it into all 8 lanes and letting hsum_ps add them would |
| 215 | // apply it eight times per block. |
| 216 | float corr = 0.f; |
| 217 | for (int b = 0; b < nblocks; ++b) { |
| 218 | const float d = h2f(scales + 2 * b); |
| 219 | const __m256 slo = _mm256_cvtepi32_ps(block_dot(codes + b * 16, a.q + b * QK)); |
| 220 | const __m256 shi = _mm256_cvtepi32_ps(block_dot(codes + b * 16 + 8, a.q + b * QK + QKA)); |
| 221 | acc = _mm256_fmadd_ps(_mm256_set1_ps(d * a.scale[2 * b]), slo, acc); |
| 222 | acc = _mm256_fmadd_ps(_mm256_set1_ps(d * a.scale[2 * b + 1]), shi, acc); |
| 223 | corr += d * (a.hx[2 * b] + a.hx[2 * b + 1]); |
| 224 | } |
| 225 | return hsum_ps(acc) - corr; |
| 226 | } |
| 227 | |
| 228 | // chunk_dot_oracle and row_dot_oracle (the oracle path's Q2_0 row dot, with its fixed float order) are in expert_oracle_parts.hpp. |
| 229 |
no test coverage detected