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

Method open_sized

engine/src/core/expert_cache.cpp:704–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704bool ExpertCache::open_sized(const std::vector<int64_t>& slot_bytes, int64_t n_layers, int64_t n_expert,
705 std::string& err) {
706 if (slot_bytes.empty()) { err = "ExpertCache: no slots"; return false; }
707 int64_t mx = 0;
708 std::vector<uint64_t> off(slot_bytes.size() + 1, 0);
709 for (size_t i = 0; i < slot_bytes.size(); ++i) {
710 // 256-byte aligned slots, so every blob starts where the kernels' vector loads expect it (and the
711 // STRATA_MMQ_DIRECT guard after each blob, 0 by default)
712 off[i + 1] = off[i] + (uint64_t) slot_stride(slot_bytes[i], guard_req_);
713 mx = slot_bytes[i] > mx ? slot_bytes[i] : mx;
714 }
715 // one allocation of the summed size, through the uniform path's checks: n "slots" of 1 byte
716 if (!open((int64_t) off.back(), n_layers, n_expert, 1, err)) return false;
717 slots_ = (int64_t) slot_bytes.size();
718 live_slots_ = slots_;
719 blob_ = mx;
720 off_ = std::move(off);
721 guard_ = guard_req_;
722#if defined(STRATA_USE_HIP)
723 if (!ensure_blocking_staging((std::size_t) blob_, err)) {
724 close();
725 return false;
726 }
727#endif
728 // #369: each layer's cursor at the bottom of its own range, as open() seeds it - open() above ran on byte-sized
729 // "slots", so its seeds are not slot indices
730 layer_next_.assign((size_t) (n_layers > 0 ? n_layers : 0), 0);
731 for (int64_t l = 0; l < n_layers; ++l) {
732 int64_t lo = 0, hi = 0;
733 layer_slot_range(l, lo, hi);
734 layer_next_[(size_t) l] = (int32_t) lo;
735 }
736 return true;
737}
738
739void ExpertCache::close() {
740#if defined(STRATA_USE_HIP)

Callers 6

openMethod · 0.45
openMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 7

moveFunction · 0.85
assignMethod · 0.80
openFunction · 0.50
closeFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45

Tested by 4

mainFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36