| 1430 | } |
| 1431 | |
| 1432 | bool lm_head(const WeightTable& tables, const ModelGeometry& g, const BlockBuffers& bb, |
| 1433 | float* logits, void* stream, std::string& err) { |
| 1434 | const WeightRef* wo = tables.find("output.weight"); |
| 1435 | if (!wo) { err = "output.weight is missing"; return false; } |
| 1436 | strata::kernels::SForm form; |
| 1437 | Planes planes; |
| 1438 | if (!sform_of(*wo, form, "output.weight", err) || |
| 1439 | !plane_ptrs(*wo, "output.weight", planes, err)) return false; |
| 1440 | if (g.n_embd % Q8K_ELEMS_PER_BLOCK != 0) { |
| 1441 | err = "lm_head: n_embd is not a multiple of 256"; |
| 1442 | return false; |
| 1443 | } |
| 1444 | if (!lm_head_mix(tables, g, bb, stream, err)) return false; |
| 1445 | strata::kernels::quantize_q8_K(bb.mixed, bb.head_q8k, g.n_embd, stream); |
| 1446 | return gemv_quantized(*wo, planes, form, bb.head_q8k, bb.head_q8k, logits, |
| 1447 | g.n_embd, wo->ne1, "output.weight", stream, err); |
| 1448 | } |
| 1449 | // ================================ ONE WHOLE BLOCK ================================ |
| 1450 | uint64_t block_buffers_bytes(const ModelGeometry& g) { const strata::kernels::GrShapes s{g.n_embd, g.hc, g.hc_lr}; uint64_t n = 0; n += (uint64_t) g.hc * g.n_embd * 4; |
| 1451 | // R |
no test coverage detected