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

Method dense

engine/src/split/src/model.cpp:437–456  ·  view source on GitHub ↗

a dense matrix for q8s_gemv: Q8_0 slices move to the split layout (other types stay as they are)

Source from the content-addressed store, hash-verified

435 }
436 // a dense matrix for q8s_gemv: Q8_0 slices move to the split layout (other types stay as they are)
437 DW dense(DW w) {
438 if (w.type != T_Q8_0) return w;
439 const size_t bytes = (size_t) w.n_out * w.row_bytes, nblk = bytes / 34;
440 std::vector<uint8_t> h(bytes);
441 ck(cudaMemcpy(h.data(), w.p, bytes, cudaMemcpyDeviceToHost), "dense: download");
442 if (store) store->free_dev(c.dev, w.p, bytes); // the upload just before: its room is used again
443 else ck(cudaFree(w.p), "dense: free");
444 if (track) track->erase(std::remove(track->begin(), track->end(), (void*) w.p), track->end()); // not freed twice
445 c.bytes -= bytes;
446 std::vector<int8_t> q(nblk * 32);
447 std::vector<uint16_t> d(nblk);
448 for (size_t b = 0; b < nblk; ++b) {
449 std::memcpy(&d[b], &h[b * 34], 2);
450 std::memcpy(&q[b * 32], &h[b * 34 + 2], 32);
451 }
452 w.p = nullptr;
453 w.s.q = put<int8_t>(q.data(), q.size());
454 w.s.d = put<uint16_t>(d.data(), d.size() * 2);
455 return w;
456 }
457 // bf16 values [n] as the split int8 layout (per 32 values: d = amax / 127, ggml's rounding)
458 Q8S q8split_bf16(const uint16_t* v, size_t n) {
459 std::vector<int8_t> q(n);

Callers 4

load_layers_27bFunction · 0.80
load_cardFunction · 0.80
load_mtp_cardFunction · 0.80
MtpMethod · 0.80

Calls 11

memcpyFunction · 0.85
free_devMethod · 0.80
eraseMethod · 0.80
ckFunction · 0.70
cudaMemcpyFunction · 0.50
cudaFreeFunction · 0.50
removeFunction · 0.50
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected