Merge perf-PR group batch (f-145-pp-batch)
This commit is contained in:
commit
e8b1edbcb7
25 files changed
+2105
-130
No files matched your search
+41
-8
@@ -1372,6 +1372,46 @@ bool MtpDrafter::prepare_prefill(std::string& err) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// STRATA_MTP_PREFILL_SYNC: the prompt pass's per-group loop (see MtpDrafter::prefill); HIP's default
|
||||
static bool prefill_per_group_sync() {
|
||||
static const bool v = [] {
|
||||
if (const char* e = std::getenv("STRATA_MTP_PREFILL_SYNC")) return std::atoi(e) != 0;
|
||||
#if defined(STRATA_USE_HIP)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}();
|
||||
return v;
|
||||
}
|
||||
|
||||
bool MtpDrafter::reserve_prefill(int64_t n, std::string& err) {
|
||||
const OnDevice on_device(device_);
|
||||
if (prefill_per_group_sync()) {
|
||||
for (int T = 1; T <= max_t_; ++T)
|
||||
if (!capture_prefill(T, err)) return false;
|
||||
return true;
|
||||
}
|
||||
if (!prepare_prefill(err)) return false;
|
||||
const int64_t per_row = 1 + 4 + g_->n_head;
|
||||
if (n <= 0) return true;
|
||||
// the records' pinned upload slots too (#1996's ring grows a slot at its first larger upload: a pinned free and
|
||||
// allocation, which take the driver's lock)
|
||||
if (!pf_ring_.reserve((size_t) (n * per_row) * sizeof(int32_t)))
|
||||
std::fprintf(stderr, "strata mtp: the prompt records' pinned upload slots could not be reserved (they grow at "
|
||||
"first use)\n");
|
||||
if (pf_cap_ >= n * per_row) return true;
|
||||
if (pf_dev_) cudaFree(pf_dev_);
|
||||
pf_dev_ = nullptr;
|
||||
pf_cap_ = 0;
|
||||
if (cudaMalloc((void**) &pf_dev_, (size_t) (n * per_row) * sizeof(int32_t)) != cudaSuccess) {
|
||||
err = "mtp prefill: the input records do not fit";
|
||||
return false;
|
||||
}
|
||||
pf_cap_ = n * per_row;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MtpDrafter::prefill(const float* R_rows, const int32_t* next_tokens, int64_t n, int64_t cell0, std::string& err,
|
||||
bool sync) {
|
||||
#if defined(STRATA_GPU_METAL)
|
||||
@@ -1393,14 +1433,7 @@ bool MtpDrafter::prefill(const float* R_rows, const int32_t* next_tokens, int64_
|
||||
// in hipGraphLaunch or the final sync until the watchdog ends the engine. R9700, full IQ3_XXS, --kv-resident
|
||||
// 32768, mixed load (chats, 32K and 7K prompts, deep follow-ups): E-4 hung in the first round on 2 of 2 tries,
|
||||
// the old loop ran 30 of 30 rounds clean, prompt speed unchanged.
|
||||
static const bool per_group_sync = [] {
|
||||
if (const char* v = std::getenv("STRATA_MTP_PREFILL_SYNC")) return std::atoi(v) != 0;
|
||||
#if defined(STRATA_USE_HIP)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}();
|
||||
const bool per_group_sync = prefill_per_group_sync();
|
||||
const int64_t NHp = g_->n_head, per_row = 1 + 4 + NHp;
|
||||
if (!per_group_sync && n > 0) {
|
||||
if (pf_cap_ < n * per_row) {
|
||||
|
||||
Reference in new issue
Block a user