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

Method place_experts

engine/src/split/src/model.cpp:1587–1605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1585} // namespace
1586
1587void Model::place_experts() {
1588 choose_residency();
1589 each_card(cards, [&](CardW& c) {
1590 if (c.ec_host_gu.size() != (size_t) NL * NEXP) throw std::runtime_error("fnx: placing experts needs their host copies");
1591 const size_t before = c.bytes;
1592 Up up{c, nullptr, &c.expert_mem};
1593 if (resident.empty()) { // every expert in VRAM: each layer's host copy is one block
1594 for (int l = 0; l < NL; ++l) {
1595 LayerW& L = c.L[(size_t) l];
1596 L.gu_e.p = up.put<uint8_t>(c.ec_host_gu[(size_t) l * NEXP], (size_t) NEXP * L.gu_e_stride);
1597 L.down_e.p = up.put<uint8_t>(c.ec_host_dn[(size_t) l * NEXP], (size_t) NEXP * L.down_e_stride);
1598 }
1599 } else {
1600 const std::vector<const char*> hgu = c.ec_host_gu, hdn = c.ec_host_dn;
1601 up.expert_cache(resident, hgu, hdn, arena ? &score : nullptr);
1602 }
1603 c.expert_bytes = c.bytes - before;
1604 });
1605}
1606
1607void Model::free_experts() {
1608 each_card(cards, [&](CardW& c) {

Callers

nothing calls this directly

Calls 4

each_cardFunction · 0.85
expert_cacheMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected