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

Method init_deferred_commit

engine/src/core/verify.cpp:5558–5591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5556// ---- STRATA_PIPED_MTP: commits after the verdict (see the header)
5557
5558bool Verifier::init_deferred_commit(int rows, std::string& err) {
5559 const OnDevice on_device(device_);
5560 if (slots_.empty()) { err = "verify: init_deferred_commit before init_slots"; return false; }
5561 if (rows < 1) { err = "verify: init_deferred_commit needs at least one row"; return false; }
5562 const ModelGeometry& g = *g_;
5563 const uint64_t R = (uint64_t) rows, C = (uint64_t) g.ssm_conv_channels, HV = (uint64_t) g.ssm_v_heads;
5564 const uint64_t ID = (uint64_t) g.idx_key_dim;
5565 const uint64_t nG = (uint64_t) std::max<int64_t>(g.n_gdn_layers(), 1), nQ = (uint64_t) std::max<int64_t>(g.n_qsa_layers(), 1);
5566 const uint64_t HS = (uint64_t) strata::kernels::NG_HIST * strata::kernels::NG_HC_DIM;
5567 const uint64_t CB = 2 + (uint64_t) max_t_, nS = (uint64_t) slots_.size();
5568 const uint64_t floats[6] = {nG * R * C, nG * R * C, nG * R * HV, nG * R * HV, nQ * R * ID, R * HS};
5569 uint64_t bytes = (nS * CB * 4 + 255) & ~255ull;
5570 for (uint64_t f : floats) bytes += (f * 4 + 255) & ~255ull;
5571 if (cudaMalloc(&dc_arena_, bytes) != cudaSuccess) {
5572 err = "verify: the saved commit rows (" + std::to_string(bytes >> 20) + " MiB) do not fit";
5573 return false;
5574 }
5575 uint8_t* p = (uint8_t*) dc_arena_;
5576 commitd_ = (int32_t*) p;
5577 p += (nS * CB * 4 + 255) & ~255ull;
5578 float** dst[6] = {&dc_qkv_, &dc_h_, &dc_gate_, &dc_beta_, &dc_idx_, &dc_hist_};
5579 for (int i = 0; i < 6; ++i) {
5580 *dst[i] = (float*) p;
5581 p += (floats[i] * 4 + 255) & ~255ull;
5582 }
5583 if (!mapped((size_t) (nS * CB * 4 + 16), (void**) &h_commitd_, (void**) &m_commitd_)) {
5584 err = "verify: the deferred commit staging failed";
5585 return false;
5586 }
5587 dc_rows_ = rows;
5588 std::fprintf(stderr, "strata verify: pipelined batch windows commit after the verdict (layers [%lld, %lld), %d rows, "
5589 "%.1f MiB saved rows)\n", (long long) lb_, (long long) le_, rows, (double) bytes / 1048576.0);
5590 return true;
5591}
5592
5593bool Verifier::capture_deferred(const int* rows, int S, int hbase, std::string& err) {
5594 using namespace strata::kernels;

Callers

nothing calls this directly

Calls 7

n_qsa_layersMethod · 0.80
mappedFunction · 0.70
cudaMallocFunction · 0.50
to_stringFunction · 0.50
emptyMethod · 0.45
n_gdn_layersMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected