mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
repository paths inside tests.
engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.
No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
42 lines
2.5 KiB
C++
42 lines
2.5 KiB
C++
// include/strata/core/hit_hook.hpp - R4.2c: the seam between the host loop and the VRAM expert tier.
|
|
//
|
|
// **IT IS ITS OWN HEADER BECAUSE BOTH SIDES NEED IT AND NEITHER SHOULD OWN IT.** `session.hpp` declares the
|
|
// loop that calls the hook; `expert_source.hpp` declares the implementation that answers it. Putting the type
|
|
// in either one makes the other include a header it has no other use for, and the loop knowing what an expert
|
|
// cache is (or the adapter knowing what a graph is) is exactly the coupling this seam exists to avoid.
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
namespace strata::core {
|
|
|
|
/// **TWO PHASES, AND THE SPLIT IS THE WHOLE POINT.** `Launch` runs BEFORE the CPU pool and `Combine` runs
|
|
/// AFTER the misses have been copied into `parts`. That ordering is what lets the GPU's resident experts run
|
|
/// at the same time as the CPU's misses instead of after them:
|
|
///
|
|
/// ring -> hits(Launch) [GPU: quantize + grouped experts into `hit_out`]
|
|
/// -> pool() [CPU: the misses, CONCURRENT with the GPU]
|
|
/// -> H2D misses into `parts`
|
|
/// -> hits(Combine) [GPU: parts += hit_out]
|
|
/// -> post[l]
|
|
///
|
|
/// **MEASURED, AND WHY IT IS NOT THE OBVIOUS ORDER.** The first version called the hit path once, after the
|
|
/// pool, writing straight into `parts`. The drain duly fell **18.2 -> 10.2 ms** - the CPU really was doing
|
|
/// half the experts - and **the token did not move at all**, because the GPU's half had simply been moved onto
|
|
/// the critical path behind the CPU's instead of beside it. A second buffer and one `add_inplace` buy the
|
|
/// overlap back.
|
|
enum class HitPhase { Launch, Combine };
|
|
|
|
/// `ids` AND `k` ARE THE ROUTER'S OWN OUTPUT, AND THEY ARE WHY THIS HOOK TAKES ARGUMENTS AT ALL.
|
|
///
|
|
/// The first version took only `(user, stream, phase)` and left the hit/miss decision inside the pool
|
|
/// callback - which runs AFTER `Launch`. So `Launch` read the hit list from the PREVIOUS layer and computed
|
|
/// the previous layer's experts into the current layer's rows. It produced a token, the timings looked
|
|
/// plausible, and **C1 moved from mean KL 9.69e-02 to 1.03e+00 and top-1 from 0.867 to 0.333.** The decision
|
|
/// has to happen in `Launch`, on the ids the doorbell published for THIS layer, and the pool then consumes it.
|
|
///
|
|
/// A null `HitFn` means "no VRAM tier" - the default, and what every caller had before R4.
|
|
using HitFn = void (*)(void* user, void* stream, HitPhase phase, const int32_t* ids, int64_t k);
|
|
|
|
} // namespace strata::core
|