Archived
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
433 lines
24 KiB
C++
433 lines
24 KiB
C++
/* engine.h -- the startup sequence and the step loop: what happens, in order, between a command
|
|
* line and a served token. Kept thin; each step is one component doing its own job.
|
|
*
|
|
* Startup, per spec §1:
|
|
*
|
|
* 1. Load kernel plugins from $RADIANCE_HOME/kernels/, in the configured hierarchy order.
|
|
* 2. Load the model's metadata only: architecture id, dimensions, quantisation, vocab.
|
|
* 3. Look up the architecture id in $RADIANCE_HOME/architectures/. No match, no model.
|
|
* 4. Declare. The architecture plugin enumerates every weight, buffer and op it will ever
|
|
* issue, and the core resolves each op against the kernel hierarchy. This phase always
|
|
* completes and reports every resolution failure, not just the first.
|
|
* 5. Plan. The placement planner assigns every weight a tier and an execution site against
|
|
* explicit pool budgets.
|
|
* 6. Load. Weights are mapped and staged according to the plan.
|
|
* 7. Serve.
|
|
*
|
|
* After step 4 the whole model is known statically: every op, its kernel, the weights it touches,
|
|
* and the order. The rest of the engine relies on that.
|
|
*/
|
|
#pragma once
|
|
#include "rad_core.h"
|
|
#include "build/startup.h"
|
|
#include "diag/diag.h"
|
|
#include "mem/hostarena.h"
|
|
#include "sched/mem_iface.h"
|
|
#include "sched/scheduler.h"
|
|
#include "sample/vocab_view.h"
|
|
#include "runtime/rank_barrier.h"
|
|
#include "text/tokenizer.h"
|
|
#include "format/radfile.h"
|
|
#include "format/table_copy.h"
|
|
|
|
#include <atomic>
|
|
#include <chrono>
|
|
#include <condition_variable>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <thread>
|
|
|
|
namespace rad {
|
|
|
|
class Kld;
|
|
class StallWatch;
|
|
namespace gen { class Driver; }
|
|
struct TierPump;
|
|
struct TierJob;
|
|
struct StepSlot;
|
|
|
|
struct VramFacts; /* mem/vram_budget.h */
|
|
struct WeightFootprint; /* place/planner.h */
|
|
|
|
class Engine {
|
|
public:
|
|
explicit Engine(Config cfg);
|
|
~Engine();
|
|
|
|
/* Steps 1..6. Returns negative after printing what failed and why; missing kernels are
|
|
* reported as a full list. */
|
|
int start();
|
|
|
|
/* Step 7. Blocks until the server is asked to stop. A device fault is not recoverable
|
|
* in-process, so it exits non-zero rather than serving from a wedged queue (spec §17).
|
|
* `watch`, when given, is the startup's stall watch (util/stallwatch.h): held until the
|
|
* server listens, or the KL mode starts scoring, so the stretch from start() to there
|
|
* reports where it waits like start() itself. */
|
|
int serve(std::unique_ptr<StallWatch> watch);
|
|
|
|
/* --debug-graph and friends: print everything declare and plan learned, without serving. A
|
|
* first-class mode rather than a verbose-flag side effect, so what runs is always visible. */
|
|
int dump();
|
|
|
|
const Program& program() const;
|
|
const Config& config() const { return cfg_; }
|
|
|
|
/* The startup report (core/diag/diag.h): every option with its value and source, the
|
|
* machine, and what on it costs speed or correctness. serve() prints it with RAD_OK before
|
|
* listening; main prints it with the error start() or serve() failed with, so a server that
|
|
* never came up still logs its setup. The report then repeats the error on an E line, so the
|
|
* log's tail shows it. */
|
|
void print_startup_report(int status);
|
|
/* The report as JSON, with the hardware re-read, since link and clock state only mean
|
|
* something under load (/diagnostics). The reading is reused for a second and covers only the
|
|
* serving cards' power-management files (hardware_facts). */
|
|
std::string diagnostics_json() const;
|
|
bool startup_report_printed() const { return report_printed_; }
|
|
|
|
private:
|
|
/* One thread per tensor-parallel rank, each owning one device. Ranks share the address
|
|
* space, so there is no IPC or serialisation and the step batch is shared by pointer rather
|
|
* than broadcast (spec §1). */
|
|
struct Rank;
|
|
std::vector<std::unique_ptr<Rank>> ranks_;
|
|
/* The tiers' work in flight: the host-memory copies the transfer streams are running. */
|
|
std::unique_ptr<TierPump> pump_;
|
|
/* serve()'s startup stall watch, released when the server listens (run_server) or the KL
|
|
* mode starts (run_kld). */
|
|
std::unique_ptr<StallWatch> startup_watch_;
|
|
std::vector<std::thread> rank_threads_;
|
|
|
|
Config cfg_;
|
|
/* The VRAM split each rank actually takes, filled by Engine::plan. Equal to cfg_ on every
|
|
* rank whose cache costs as much per token as the dearest rank's. A cheaper rank (an
|
|
* attention-zero rank) gets a KV pool sized for the common token count and the difference in
|
|
* its weights pool. Pools::configure and the planner must read the rank's entry, never cfg_;
|
|
* plan() refuses a rank whose plan and weights pool disagree. */
|
|
std::vector<Config> rank_cfg_;
|
|
int64_t kv_planned_tokens_ = 0; /* the common token count plan() sized the re-split pools for */
|
|
|
|
/* The model's source, one of the two. A container stays mapped for the engine's life because
|
|
* the mapped and file tiers read it in place (spec §4.3). A checkpoint served directly also
|
|
* stays mapped and is read once, at load (spec §4.3). */
|
|
std::unique_ptr<RadFile> file_;
|
|
std::unique_ptr<Checkpoint> ckpt_;
|
|
std::unique_ptr<CheckpointSources> ckpt_src_;
|
|
/* The source rad_weight_encoding answers from: container entries or checkpoint tensors. */
|
|
WeightSourceFn sources() const;
|
|
|
|
RadModelMeta meta_{};
|
|
LoadedPlugins plugins_;
|
|
|
|
/* RadModelMeta holds bare char*, so the strings behind its key/value table must outlive
|
|
* every declare. */
|
|
std::vector<std::string> meta_kv_k_, meta_kv_v_;
|
|
std::vector<const char*> meta_kv_kp_, meta_kv_vp_;
|
|
|
|
void (*arch_step_)(RadCtx*, const RadBatch*) = nullptr;
|
|
|
|
int load_plugins();
|
|
int read_metadata();
|
|
int read_checkpoint_metadata();
|
|
/* --rope-scaling over the free-form keys, then the startup line and the context checks;
|
|
* runs on meta_kv_k_/meta_kv_v_ before their pointer arrays are built. */
|
|
int apply_rope_scaling();
|
|
int declare();
|
|
int plan();
|
|
/* Resolves --embedding-placement, --vision-tower-placement and --ngram-placement into Config
|
|
* before the card is split (engine_bringup.cpp describes how auto chooses). `wfs` is every
|
|
* rank's footprint, read for its towers. `host_late` is the pinned host memory startup
|
|
* allocates after the tables and outside every pool (the checkpoint store, the host
|
|
* activation arenas), which a table pinned in host memory must leave room for. */
|
|
int resolve_table_placement(const std::vector<VramFacts>& facts,
|
|
const std::vector<int64_t>& emb_bytes,
|
|
const std::vector<WeightFootprint>& wfs, int64_t kv_floor,
|
|
int64_t ngram_bytes, bool ngram_device, bool ngram_host,
|
|
int64_t host_late);
|
|
/* --ngram-placement ram: one copy of the container's [src, src + n) at file offset `foff`,
|
|
* shared by every rank. Locked for the host gather, or pinned for a device kernel to read
|
|
* over the link (`card`). */
|
|
int copy_table(const uint8_t* src, int64_t n, int64_t foff, bool card, void** out,
|
|
std::string* why);
|
|
/* An auto-chosen pinned copy failed: move every rank's n-gram gather to the host. */
|
|
bool ngram_gather_to_host();
|
|
/* The table copies: locked ones as [base, base + bytes), pinned ones as rad_dev_alloc
|
|
* RAD_MEM_HOST_MAPPED ranges, and the container address each copies. Freed in ~Engine after
|
|
* the ranks that read them are gone. */
|
|
std::vector<TableCopy> table_copies_;
|
|
std::vector<void*> card_copies_;
|
|
std::vector<std::pair<const void*, void*>> table_copy_of_;
|
|
int load_weights();
|
|
int configure_kv();
|
|
/* Maps the step's logits rows back to the sequences that wanted them. Not the identity: a
|
|
* mid-prompt prefill chunk produces no row, and a speculative verify produces 1 + n_spec. */
|
|
struct StepOut {
|
|
std::vector<Request*> reqs; /* the requests that wanted a row, in row order */
|
|
std::vector<int32_t> first_row; /* [n_seq] that entry's first row, or -1 */
|
|
/* Leading logits rows the sampler reads. RadBatch::n_out also counts the KL mode's scored
|
|
* rows after them (Request::score). */
|
|
int32_t n_rows = 0;
|
|
std::vector<int32_t> rows; /* [n_out] the device's answer, copied back */
|
|
int32_t* rb = nullptr; /* the pinned readback collect_issue filled */
|
|
std::vector<float> lg; /* the first row's logits, at -vv */
|
|
std::vector<int32_t> token; /* [n_seq] */
|
|
std::vector<int32_t> accepted; /* [n_seq] */
|
|
std::vector<uint8_t> eos; /* [n_seq] */
|
|
/* [n_rows] each sampled row's logprobs, for the rows of requests that asked for them;
|
|
* empty on a step with none. */
|
|
std::vector<TokenLogprobs> lp;
|
|
};
|
|
|
|
/* The text frontend, loaded from the container. The sampler's grammars walk `vocab_view_`,
|
|
* which references `vocab_` and must not outlive it. */
|
|
std::shared_ptr<const Vocab> vocab_;
|
|
std::unique_ptr<VocabView> vocab_view_;
|
|
|
|
/* The chunk geometry, resolved once and shared: the prefix cache needs the checkpoint interval
|
|
* at configure time and the scheduler the whole geometry at init. Resolving it separately
|
|
* would let the cache use the raw interval while the scheduler uses the rounded one. */
|
|
ChunkGeometry geo_;
|
|
|
|
/* One scheduler for every rank: one decision per step, one batch, shared by pointer. */
|
|
Scheduler sched_;
|
|
std::unique_ptr<IKVManager> kv_iface_;
|
|
std::unique_ptr<IPrefixCache> pc_iface_;
|
|
|
|
/* The release point. Width is tp + 1: the scheduler thread also takes part. */
|
|
std::unique_ptr<RankBarrier> barrier_;
|
|
std::atomic<const RadBatch*> step_batch_{nullptr};
|
|
/* What a release asks the ranks to issue: the forward pass and its sampler (kIssueAll), the
|
|
* forward pass alone (kIssueModel: the next step's, issued before this one is read back), or
|
|
* that pass's sampler alone (kIssueSampler, once the host has committed its inputs). Every
|
|
* release must set it; a stale value would make a draft pass issue only its sampler. */
|
|
enum { kIssueAll = 0, kIssueModel = 1, kIssueSampler = 2 };
|
|
std::atomic<int> issue_what_{kIssueAll};
|
|
std::atomic<int> step_status_{RAD_OK};
|
|
std::atomic<bool> stopping_{false};
|
|
/* The error the step loop ended on; RAD_OK while running or after a clean stop. Written once
|
|
* by fail_loop(); read by the server watcher to stop HTTP and by serve() to return it. */
|
|
std::atomic<int> loop_status_{RAD_OK};
|
|
int fail_loop(int st);
|
|
|
|
/* This step's scored rows (Request::token_scores): a logits row and the result it fills.
|
|
* Written by the scheduler thread while the ranks are parked, read by them during the step,
|
|
* consumed by collect_step. */
|
|
std::vector<std::pair<int32_t, TokenScores*>> score_rows_;
|
|
int stage_scored_rows(const StepPlan& plan, const StepOut& so);
|
|
int issue_scored_rows(Rank& r);
|
|
int collect_scored_rows();
|
|
|
|
/* Gate for the sampler's host work, which runs while the device executes the model.
|
|
* Staging sampler parameters (and, with a grammar, a whole-vocabulary mask per draft
|
|
* position) touches no stream: Sampler::run issues every upload on the rank thread. So the
|
|
* ranks enqueue the model first, the scheduler runs build_step meanwhile, and the ranks wait
|
|
* here before enqueueing the sampler chain. One-shot per step, reset while the ranks are
|
|
* parked at the release, so no rank can see a stale ready flag. */
|
|
std::mutex build_mu_;
|
|
std::condition_variable build_cv_;
|
|
bool build_ready_ = false;
|
|
int build_status_ = RAD_OK;
|
|
|
|
/* Scratch for the checkpoint copies: one sequence's state slots, reused so the step path
|
|
* does not allocate. See state_slots_of. */
|
|
std::vector<int32_t> ckpt_slots_;
|
|
std::vector<int32_t> ckpt_win_; /* KVManager::window_rows, same reuse */
|
|
bool state_slots_of(uint64_t seq, std::vector<int32_t>* out) const;
|
|
|
|
int load_vocab();
|
|
int declare_sampler(int rank, RadBuilder* b, int64_t logits_width, bool sizing = false);
|
|
/* The build context for every declare of rank `rank` at `max_tok`; the real declare and the
|
|
* arena's sizing declares differ only in max_tok. */
|
|
RadBuildCtx build_ctx(int rank, int64_t max_tok) const;
|
|
void probe_arena_levels();
|
|
int step_loop();
|
|
/* Issue the copy of the step's sampled ids to the host, then wait for and interpret them.
|
|
* Split so the copy is issued before draft passes overwrite the ids, and the wait comes after
|
|
* them. */
|
|
int collect_issue(StepOut& so);
|
|
int collect_step(const RadBatch* b, StepOut& so);
|
|
int row_logprobs(StepOut& so, int32_t row, int32_t token);
|
|
/* The step's end on the card: after its last draft pass and the host readbacks, before the
|
|
* step issued ahead. collect_step waits on this event, not the stream, so the card runs the
|
|
* next step while the host commits this one. */
|
|
int mark_step_end(const RadBatch* b, StepOut& so);
|
|
RadEvent step_end_ = nullptr;
|
|
|
|
/* The draft head as declared (rad_declare_drafter), zeroed when no speculative window was
|
|
* asked for. `kind` selects which of the two drivers below runs. `drafter_name_` owns the
|
|
* string because RadDrafterDecl::name points into the Program. */
|
|
RadDrafterDecl drafter_{};
|
|
std::string drafter_name_;
|
|
|
|
/* Serial driver (spec §10): `depth` dependent passes after the step commits, each embedding
|
|
* the previous proposal. MTP, EAGLE and Medusa-serial have this shape. */
|
|
std::vector<int32_t> draft_out_; /* [rows][depth], what each pass proposed */
|
|
|
|
/* Host side of every step-path readback (sampled tokens, draft proposals). Pinned, because a
|
|
* device-to-host copy into pageable memory bounces synchronously through a staging buffer and
|
|
* blocks on the whole stream; into pinned memory it is one more stream packet and the step's
|
|
* own wait is the only wait. Grown on first use to the largest readback requested. */
|
|
struct Readback {
|
|
int32_t* p = nullptr;
|
|
int64_t n = 0;
|
|
int32_t* reserve(int64_t count);
|
|
~Readback();
|
|
};
|
|
Readback readback_;
|
|
/* Embedding program (rad_declare_pooled): no sampler; a step's answer is the pooled buffer's
|
|
* first n_seq rows. `pooled_host_` is their pinned landing area, [max_seqs, pooled_dim_] f32;
|
|
* collect_pooled copies them behind the step and hands each row to its sink after the
|
|
* step's one wait. */
|
|
bool embedding_ = false;
|
|
int64_t pooled_dim_ = 0;
|
|
float* pooled_host_ = nullptr;
|
|
int collect_pooled_issue(const RadBatch* b, StepOut& so);
|
|
int collect_pooled(const RadBatch* b, StepOut& so);
|
|
/* Image generator (rad_declare_generator): the driver that turns requests into passes and the
|
|
* loop that runs them, replacing the scheduler and step loop (engine_gen.cpp). Null for every
|
|
* other program. */
|
|
std::unique_ptr<gen::Driver> gen_;
|
|
int gen_loop();
|
|
bool serial_drafting() const;
|
|
int advance_all(int mode, int round, bool from_proposal, int rows = -1);
|
|
int issue_serial_drafter(int step, StepOut& so);
|
|
/* The next step's forward pass, issued before this one is read back; null when the scheduler
|
|
* wants this step committed first. See Scheduler::step_next. */
|
|
int issue_ahead(const RadBatch** out);
|
|
/* The arena level and the followers' pools, before any release that runs a forward pass. */
|
|
int prepare_release(const RadBatch* b);
|
|
/* Whether a step may be issued ahead: requires that the drafter, if any, runs on the card (a
|
|
* block drafter and the prompt-lookup drafter both read the committed sequence). */
|
|
bool pipelining_ = false;
|
|
int finish_serial_drafter(const StepOut& so);
|
|
/* Handed from issue_serial_drafter to finish_serial_drafter: the drafting rows, the rounds
|
|
* asked for, and the rounds that ran. */
|
|
std::vector<Scheduler::SerialRow> serial_row_;
|
|
int serial_rounds_ = 0, serial_rows_ = 0, serial_done_ = 0;
|
|
/* The StepSlots and end-of-generation ids on every rank, and the pinned host copy of rank 0's
|
|
* slots the step reads back (sched/advance.h). */
|
|
int step_state_init();
|
|
void step_state_fini();
|
|
StepSlot* slots_host_ = nullptr;
|
|
|
|
/* Step-time attribution, Debug only (see the barrier in step_loop): time per scheduler phase.
|
|
* The nine phases sum to the whole step, including the readback, commit and drafter after the
|
|
* join. */
|
|
enum Ph { PH_PLAN, PH_BEGIN, PH_BUILD, PH_PRE, PH_RANKS, PH_SAVE, PH_COLLECT, PH_COMMIT,
|
|
PH_DRAFT, PH_N };
|
|
double phase_us_[PH_N] = {};
|
|
int phase_n_ = 0;
|
|
std::chrono::steady_clock::time_point phase_t_{};
|
|
void phase_mark(int p);
|
|
|
|
/* Block driver (spec §10): a context pass mirroring the step just run, then one pass that
|
|
* fills every drafted position at once. DFlash2 has this shape. */
|
|
int run_block_drafter(int step);
|
|
/* Encoder driver (spec §11, core/engine_mm.cpp): encodes every media item the scheduler waits
|
|
* on, in passes of whole segments, and reads it back into the item. Runs between steps, never
|
|
* inside one. */
|
|
int run_encodes();
|
|
int32_t enc_step_ = 0;
|
|
void drain_completed();
|
|
/* Terminal ids drain_completed() took, reused so steady state allocates nothing. */
|
|
std::vector<uint64_t> done_;
|
|
/* The tiers' per-iteration work: collect a landed copy, start the next, make room in a full
|
|
* arena. Never waits on the device; the scheduler's lock covers only the bookkeeping. */
|
|
void tier_tick();
|
|
/* --prefix-cache-ttl, once a second, with or without the tiers (PrefixCache::expire). */
|
|
void expire_tick(uint64_t now_ns);
|
|
uint64_t expire_last_ns_ = 0;
|
|
/* Issue and land every waiting host copy now. Called under the scheduler's lock by an
|
|
* eviction that would otherwise erase what the copies cover. True when any landed. */
|
|
bool flush_copies();
|
|
/* The KV loan: what the cache is not using, lent to every rank's expert slab at addresses the
|
|
* cache already owns (KVManager, the loan block). Lives here, not in the scheduler, because
|
|
* rank 0's cache sets the amount while every rank's mover fills or empties slots, and a mover
|
|
* may only be driven while its rank thread is parked, which this thread knows. `idle` also
|
|
* runs each mover's own fill, which a busy engine gets from the step. */
|
|
void loan_tick(bool idle);
|
|
bool lending_ = false;
|
|
uint64_t loan_last_ns_ = 0;
|
|
/* The activation arena's loan (Engine::arena_step). `arena_rows_[k]` is the largest step Ctx
|
|
* level k serves (level 0 is the full plan); empty when the arena lends nothing. The floor is
|
|
* the largest recent step: the loan grows past it only after no step that large has run for a
|
|
* while, so a run of prefill chunks does not refill and recall the slab between chunks. */
|
|
int arena_step(const RadBatch* b);
|
|
void arena_tick(uint64_t now_ns);
|
|
int arena_level(int64_t rows) const;
|
|
std::vector<int64_t> arena_rows_;
|
|
/* The span's shared level (Engine::probe_arena_levels): the rows of the level a step of one
|
|
* interval runs at under --prefill-span, where the prefill stager's ring is the level's own
|
|
* (stager.h); 0 without one. */
|
|
int64_t arena_span_rows_ = 0;
|
|
int64_t arena_floor_ = 0;
|
|
int64_t arena_last_ = 0;
|
|
uint64_t arena_floor_ns_ = 0;
|
|
/* VRAM the budget reserves for allocations after start(), on top of --gpu-headroom-mib: the
|
|
* step batch's staging (allocated by serve()) and what is built on first use, if ever (the KV
|
|
* tiers' copy staging, the second compute lane's queue). Bring-up's final VRAM reading is
|
|
* checked against both. */
|
|
int64_t late_step_bytes_ = 0;
|
|
int64_t late_lazy_bytes_ = 0;
|
|
/* Linear-state snapshot store: pinned host memory, --checkpoint-slots slots, each holding every
|
|
* rank's shard of one snapshot (KVManager::set_checkpoint_store). Off the card because no
|
|
* kernel reads a snapshot; it is only copied back into a sequence's state. */
|
|
HostArena ck_store_;
|
|
int run_server();
|
|
/* KL mode (core/kld.h), replacing run_server: submits the corpus documents as scoring
|
|
* requests and hands every step's scored rows, copied to the host, to `kld_`. One pinned
|
|
* block per rank, holding a step's tokens of that rank's logits columns. */
|
|
int run_kld();
|
|
int score_rows(const RadBatch* b, const StepOut& so);
|
|
std::unique_ptr<Kld> kld_;
|
|
std::vector<float*> kld_host_;
|
|
std::vector<int64_t> kld_vocab0_, kld_width_; /* per rank read: its logits columns */
|
|
/* The engine half of /server_info, as a JSON object. See the definition in engine.cpp. */
|
|
std::string engine_info() const;
|
|
|
|
/* ---- startup report inputs (engine_diag.cpp). `decisions_` holds each value startup resolved
|
|
* and why, recorded where it was resolved; the rest are facts only startup saw. */
|
|
std::vector<diag::Decision> decisions_;
|
|
void decide(const std::string& key, const std::string& value, const std::string& why) {
|
|
diag::decide(&decisions_, key, value, why);
|
|
}
|
|
std::string devnote_; /* the devices usable_devices left out, and why */
|
|
int p2p_measured_ = -1; /* 1 peer to peer, 0 through host memory, -1 not asked */
|
|
std::string p2p_blocked_;
|
|
bool has_ngram_ = false; /* the model carries an n-gram table */
|
|
std::string prefix_off_why_; /* why the engine itself turned prefix caching off, or "" */
|
|
std::vector<std::string> env_set_; /* the RADIANCE_* names set when the engine was made */
|
|
bool report_printed_ = false;
|
|
/* Runtime device identity (PCI address, name, integrated flag, runtime version), read once in
|
|
* start() beside usable_devices. Later reports make no runtime call: after a failed start
|
|
* there may have been a device fault, and on an HTTP thread (/diagnostics) a runtime call can
|
|
* wait on a lock the launch path holds (see DeviceBackend::vram_used). */
|
|
struct DevId { int device = -1; std::string bdf, name; bool integrated = false; };
|
|
std::vector<DevId> dev_ids_;
|
|
std::string runtime_version_;
|
|
void identify_devices(const std::vector<std::string>& names);
|
|
/* Syscall-only facts (diag::probe_process), read once at the first report: the memlock limit
|
|
* cannot change under a running process, and the io_uring probe need not repeat per
|
|
* /diagnostics request. */
|
|
bool probed_ = false;
|
|
int64_t memlock_soft_ = -1;
|
|
std::string io_uring_;
|
|
/* The last /diagnostics hardware reading, reused for kDiagReuseNs. The SMU answers the card
|
|
* files under the driver's power-management lock, so a polling client must not become a
|
|
* stream of SMU requests beside the server. */
|
|
mutable std::mutex diag_mu_;
|
|
mutable diag::Facts diag_facts_;
|
|
mutable uint64_t diag_read_ns_ = 0;
|
|
/* `serving`: read power-management files only for the cards the ranks serve on
|
|
* (diag::collect's `managed`). */
|
|
diag::Facts hardware_facts(bool serving) const;
|
|
diag::RunFacts run_facts(bool failed) const;
|
|
|
|
/* One dispatch of the tiering seam: retire what landed, credit last step's routing, issue
|
|
* what the heat engine proposes. A member because Rank is private; a no-op on a static plan.
|
|
* The definition explains why a step is the unit. */
|
|
void tiering_dispatch(Rank& r, int step);
|
|
void rank_loop(int rank);
|
|
};
|
|
|
|
} /* namespace rad */
|