expert cache: a slot guard for STRATA_MMQ_DIRECT (set_slot_guard), the sizing sites use slot_stride
ExpertCache gets inline set_slot_guard / slot_guard / slot_stride / slot_room / slot_tail; the 4-argument open_sized declaration is unchanged (the SYCL engine defines it out of line against the same header and ignores the guard). open_sized lays slots out at slot_stride(blob, guard); blob_ stays the largest blob, so fills, verify_slot and the HIP staging read no further. slot_tail works on uniform caches too (through slot_offset). generate.cpp: slot_guard = Prefill::slot_guard_bytes() (mmq::direct_slot_guard(): 256 when STRATA_MMQ_DIRECT is 1 or 2 on a pointer-table build, else 0) for native packs; the seven round-256 slot costs (split-skip-if-fits, split placement, per-layer sum, profile sizing, shrink_to, cache_bytes, stage sizing) use ExpertCache::slot_stride(b, slot_guard), and the primary and stage caches get set_slot_guard before they open. Guard 0: the same arithmetic as before, so the default layout is unchanged byte for byte.
This commit is contained in:
1 parent
86f677b4a9
commit
b82cdb1090
5 files changed
+47
-10
No files matched your search
@@ -119,6 +119,15 @@ public:
|
||||
/// always. CUDA only: a HIP build refuses it at open. The slots past `slots()` after a shrink must hold no
|
||||
/// resident expert and no loan: the CALLER evicts them first (they become CPU misses).
|
||||
void set_segment_bytes(int64_t seg_bytes) { seg_req_ = seg_bytes > 0 ? seg_bytes : 0; }
|
||||
/// STRATA_MMQ_DIRECT: `open_sized` leaves at least `g` bytes of room after each slot's blob (the prompt MMQ
|
||||
/// reads a little past a down matrix when it reads an expert in its slot). Set before opening, like
|
||||
/// `set_segment_bytes`; `close` keeps it. 0 (the default): no guard. The uniform `open` ignores it, and so does
|
||||
/// the SYCL engine's open_sized (its slots then have no guard, and `slot_tail` finds no room).
|
||||
void set_slot_guard(int64_t g) { guard_req_ = g > 0 ? g : 0; }
|
||||
/// The guard the open slots have (0 for uniform slots).
|
||||
int64_t slot_guard() const { return off_.empty() ? 0 : guard_req_; }
|
||||
/// A sized slot's arena bytes: the blob plus the guard, 256-byte aligned.
|
||||
static int64_t slot_stride(int64_t blob, int64_t guard = 0) { return (blob + guard + 255) / 256 * 256; }
|
||||
bool segmented() const { return !segs_.empty(); }
|
||||
int64_t segment_bytes() const { return seg_; }
|
||||
/// Bytes of the arena backed by VRAM now (a whole number of segments; the arena when not segmented).
|
||||
@@ -208,6 +217,14 @@ public:
|
||||
VmmRange* vmm_range() { return vmm_.get(); }
|
||||
/// Byte offset of slot `s` in the arena (s == slots(): the end).
|
||||
uint64_t slot_offset(int64_t s) const { return off_.empty() ? (uint64_t) s * (uint64_t) blob_ : off_[(size_t) s]; }
|
||||
/// The arena bytes of slot `s` (its blob, any slack and the guard).
|
||||
uint64_t slot_room(int32_t s) const { return slot_offset(s + 1) - slot_offset(s); }
|
||||
/// STRATA_MMQ_DIRECT: the address `blob` bytes into slot `s` when the slot has room for `need` more bytes there
|
||||
/// (null otherwise, or for a bad slot). Uniform slots too: their stride is the largest blob.
|
||||
uint8_t* slot_tail(int32_t s, uint64_t blob, uint64_t need) const {
|
||||
if (s < 0 || s >= slots_ || base_ == nullptr) return nullptr;
|
||||
return slot_room(s) >= blob + need ? base_ + slot_offset(s) + blob : nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined(STRATA_USE_HIP)
|
||||
@@ -221,6 +238,7 @@ private:
|
||||
uint8_t* base_ = nullptr;
|
||||
int64_t live_slots_ = 0; ///< #533: slots() - all of them unless shrunk
|
||||
int64_t seg_req_ = 0; ///< #533: the segment size asked for (0: one cudaMalloc)
|
||||
int64_t guard_req_ = 0; ///< STRATA_MMQ_DIRECT: bytes kept after each sized slot's blob (set_slot_guard)
|
||||
int64_t seg_ = 0; ///< #533: the segment size used (a multiple of the driver's granularity)
|
||||
uint64_t reserved_ = 0; ///< #533: the reserved address range's size
|
||||
std::vector<unsigned long long> segs_; ///< #533: each segment's physical handle (0: unmapped)
|
||||
|
||||
@@ -124,6 +124,11 @@ public:
|
||||
/// keeps the ring full. STRATA_RING_BYTES=0: 0.1.39's ring, loan and chunk list.
|
||||
static bool ring_bytes_enabled();
|
||||
|
||||
/// STRATA_MMQ_DIRECT: the guard each sized expert-cache slot keeps after its blob (ExpertCache::set_slot_guard),
|
||||
/// so the prompt MMQ can read a resident expert in its slot. 0 unless STRATA_MMQ_DIRECT is 1 or 2 on a CUDA
|
||||
/// build with the pointer-table MMQ (STRATA_MMQ_TAB).
|
||||
static size_t slot_guard_bytes();
|
||||
|
||||
/// Positions [pos0, pos0 + n) holding `tokens`; `ss.ple_prev` must be the two tokens before pos0 (oldest
|
||||
/// first, -1 for none) and is advanced to the last two of these.
|
||||
bool run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& err);
|
||||
|
||||
Reference in new issue
Block a user