Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3091502d4 | ||
|
|
c2b9b8ea62 |
No files matched your search
@@ -107,12 +107,12 @@ struct KvaConfig {
|
||||
/// everyday one (a continuation, a short prompt) that is not worth a log line.
|
||||
const char* decline(const KvaEngine& e, int64_t pos0, int64_t n, int64_t lb, int64_t le, int64_t n_layers,
|
||||
bool pictures = false, bool taps = false, bool* routine = nullptr,
|
||||
bool unmeasured_shape = false) const {
|
||||
bool unmeasured_shape = false, bool cold_read = false) const {
|
||||
if (routine) *routine = false;
|
||||
if (!on) return "off (STRATA_KVA is not 1)";
|
||||
if (capture) return "capture mode";
|
||||
if (!e.blocked.empty()) return e.blocked.c_str();
|
||||
if (pos0 != 0) {
|
||||
if (pos0 != 0 && !cold_read) {
|
||||
if (routine) *routine = true;
|
||||
return "a continuation read (pos0 != 0)";
|
||||
}
|
||||
|
||||
@@ -220,6 +220,8 @@ public:
|
||||
/// on), i.e. the first position whose final rows are real; 0 when that run approximated nothing. Raised chunk by
|
||||
/// chunk, before on_chunk reports the chunk, so the draft layer can skip the chunk's cells. Reset by every run.
|
||||
int64_t kva_floor() const { return kva_floor_; }
|
||||
/// KVA: a cold prompt read in several batch pieces; the full part length, so the frontier spans the whole part.
|
||||
void set_kva_total(int64_t n) { kva_total_ = n; }
|
||||
/// Grows this stage's (and the later stages') pinned upload slots to what a text chunk of `T` tokens uploads, so
|
||||
/// a run of such chunks allocates no pinned memory (STRATA_PIPED_CONCURRENT: an allocation or free on the read's
|
||||
/// thread takes the driver's lock). Before the run, with nothing of this path in flight. False: a slot could
|
||||
@@ -317,6 +319,7 @@ private:
|
||||
bool single_chunk_ = false; ///< a later stage: the prompt is one chunk (set by the stage before)
|
||||
int64_t stopped_at_ = -1; ///< stop_at_chunk ended the last run after this many tokens (-1: it read all)
|
||||
int64_t kva_floor_ = 0; ///< kva_floor()
|
||||
int64_t kva_total_ = 0; ///< set_kva_total()
|
||||
bool pipe_chunked_ = false; ///< a later stage: the chunks came from a --prefill-pipe plan (set likewise)
|
||||
int64_t force_chunk_ = 0; ///< force_chunk, for the next run (0: none)
|
||||
bool force_single_ = false, force_planned_ = false;
|
||||
|
||||
@@ -2952,7 +2952,7 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
|
||||
bool kva_routine = false;
|
||||
const char* kva_why_not = kva.decline(kva_eng, pos0, n, LB, LE < 0 ? -1 : LE, (int64_t) g.n_layers,
|
||||
embd_rows != nullptr, !tap_layers_.empty(), &kva_routine,
|
||||
g.n_layers != 48 || g.n_expert != 512);
|
||||
g.n_layers != 48 || g.n_expert != 512, kva_total_ > 0);
|
||||
if (kva_why_not == nullptr && (g.n_layers != 48 || g.n_expert != 512)) {
|
||||
// STRATA_KVA_ANY_MODEL=1 (research): allowed on a shape KVA was not measured on, with a warning once
|
||||
static std::atomic<bool> warned{false};
|
||||
@@ -2963,11 +2963,12 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
|
||||
}
|
||||
const bool kva_run = kva_why_not == nullptr;
|
||||
const int64_t kva_split = std::min<int64_t>(std::max<int64_t>(kva.split, 1), g.n_layers);
|
||||
const int64_t kva_frontier = std::max<int64_t>(0, n - kva_suffix);
|
||||
const int64_t kva_total = kva_total_ > 0 ? kva_total_ : n;
|
||||
const int64_t kva_frontier = std::max<int64_t>(0, kva_total - kva_suffix);
|
||||
static KvaTap kva_capture; // process-wide: one cold read at a time, so the per-layer position is enough
|
||||
static KvaTap kva_oracle;
|
||||
int64_t kva_positions = 0, kva_chunks = 0; // what actually took the approximate path (diagnostics)
|
||||
kva_floor_ = 0; // this run's: raised below as chunks are approximated
|
||||
if (kva_total_ <= 0 || pos0 == 0) kva_floor_ = 0; // one cold part keeps its floor across pieces
|
||||
if (kva.capture && kva_capture.f.empty()) kva_capture.open(kva.capture_dir, kva.capture_fp32);
|
||||
if (kva.capture && pos0 == 0 && hand_in_ == nullptr) kva_capture.begin_prompt(); // one prompt per capture
|
||||
if (kva_run && kva.mode == KvaConfig::Mode::Oracle && kva_oracle.f.empty())
|
||||
|
||||
@@ -15243,6 +15243,11 @@ int main(int argc, char** argv) {
|
||||
};
|
||||
auto run = [&](int64_t q, int64_t r) -> bool {
|
||||
if (planned) sp.force_chunk(plan.chunk, plan_single, plan.chunked);
|
||||
if (kva_cold(a0, b0)) {
|
||||
const auto& kc = strata::prefill::kva_config();
|
||||
const int64_t frontier = (b0 - a0) - kc.effective_suffix();
|
||||
if (frontier > 0 && frontier <= sp.chunk()) sp.force_chunk(frontier, false, false);
|
||||
}
|
||||
bool run_ok;
|
||||
if (!co_set.empty() && !co_tried && admit_slot >= 0 && req_imgs.empty()) {
|
||||
co_tried = true;
|
||||
@@ -15656,10 +15661,10 @@ int main(int argc, char** argv) {
|
||||
return v != nullptr ? std::max(0.0, std::atof(v)) : 0.0;
|
||||
}();
|
||||
const bool pr_on = piped && pr_piece > 0;
|
||||
const bool kva_whole = kva_cold(a0, b0);
|
||||
sp.set_kva_total(kva_cold(a0, b0) ? b0 - a0 : 0);
|
||||
auto piece_now = [&]() -> int64_t {
|
||||
return pr_on ? strata::program::piped_read_piece(pr_piece, C)
|
||||
: strata::program::batch_read_piece(o.batch > 0 && !kva_whole, piped, !stages.empty(), batch_on(), C,
|
||||
: strata::program::batch_read_piece(o.batch > 0, piped, !stages.empty(), batch_on(), C,
|
||||
yield_chunks);
|
||||
};
|
||||
// the slots decode through the pipeline for budget_ms, drained before the next read
|
||||
@@ -15917,6 +15922,7 @@ int main(int argc, char** argv) {
|
||||
for (const int64_t to : cuts) {
|
||||
if (to <= at) continue;
|
||||
err.clear();
|
||||
if (!kva_cold(at, to)) sp.set_kva_total(0);
|
||||
const bool win = windows_ok(at, to) && !kva_cold(at, to);
|
||||
if (win && !refill(err)) {
|
||||
std::printf("ERR refilling a lent slot failed: %s\n", err.c_str());
|
||||
|
||||
Reference in new issue
Block a user