MCPcopy Create free account
hub / github.com/Niko1221/Strata / lm_head

Function lm_head

engine/src/core/layer.cpp:1432–1448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1430}
1431
1432bool 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 ================================
1450uint64_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

Callers 1

verify.cppFile · 0.70

Calls 6

sform_ofFunction · 0.70
plane_ptrsFunction · 0.70
lm_head_mixFunction · 0.70
gemv_quantizedFunction · 0.70
quantize_q8_KFunction · 0.50
findMethod · 0.45

Tested by

no test coverage detected