sycl: the draft steps wait for the GPU, not 1024 spins (MTP acceptance 4% -> 62%)
wait_step and the chain wait polled ext_oneapi_empty() through DPCT_CHECK_ERROR, which is always 0, so the loop left after 1024 spins and read draft tokens the GPU had not written (-1). Same migration bug as the cudaStreamQuery fix in verify.cpp, missed in mtp.cpp. IQ3_XXS on the A750: 61 of 99 drafts accepted on the story prompt (the 5070 gets 106 of 166); copy_'s readiness test in verify.cpp had the same flaw. STRATA_DBG_DRAFT=1 prints each window's drafts and the target's tokens.
This commit is contained in:
1 parent
9370ea41f9
commit
76e1cd2eef
3 files changed
+11
-6
No files matched your search
@@ -87,9 +87,9 @@ bool mapped(size_t bytes, void **h, void **d) try {
|
||||
migrated code and was removed or replaced with 0. You may need to check the
|
||||
migrated code.
|
||||
*/
|
||||
if (DPCT_CHECK_ERROR(*h = (void *)sycl::malloc_host(
|
||||
if (DPCT_CHECK_ERROR(*h = strata::host_malloc_polled(
|
||||
bytes, dpct::get_in_order_queue())) !=
|
||||
0) return false;
|
||||
0 || *h == nullptr) return false; // the host polls what the draft steps write: uncached host memory (sycl_queue.hpp)
|
||||
std::memset(*h, 0, bytes);
|
||||
return DPCT_CHECK_ERROR(*d = (void *)*h) == 0;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ MtpDrafter::~MtpDrafter() {
|
||||
if (ev_chain_) dpct::destroy_event(ev_chain_);
|
||||
for (dpct::event_ptr e : ev_step_) if (e) dpct::destroy_event(e);
|
||||
void* hosts[] = {h_tok_, h_step_, h_pos_, h_row_, h_out_, h_prob_, h_force_};
|
||||
for (void *h : hosts) if (h) sycl::free(h, dpct::get_in_order_queue());
|
||||
for (void *h : hosts) if (h) strata::host_free_polled(h, dpct::get_in_order_queue());
|
||||
}
|
||||
|
||||
const float* MtpDrafter::f32(const char* name) const {
|
||||
@@ -1622,7 +1622,7 @@ bool MtpDrafter::draft(int T, const int32_t* tokens, int64_t p, int a, int32_t*
|
||||
_mm_pause();
|
||||
#endif
|
||||
if ((++spins & 1023u) == 0 &&
|
||||
DPCT_CHECK_ERROR(((cs_)->ext_oneapi_empty())) != 1) break;
|
||||
((cs_)->ext_oneapi_empty() ? 0 : 1) != 1) break; /* SYCL port: DPCT_CHECK_ERROR of ext_oneapi_empty() was always 0, so the wait gave up after 1024 spins and read a draft the GPU had not written */
|
||||
}
|
||||
drafts[j] = ((volatile int32_t*) h_out_)[j];
|
||||
if (probs) probs[j] = ((volatile float*) h_prob_)[j];
|
||||
@@ -1673,7 +1673,7 @@ bool MtpDrafter::draft(int T, const int32_t* tokens, int64_t p, int a, int32_t*
|
||||
_mm_pause();
|
||||
#endif
|
||||
if ((++spins & 1023u) == 0 &&
|
||||
DPCT_CHECK_ERROR(((cs_)->ext_oneapi_empty())) != 1) break;
|
||||
((cs_)->ext_oneapi_empty() ? 0 : 1) != 1) break; /* SYCL port: DPCT_CHECK_ERROR of ext_oneapi_empty() was always 0, so the wait gave up after 1024 spins and read a draft the GPU had not written */
|
||||
}
|
||||
}
|
||||
catch (sycl::exception const &exc) {
|
||||
|
||||
@@ -3588,7 +3588,7 @@ bool Verifier::done(std::string &err) try {
|
||||
return false;
|
||||
}
|
||||
if (copy_used_) { // no host function of this window may raise flag B in the next one
|
||||
if (DPCT_CHECK_ERROR(((copy_)->ext_oneapi_empty())) == 1) return false;
|
||||
if (((copy_)->ext_oneapi_empty() ? 0 : 1) == 1) return false;
|
||||
copy_used_ = false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -12159,6 +12159,11 @@ int main(int argc, char **argv) try {
|
||||
}
|
||||
int a = 0;
|
||||
while (a < T - 1 && window[(size_t) a + 1] == outv[(size_t) a]) ++a;
|
||||
if (std::getenv("STRATA_DBG_DRAFT") != nullptr) { // the window the drafter built and what the target said
|
||||
std::fprintf(stderr, "draftdbg: window"); for (int i = 0; i < T; ++i) std::fprintf(stderr, " %d", (int) window[(size_t) i]);
|
||||
std::fprintf(stderr, " | target"); for (int i = 0; i < T; ++i) std::fprintf(stderr, " %d", (int) outv[(size_t) i]);
|
||||
std::fprintf(stderr, " | accepted %d\n", a);
|
||||
}
|
||||
if (first_window) {
|
||||
first_window = false;
|
||||
ttft_ms = std::chrono::duration<double, std::milli>(Clock::now() - t_start).count();
|
||||
|
||||
Reference in new issue
Block a user