| 1660 | } |
| 1661 | |
| 1662 | bool FileExpertSource::pin_cache_complement( |
| 1663 | const ExpertCache &cache, std::string &err, bool pin, |
| 1664 | const std::vector<std::pair<int32_t, int32_t>> &additional_gpu_pairs, |
| 1665 | int64_t lend_from_slot, uint64_t headroom_bytes, uint64_t budget_bytes, |
| 1666 | const std::vector<std::pair<int32_t, int32_t>> *rank) try { |
| 1667 | err.clear(); |
| 1668 | const auto pin_t0 = std::chrono::steady_clock::now(); |
| 1669 | if (base_ == nullptr) { err = "FileExpertSource: open the mapped experts before pinning a complement"; return false; } |
| 1670 | if (complement_ready_) { err = "FileExpertSource: the cache complement is already pinned"; return false; } |
| 1671 | if (!cache.valid()) { err = "FileExpertSource: the GPU expert cache is not open"; return false; } |
| 1672 | if (cache.fills() != cache.resident()) { |
| 1673 | err = "FileExpertSource: the GPU expert cache is not fully filled"; |
| 1674 | return false; |
| 1675 | } |
| 1676 | const dpct::err0 sync = |
| 1677 | DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw()); |
| 1678 | /* |
| 1679 | DPCT1000: Error handling if-stmt was detected but could not be |
| 1680 | rewritten. |
| 1681 | */ |
| 1682 | if (sync != 0) { |
| 1683 | /* |
| 1684 | DPCT1009: SYCL reports errors using exceptions and does not use |
| 1685 | error codes. Please replace the "get_error_string_dummy(...)" with a |
| 1686 | real error-handling function. |
| 1687 | */ |
| 1688 | /* |
| 1689 | DPCT1001: The statement could not be removed. |
| 1690 | */ |
| 1691 | err = std::string("FileExpertSource: GPU expert cache is not ready: ") + |
| 1692 | dpct::get_error_string_dummy(sync); |
| 1693 | /* |
| 1694 | DPCT1010: SYCL uses exceptions to report errors and does not use |
| 1695 | the error codes. The cudaGetLastError function call was replaced with 0. |
| 1696 | You need to rewrite this code. |
| 1697 | */ |
| 1698 | (void)0; |
| 1699 | return false; |
| 1700 | } |
| 1701 | |
| 1702 | // The GPU cache's experts, and the bytes each slot's expert takes here (for the lend region below). |
| 1703 | const int64_t n_slots = cache.slots(); |
| 1704 | std::vector<std::pair<int32_t, int32_t>> primary_gpu_pairs; |
| 1705 | std::vector<int32_t> pair_slot; |
| 1706 | std::vector<uint64_t> slot_bytes((size_t) std::max<int64_t>(n_slots, 0), 0); |
| 1707 | primary_gpu_pairs.reserve((size_t) cache.resident()); |
| 1708 | pair_slot.reserve((size_t) cache.resident()); |
| 1709 | for (int64_t layer = 0; layer < n_layers_; ++layer) { |
| 1710 | for (int64_t expert = 0; expert < n_expert_; ++expert) { |
| 1711 | const int32_t slot = cache.slot_of(layer, expert); |
| 1712 | if (slot == kNotResident) continue; |
| 1713 | primary_gpu_pairs.emplace_back((int32_t) layer, (int32_t) expert); |
| 1714 | pair_slot.push_back(slot); |
| 1715 | if (slot >= 0 && slot < n_slots) slot_bytes[(size_t) slot] = layer_blob_bytes_[(size_t) layer]; |
| 1716 | } |
| 1717 | } |
| 1718 | std::vector<uint64_t> offsets; |
| 1719 | uint64_t bytes = 0; |
no test coverage detected