| 1585 | } // namespace |
| 1586 | |
| 1587 | void 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 | |
| 1607 | void Model::free_experts() { |
| 1608 | each_card(cards, [&](CardW& c) { |
nothing calls this directly
no test coverage detected