mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 06:15:58 -10:00
Prompt-path block scores in single-pass TF32 with a per-block error bound, 3xTF32 rescoring only near each query's top-k cut-off, so qsa_block_topk returns the same cells in the same order, ties included. Off unless the variable is set; says once where it cannot run (HIP, Metal, SYCL, layer-major path). Adds qsa_two_pass_test, qsa_two_pass_status_test and the GPU parity test qsa_two_pass_parity. Ported from PR 4119 (bitaccesscomau); the log line of the per-prompt counters is shortened without dropping a field. l620 (sm_120, IQ3_S), greedy ids identical off vs on in every pair: prompt 128K +1.65% (n=12), 256K +4.10% (n=8), 32K -0.14% (noise). (cherry picked from commit bbf7c55f1351d913233250fe7869642f7c2b98a1)
42 lines
1.9 KiB
C++
42 lines
1.9 KiB
C++
#pragma once
|
|
// STRATA_SELECT_TWO_PASS: the request, read once, and the line a set switch prints where the two-pass scorer cannot
|
|
// run. The scorer runs only in the CUDA prompt path's chunked walk, on a card where qsa_block_scores_tc runs its
|
|
// tensor-core kernel (sm_80+, STRATA_QSA_WARP not set). Elsewhere (HIP, Metal, SYCL, an older card or the warp
|
|
// scorer, the layer-major prompt path) the selection runs as without the switch; that was silent, so the switch read
|
|
// as active. Header-only, so the rule and the line are tested without a GPU (qsa_two_pass_status_test).
|
|
#include <atomic>
|
|
#include <cstdio>
|
|
|
|
namespace strata::kernels::two_pass {
|
|
|
|
// The switch's own parse: exactly "1" is on (as the two-pass scorer read it before).
|
|
inline bool requested_from(const char* v) { return v != nullptr && v[0] == '1' && v[1] == '\0'; }
|
|
|
|
class RequestStatus {
|
|
public:
|
|
explicit RequestStatus(const char* flag) : requested_(requested_from(flag)) {}
|
|
|
|
bool requested() const { return requested_; }
|
|
|
|
// `not_here` null: this path can run the scorer, so the result is the request (whether a call takes it still
|
|
// depends on the call: its size, geometry and scratch). Otherwise the path cannot run it: false, and the first
|
|
// such query prints one line naming the path. A supported query never uses up that line.
|
|
bool on(const char* not_here, FILE* log = stderr) {
|
|
if (!requested_) return false;
|
|
if (not_here == nullptr) return true;
|
|
if (!warned_.exchange(true)) {
|
|
std::fprintf(log, "strata: STRATA_SELECT_TWO_PASS=1 is not used on %s: the two-pass scorer runs only in "
|
|
"the CUDA prompt path's tensor-core selection (sm_80+); the selection is unchanged\n",
|
|
not_here);
|
|
std::fflush(log);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private:
|
|
const bool requested_;
|
|
std::atomic<bool> warned_{false};
|
|
};
|
|
|
|
} // namespace strata::kernels::two_pass
|