diagnostics: STRATA_DUMP_FIRST_LOGITS writes the first generated token's logits
STRATA_DUMP_FIRST_LOGITS=<file>: the logits of the first window's first position (the token the prompt predicts), n_vocab float32, written once per run. Two engine variants run on the same prompt then give a first-token KL divergence: how far a prompt-path change moves the model's distribution, not only whether its top token changed. On a layer split the last stage's verifier writes it.
This commit is contained in:
1 parent
6ac1a2cc5e
commit
aea6e45c64
3 files changed
+20
No files matched your search
@@ -74,6 +74,9 @@ public:
|
||||
/// One window: `tokens[0..T)` at positions pos0.., the pool served per layer; `out[t]` = argmax after token t.
|
||||
/// The PLE rows are gathered here from `ss.ple_prev` and the tokens. Captures the T-token graph on first use.
|
||||
bool run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool, void* user, int32_t* out, std::string& err);
|
||||
/// Diagnostics: row `t` of the last window's head logits (n_vocab floats) to the host. Valid after run().
|
||||
bool copy_logits(int t, float* host) const;
|
||||
int64_t vocab() const { return next_ ? next_->vocab() : n_vocab_; }
|
||||
/// The sampling the verify window's head applies (temperature / top_p / top_k / seed). Set per
|
||||
/// request; greedy by default. The sampling itself runs OUTSIDE the captured graph - its
|
||||
/// parameters would otherwise be baked forever - so this can change between requests freely.
|
||||
|
||||
@@ -1303,4 +1303,11 @@ bool Verifier::commit(int n_keep, std::string& err) {
|
||||
return next_ == nullptr || next_->commit(n_keep, err);
|
||||
}
|
||||
|
||||
bool Verifier::copy_logits(int t, float* host) const {
|
||||
if (next_ != nullptr) return next_->copy_logits(t, host); // a layer split: the head is on the last stage
|
||||
if (head_logits_ == nullptr || host == nullptr || t < 0 || n_vocab_ <= 0) return false;
|
||||
return cudaMemcpy(host, head_logits_ + (size_t) t * (size_t) n_vocab_, (size_t) n_vocab_ * sizeof(float),
|
||||
cudaMemcpyDeviceToHost) == cudaSuccess;
|
||||
}
|
||||
|
||||
} // namespace strata::core
|
||||
@@ -5833,6 +5833,16 @@ int main(int argc, char** argv) {
|
||||
if (first_window) {
|
||||
first_window = false;
|
||||
ttft_ms = std::chrono::duration<double, std::milli>(Clock::now() - t_start).count();
|
||||
// Diagnostics: the first window runs the prompt's last token over the state the prompt path left
|
||||
// (keys, values, recurrent state), so its logits carry whatever that path did. A native pack never
|
||||
// runs the per-token loop --dump-logits reads; this is where prompt paths can be compared by output.
|
||||
if (const char* fl = std::getenv("STRATA_DUMP_FIRST_LOGITS")) {
|
||||
std::vector<float> row((size_t) ver.vocab());
|
||||
std::FILE* f = ver.copy_logits(0, row.data()) ? std::fopen(fl, "wb") : nullptr;
|
||||
if (f == nullptr || std::fwrite(row.data(), sizeof(float), row.size(), f) != row.size())
|
||||
std::fprintf(stderr, "strata generate: STRATA_DUMP_FIRST_LOGITS: cannot write %s\n", fl);
|
||||
if (f) std::fclose(f);
|
||||
}
|
||||
}
|
||||
// plan v0.3 P6: the adaptive tier's host work (ranking, copy submission) runs on its own thread while the
|
||||
// GPU commits and drafts; it touches only the residency tables, which nothing reads until the next window
|
||||
|
||||
Reference in new issue
Block a user