Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/src/omega_gpu_serving.h # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / src / omega_gpu_serving.h` 49 lines · 3388 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* 3 * omega_gpu_serving.h: OPT-IN up-front reservation of the GB10 serving buffers (sovereign-core design 4 * note docs/design/gb10-weight-ownership.md, sc#277). 5 * 6 * Without this call nothing changes: the attention staging pool, the matmul activation and result 7 * buffers and the matmul kernel cache grow on demand, which on the GB10 means one driver allocation 8 * per new context length and per row-count growth (omega PR #332 measured 458 after warm-up over 428 9 * tokens). With it, a daemon calls omega_gpu_reserve_serving once after loading weights, and every 10 * later call inside the declared bounds reuses the same buffers. A call outside the bounds is refused 11 * with TOO_LARGE and a clear omega_gpu_*_last_error() text ("serving reservation exceeded: need N 12 * bytes, reserved M"); it never asks the driver for more memory, so it cannot fault the session. 13 * 14 * Not covered (documented follow-ups): the elementwise API's scratch (it stops growing after the 15 * first full-size call), the attention kernel cache (8 slots, one kernel per model shape and context split count), and the 16 * first build of each distinct matmul shape unless the server prepares every shape it will run 17 * (omega_gpu_matmul_prepare: one small code buffer per shape, pinned) and then seals 18 * (omega_gpu_serving_seal): after that an unprepared shape is refused, never built. 19 */ 20 #ifndef OMEGA_GPU_SERVING_H 21 #define OMEGA_GPU_SERVING_H 22 23 #include 24 25 typedef struct { 26 uint32_t max_context; /* longest sequence (tokens) one attention call may cover */ 27 uint32_t max_seqs; /* sequences per attention call; 0 = 1 */ 28 uint32_t num_q_heads, num_kv_heads, head_dim; /* the model's attention shape */ 29 uint32_t kv_block_size; /* paged KV block size in tokens (power of two); 0 = the paged bf16 path is not used */ 30 uint32_t max_rows; /* most rows one matmul call may carry (prefill chunk) */ 31 uint32_t max_k; /* widest weight input dimension */ 32 uint32_t max_n; /* widest weight output dimension for calls of up to max_rows rows */ 33 uint32_t max_n_one_row; /* widest output dimension for calls of at most 16 rows (lm_head); 0 = max_n */ 34 uint32_t kernel_slots; /* matmul kernel cache slots; 0 = leave at 8; at most 128. Qwen3-4B, rows 1..256: 83 distinct kernels (grid_x and the row/column block vary with rows) */ 35 } OmegaGpuServingBounds; 36 37 /* Opens the device if needed. 0 on success, else the first failing OMEGA_GPU_MATMUL_* / ATTN_* code 38 * (omega_gpu_matmul_last_error() has the text). All-or-nothing: each API rolls back its own buffers when one of its 39 * allocations fails, and this call rolls back the attention half when the matmul half fails, so a failed reserve 40 * leaves nothing flagged. Notes: a refused paged/batched attention call may follow earlier launch chunks that already 41 * wrote their outputs (TOO_LARGE = output incomplete); max_seqs is checked per launch chunk, not per call. */ 42 int omega_gpu_reserve_serving(const OmegaGpuServingBounds *b); 43 44 /* After the server prepared its matmul shapes: refuse any unprepared one from now on (omega_gpu_matmul_seal). */ 45 void omega_gpu_serving_seal(void); 46 /* Lift the reservation and the seal: buffers stay, growth is allowed again. (Closing the device also ends both.) */ 47 void omega_gpu_serving_release(void); 48 49 #endif