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/omega-mv/blob/main/src/omega_gpu_bf16_gemv_api.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / omega_gpu_bf16_gemv_api.c` 349 lines ยท 18704 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* omega_gpu_bf16_gemv_api.c: bf16 streaming GEMV (lm_head) on the shared session, OWN-30B 2026-10-13. 18 * See the header. Submission path and buffer policy are the FP8 API's: every buffer both sides touch is 19 * GPU-uncached (nvos.h NVOS32_ATTR2_GPU_CACHEABLE: "For system memory this will not be coherent with direct CPU 20 * mappings"); one launch = omega_gpu_session_launch. */ 21 #include "omega_gpu_bf16_gemv_api.h" 22 #include "omega_gpu_session.h" 23 #include "omega_gpu_fmt.h" 24 #include "omega_gpu_cmdlist.h" 25 #include 26 27 #define CACHE_SLOTS 8 28 #define MARKER_TIMEOUT_MS 20000ull 29 #define POISON_F32 (-999.0f) 30 #define DEFAULT_CTAS 96u 31 32 struct OmegaGpuBf16Tensor { 33 uint32_t n, k; 34 OmegaGpuMem w; 35 }; 36 37 typedef struct { 38 bool valid, pinned; 39 OmegaBf16GemvSpec spec; 40 OmegaBlackwellKernel kernel; 41 OmegaGpuMem code; 42 } Slot; 43 44 static struct { 45 OmegaGpuScratch x_buf, y_buf; 46 uint32_t rows, warps, depth, ctas; /* overrides, 0 = automatic */ 47 int mutant; 48 bool hooked; 49 Slot cache[CACHE_SLOTS]; 50 unsigned next; 51 } g; 52 static int g_rec; /* 1 while a record call runs (lock held): kernel_for must not evict */ 53 static int g_mask_mutant; /* TEST ONLY: the MASK form's mutant (4 = keep / drop inverted), other kernels untouched */ 54 55 const char *omega_gpu_bf16_last_error(void) { return omega_gpu_session_last_error(); } 56 const char *omega_gpu_bf16_rc_name(int rc) { 57 switch (rc) { 58 case OMEGA_GPU_BF16_OK: return "OK"; 59 case OMEGA_GPU_BF16_BAD_ARGS: return "BAD_ARGS"; 60 case OMEGA_GPU_BF16_TOO_LARGE: return "TOO_LARGE"; 61 case OMEGA_GPU_BF16_CODEGEN_FAIL: return "CODEGEN_FAIL"; 62 case OMEGA_GPU_BF16_CHIP_FAIL: return "CHIP_FAIL"; 63 case OMEGA_GPU_BF16_NAN_WEIGHT: return "NAN_WEIGHT"; 64 default: return "UNKNOWN"; 65 } 66 } 67 68 static void cache_clear_locked(void) { 69 for (unsigned i = 0; i < CACHE_SLOTS; i++) { 70 if (!g.cache[i].valid) continue; 71 omega_gpu_session_free(&g.cache[i].code); 72 memset(&g.cache[i], 0, sizeof g.cache[i]); 73 } 74 g.next = 0; 75 } 76 static void on_session_close(void) { 77 cache_clear_locked(); 78 omega_gpu_session_scratch_free(&g.x_buf); 79 omega_gpu_session_scratch_free(&g.y_buf); 80 } 81 static OmegaGpuSession *dev_open_locked(void) { 82 if (!g.hooked) { (void)omega_gpu_session_on_close(on_session_close); g.hooked = true; } 83 return omega_gpu_session_open(); 84 } 85 void omega_gpu_bf16_cache_clear(void) { omega_gpu_session_lock(); cache_clear_locked(); omega_gpu_session_unlock(); } 86 void omega_gpu_bf16_set_shape(uint32_t rows, uint32_t warps, uint32_t depth) { 87 omega_gpu_session_lock(); g.rows = rows; g.warps = warps; g.depth = depth; cache_clear_locked(); omega_gpu_session_unlock(); 88 } 89 void omega_gpu_bf16_set_cta_budget(uint32_t ctas) { omega_gpu_session_lock(); g.ctas = ctas; omega_gpu_session_unlock(); } 90 void omega_gpu_bf16_test_set_mutant(int m) { omega_gpu_session_lock(); g.mutant = m; cache_clear_locked(); omega_gpu_session_unlock(); } 91 void omega_gpu_bf16_test_set_mask_mutant(int m) { omega_gpu_session_lock(); g_mask_mutant = m; omega_gpu_session_unlock(); } 92 93 /* Declared registers: peak + 1 rounded up to 8; a CTA must fit the 65536-register file (chip-found rules, see 94 * omega_gpu_fp8_api.c and ~/handoffs/own30b-K-report.md). */ 95 static uint32_t gpr_declared(uint32_t peak) { return omega_bw_gpr_declared(peak); } /* peak + 2 rounded up to 8: the chip hung at peak + 1 (omega_blackwell_codegen.h) */ 96 static bool register_file_fits(uint32_t warps, uint32_t peak) { 97 uint32_t decl = gpr_declared(peak); 98 if ((uint64_t)32u * warps * decl <= 65536u) return true; 99 char e[160]; omega_gpu_fmt(e, sizeof e, "bf16 kernel: %u warps x %u declared registers exceed the 65536-register file", warps, decl); 100 omega_gpu_session_set_error(e); 101 return false; 102 } 103 int omega_gpu_bf16_kernel_fits(const OmegaBf16GemvSpec *spec, uint32_t *declared) { 104 uint32_t peak = 0; 105 if (!spec || omega_bf16_gemv_prog_stats(spec, NULL, &peak) != 0) { omega_gpu_session_set_error("bf16 codegen refused the shape"); return OMEGA_GPU_BF16_CODEGEN_FAIL; } 106 if (declared) *declared = gpr_declared(peak); 107 return register_file_fits(spec->warps, peak) ? OMEGA_GPU_BF16_OK : OMEGA_GPU_BF16_TOO_LARGE; 108 } 109 110 /* Automatic shape. DEFAULTS_BEGIN: set from the chip sweep (evidence OWN30B-BF16-*); see the report. */ 111 void omega_gpu_bf16_shape_for(uint32_t k, uint32_t *rows, uint32_t *warps, uint32_t *depth, uint32_t *ctas) { 112 uint32_t ks = k / 256u, w = 16u, r = 1u, d = ks; 113 while (d > 16u || ks % d || r * d > 16u) d--; 114 if (k % (32u * w) || k > 512u * w) w = 32u; 115 if (rows) *rows = g.rows ? g.rows : r; 116 if (warps) *warps = g.warps ? g.warps : w; 117 if (depth) *depth = g.depth ? g.depth : d; 118 if (ctas) *ctas = g.ctas ? g.ctas : DEFAULT_CTAS; 119 } 120 static void spec_for(uint32_t k, OmegaBf16GemvSpec *spec, uint32_t *ctas) { 121 memset(spec, 0, sizeof *spec); 122 spec->k = k; 123 omega_gpu_bf16_shape_for(k, &spec->rows, &spec->warps, &spec->depth, ctas); 124 spec->mutant = g.mutant; 125 } 126 127 static int kernel_for(const OmegaBf16GemvSpec *spec, Slot **out, bool *hit) { 128 for (unsigned i = 0; i < CACHE_SLOTS; i++) { 129 Slot *s = &g.cache[i]; 130 if (s->valid && memcmp(&s->spec, spec, sizeof *spec) == 0) { *out = s; *hit = true; return OMEGA_GPU_BF16_OK; } 131 } 132 Slot *s = NULL; 133 for (unsigned i = 0; i < CACHE_SLOTS && !s; i++) { 134 Slot *c = &g.cache[(g.next + i) % CACHE_SLOTS]; 135 if (!c->valid || !c->pinned) { s = c; g.next = (unsigned)((c - g.cache) + 1) % CACHE_SLOTS; } 136 } 137 if (!s) { omega_gpu_session_set_error("bf16 kernel cache: every slot holds a prepared kernel"); return OMEGA_GPU_BF16_TOO_LARGE; } 138 if (g_rec && s->valid) { omega_gpu_session_set_error("bf16 record: kernel cache miss would evict a resident kernel (warm up before recording)"); return OMEGA_GPU_BF16_TOO_LARGE; } 139 BlackwellIRProgram *prog = omega_gpu_host_calloc(1, sizeof *prog); 140 if (!prog) { omega_gpu_session_set_error("bf16 codegen: host memory"); return OMEGA_GPU_BF16_CODEGEN_FAIL; } 141 int cg = omega_blackwell_codegen_bf16_gemv_prog(spec, prog); 142 size_t need = cg == 0 ? omega_bw_program_code_bytes(prog) : 0; 143 if (cg != 0 || need == 0) { omega_gpu_host_free(prog); omega_gpu_session_set_error("bf16 codegen refused the shape"); return OMEGA_GPU_BF16_CODEGEN_FAIL; } 144 if (!register_file_fits(spec->warps, prog->regalloc.peak_gpr_usage)) { omega_gpu_host_free(prog); return OMEGA_GPU_BF16_TOO_LARGE; } 145 OmegaGpuMem code; 146 if (omega_gpu_session_alloc_code(need, &code) != 0) { omega_gpu_host_free(prog); return OMEGA_GPU_BF16_CHIP_FAIL; } 147 OmegaBlackwellKernel kernel; 148 cg = omega_blackwell_kernel_encode_into(prog, code.cpu, need, &kernel); 149 omega_gpu_host_free(prog); 150 if (cg != 0 || !kernel.code || kernel.code_size != need) { omega_gpu_session_free(&code); return OMEGA_GPU_BF16_CODEGEN_FAIL; } 151 if (omega_gpu_session_sync_to_gpu(&code) != 0) { omega_gpu_session_free(&code); return OMEGA_GPU_BF16_CHIP_FAIL; } 152 if (s->valid) omega_gpu_session_free(&s->code); 153 memset(s, 0, sizeof *s); 154 s->valid = true; s->spec = *spec; s->kernel = kernel; s->code = code; 155 *out = s; *hit = false; 156 return OMEGA_GPU_BF16_OK; 157 } 158 159 static int prepare_spec(const OmegaBf16GemvSpec *spec) { 160 omega_gpu_session_lock(); 161 int rc = OMEGA_GPU_BF16_OK; 162 if (!dev_open_locked()) rc = OMEGA_GPU_BF16_CHIP_FAIL; 163 else { Slot *s = NULL; bool hit = false; rc = kernel_for(spec, &s, &hit); if (rc == OMEGA_GPU_BF16_OK) s->pinned = true; } 164 omega_gpu_session_unlock(); 165 return rc; 166 } 167 int omega_gpu_bf16_prepare(uint32_t k) { 168 OmegaBf16GemvSpec spec; uint32_t ctas; spec_for(k, &spec, &ctas); 169 return prepare_spec(&spec); 170 } 171 static void xbatch_fit_depth(OmegaBf16GemvSpec *spec) { 172 if (g.depth || spec->xbatch <= 1u) return; 173 const uint32_t ks = spec->k / 256u; 174 uint32_t peak = 0; 175 while (spec->depth > 1u) { 176 if (omega_bf16_gemv_prog_stats(spec, NULL, &peak) == 0 && (uint64_t)32u * spec->warps * gpr_declared(peak) <= 65536u) return; 177 do { spec->depth--; } while (spec->depth > 1u && ks % spec->depth); 178 } 179 } 180 int omega_gpu_bf16_prepare_xbatch(uint32_t k, uint32_t xbatch, uint32_t ystride) { 181 if (xbatch <= 1u) return omega_gpu_bf16_prepare(k); 182 if (xbatch > OMEGA_BF16_MAX_XBATCH || ystride == 0) return OMEGA_GPU_BF16_BAD_ARGS; 183 OmegaBf16GemvSpec spec; uint32_t ctas; spec_for(k, &spec, &ctas); 184 spec.xbatch = xbatch; spec.ystride = ystride; 185 xbatch_fit_depth(&spec); 186 return prepare_spec(&spec); 187 } 188 /* the MASK kernel as gemv_core builds it (rows 1, mask 1), pinned: the exact head's record never compiles mid-token */ 189 int omega_gpu_bf16_prepare_mask(uint32_t k) { 190 OmegaBf16GemvSpec spec; uint32_t ctas; spec_for(k, &spec, &ctas); 191 spec.rows = 1; spec.mask = 1; 192 return prepare_spec(&spec); 193 } 194 195 void omega_gpu_bf16_tensor_shape(const OmegaGpuBf16Tensor *t, uint32_t *n, uint32_t *k) { 196 if (n) *n = t ? t->n : 0; 197 if (k) *k = t ? t->k : 0; 198 } 199 200 int omega_gpu_bf16_tensor_upload(uint32_t n, uint32_t k, const uint16_t *w, OmegaGpuBf16Tensor **out) { 201 if (out) *out = NULL; 202 if (!w || !out || n == 0 || k == 0 || k % 256u) return OMEGA_GPU_BF16_BAD_ARGS; 203 if (k > OMEGA_BF16_MAX_K) return OMEGA_GPU_BF16_TOO_LARGE; 204 const size_t count = (size_t)n * k; 205 for (size_t i = 0; i < count; i++) if ((w[i] & 0x7f80u) == 0x7f80u) { 206 char e[120]; omega_gpu_fmt(e, sizeof e, "bf16 upload: NaN or infinity at element %zu", i); 207 omega_gpu_session_set_error(e); 208 return OMEGA_GPU_BF16_NAN_WEIGHT; 209 } 210 OmegaGpuBf16Tensor *t = omega_gpu_host_calloc(1, sizeof *t); 211 if (!t) return OMEGA_GPU_BF16_BAD_ARGS; 212 t->n = n; t->k = k; 213 int rc = OMEGA_GPU_BF16_OK; 214 omega_gpu_session_lock(); 215 if (!dev_open_locked() || omega_gpu_session_alloc(count * 2u, &t->w) != 0) rc = OMEGA_GPU_BF16_CHIP_FAIL; 216 omega_gpu_session_unlock(); 217 if (rc == OMEGA_GPU_BF16_OK) { 218 memcpy(t->w.cpu, w, count * 2u); 219 if (omega_gpu_session_sync_to_gpu(&t->w) != 0) rc = OMEGA_GPU_BF16_CHIP_FAIL; 220 } 221 if (rc != OMEGA_GPU_BF16_OK) { omega_gpu_bf16_tensor_free(t); return rc; } 222 *out = t; 223 return OMEGA_GPU_BF16_OK; 224 } 225 226 void omega_gpu_bf16_tensor_free(OmegaGpuBf16Tensor *t) { 227 if (!t) return; 228 omega_gpu_session_lock(); 229 if (t->w.cpu) omega_gpu_session_free(&t->w); 230 omega_gpu_session_unlock(); 231 omega_gpu_host_free(t); 232 } 233 234 /* rec non-NULL (record path, caller holds the session lock): x and y are the device buffers dev_x / dev_y, the launch is 235 * appended to rec instead of submitted, nothing is staged, poisoned or read back. */ 236 static int gemv_core(const OmegaGpuBf16Tensor *t, const float *x32, const uint16_t *x16, float *y, OmegaGpuBf16Info *info, 237 OmegaGpuCmdList *rec, uint64_t dev_x, uint64_t dev_y, uint32_t xrows, uint32_t xbatch, uint32_t ystride, 238 uint64_t mask_hi, uint64_t mask_tau) { 239 uint64_t t0 = omega_gpu_session_now_ns(); 240 if (info) memset(info, 0, sizeof *info); 241 if (rec && (!dev_x || !dev_y)) return OMEGA_GPU_BF16_BAD_ARGS; 242 if (!t || !t->w.cpu || (!rec && ((!x32 && !x16) || !y))) return OMEGA_GPU_BF16_BAD_ARGS; 243 const uint32_t n = t->n, k = t->k; 244 if (xrows && (!rec || xrows > 65535u)) return OMEGA_GPU_BF16_BAD_ARGS; /* the ROWS form is record-only */ 245 OmegaBf16GemvSpec spec; uint32_t ctas; spec_for(k, &spec, &ctas); 246 if (xrows) spec.ystride = n; 247 const int masked = mask_hi != 0; 248 if (masked && (!rec || xrows || xbatch > 1u || !mask_tau)) return OMEGA_GPU_BF16_BAD_ARGS; /* the MASK form is record-only */ 249 if (masked) { spec.rows = 1; spec.mask = 1; if (g_mask_mutant) spec.mutant = g_mask_mutant; } /* one row per warp: each row's bits are the plain kernel's */ 250 if (xbatch > 1u) { /* XBATCH form (record-only): xbatch x rows share every weight read; y row m at y + m * ystride f32 */ 251 if (!rec || xrows || xbatch > OMEGA_BF16_MAX_XBATCH || ystride < n) return OMEGA_GPU_BF16_BAD_ARGS; 252 spec.xbatch = xbatch; spec.ystride = ystride; 253 xbatch_fit_depth(&spec); 254 } 255 if (n % spec.rows) return OMEGA_GPU_BF16_CODEGEN_FAIL; 256 const uint32_t RG = n / spec.rows; 257 uint32_t grid_x = (RG + spec.warps - 1) / spec.warps; 258 if (grid_x > ctas) grid_x = ctas; 259 if (grid_x == 0) grid_x = 1; 260 261 if (!rec) omega_gpu_session_lock(); 262 #define UNLOCK() do { if (!rec) omega_gpu_session_unlock(); } while (0) 263 int rc = OMEGA_GPU_BF16_OK; 264 if (!dev_open_locked()) { UNLOCK(); return OMEGA_GPU_BF16_CHIP_FAIL; } 265 if (!rec) { 266 int src = omega_gpu_session_scratch(&g.x_buf, (size_t)k * 4u); 267 if (src == 0) src = omega_gpu_session_scratch(&g.y_buf, (size_t)n * 4u); 268 if (src != 0) { UNLOCK(); return src == OMEGA_GPU_SESSION_SCRATCH_RESERVED ? OMEGA_GPU_BF16_TOO_LARGE : OMEGA_GPU_BF16_CHIP_FAIL; } 269 } 270 Slot *ks = NULL; bool hit = false; 271 g_rec = rec != NULL; 272 rc = kernel_for(&spec, &ks, &hit); 273 g_rec = 0; 274 if (rc != OMEGA_GPU_BF16_OK) { UNLOCK(); return rc; } 275 276 float *xd = g.x_buf.mem.cpu, *yd = g.y_buf.mem.cpu; 277 if (!rec) { 278 if (x32) memcpy(xd, x32, (size_t)k * 4u); 279 else for (uint32_t i = 0; i < k; i++) { uint32_t b = (uint32_t)x16[i] << 16; memcpy(&xd[i], &b, 4); } 280 for (size_t i = 0; i < n; i++) yd[i] = POISON_F32; 281 if (omega_gpu_session_sync_to_gpu(&g.x_buf.mem) != 0 || omega_gpu_session_sync_to_gpu(&g.y_buf.mem) != 0) rc = OMEGA_GPU_BF16_CHIP_FAIL; 282 } 283 284 uint32_t args[OMEGA_BF16_MASK_ARGS_WORDS]; 285 const uint64_t x_va = rec ? dev_x : g.x_buf.mem.va, y_va = rec ? dev_y : g.y_buf.mem.va; 286 args[0] = (uint32_t)t->w.va; args[1] = (uint32_t)(t->w.va >> 32); 287 args[2] = (uint32_t)x_va; args[3] = (uint32_t)(x_va >> 32); 288 args[4] = (uint32_t)y_va; args[5] = (uint32_t)(y_va >> 32); 289 args[6] = RG; args[7] = grid_x * spec.warps; 290 args[8] = (uint32_t)mask_hi; args[9] = (uint32_t)(mask_hi >> 32); args[10] = (uint32_t)mask_tau; args[11] = (uint32_t)(mask_tau >> 32); 291 if (info) { 292 info->n = n; info->k = k; info->rows_per_warp = spec.rows; info->warps_per_cta = spec.warps; info->depth = spec.depth; 293 info->grid_x = grid_x; info->steps = omega_bf16_gemv_steps(&spec); 294 info->weight_bytes = (uint64_t)n * k * 2u; 295 info->kernel_cache_hit = hit; 296 (void)omega_gpu_fmt(info->target_chip, sizeof info->target_chip, "%s", "NVIDIA DGX Spark (Grace Blackwell GB10)"); 297 info->sm_architecture = 121; 298 } 299 if (rc == OMEGA_GPU_BF16_OK) { 300 OmegaGpuLaunch L = { 301 .code_va = ks->code.va, .gpr_count = gpr_declared(ks->kernel.gpr_count), 302 .threads_x = 32u * spec.warps, .threads_y = 1, .grid_x = grid_x, .grid_y = xrows ? xrows : 1u, 303 .num_elements = (size_t)n * (xrows ? xrows : xbatch > 1u ? xbatch : 1u), 304 .args = args, .n_args = masked ? OMEGA_BF16_MASK_ARGS_WORDS : OMEGA_BF16_ARGS_WORDS, .timeout_ms = MARKER_TIMEOUT_MS, 305 .shared_bytes = omega_bf16_gemv_shared_bytes(&spec), 306 }; 307 if (!omega_bw_gpr_declared_ok(L.gpr_count, ks->kernel.gpr_count)) { omega_gpu_session_set_error("declared registers below peak + 2: refusing to launch"); rc = OMEGA_GPU_BF16_CHIP_FAIL; } 308 else if (rec) { if (omega_gpu_cmdlist_add(rec, &L) < 0) rc = OMEGA_GPU_BF16_CHIP_FAIL; } 309 else if (omega_gpu_session_launch(&L, info ? &info->elapsed_ns : NULL, info ? &info->completion_marker : NULL) != 0) rc = OMEGA_GPU_BF16_CHIP_FAIL; 310 } 311 if (rc == OMEGA_GPU_BF16_OK && !rec && omega_gpu_session_sync_to_cpu(&g.y_buf.mem) != 0) rc = OMEGA_GPU_BF16_CHIP_FAIL; 312 if (rc == OMEGA_GPU_BF16_OK && !rec) { 313 size_t unchanged = 0; 314 for (size_t i = 0; i < n; i++) if (yd[i] == POISON_F32) unchanged++; 315 if (unchanged) { omega_gpu_session_set_error("output poison survived"); rc = OMEGA_GPU_BF16_CHIP_FAIL; } 316 else memcpy(y, yd, (size_t)n * sizeof *y); 317 } 318 UNLOCK(); 319 if (info) info->call_ns = omega_gpu_session_now_ns() - t0; 320 return rc; 321 } 322 #undef UNLOCK 323 324 int omega_gpu_bf16_gemv_f32(const OmegaGpuBf16Tensor *t, const float *x, float *y, OmegaGpuBf16Info *info) { return gemv_core(t, x, NULL, y, info, NULL, 0, 0, 0, 0, 0, 0, 0); } 325 int omega_gpu_bf16_gemv_bf16(const OmegaGpuBf16Tensor *t, const uint16_t *x, float *y, OmegaGpuBf16Info *info) { return gemv_core(t, NULL, x, y, info, NULL, 0, 0, 0, 0, 0, 0, 0); } 326 327 /* Record path (OWN-30B W-L2a decode graph): see the header. Caller holds omega_gpu_session_lock(). */ 328 int omega_gpu_bf16_gemv_record(OmegaGpuCmdList *cl, const OmegaGpuBf16Tensor *t, uint64_t x_va, uint64_t y_va) { 329 if (!cl) return OMEGA_GPU_BF16_BAD_ARGS; 330 return gemv_core(t, NULL, NULL, NULL, NULL, cl, x_va, y_va, 0, 0, 0, 0, 0); 331 } 332 333 /* ROWS form record path (sc #642 prefill): see the header. Caller holds omega_gpu_session_lock(). */ 334 int omega_gpu_bf16_gemv_rows_record(OmegaGpuCmdList *cl, const OmegaGpuBf16Tensor *t, uint32_t rows, uint64_t x_va, uint64_t y_va) { 335 if (!cl || rows == 0) return OMEGA_GPU_BF16_BAD_ARGS; 336 return gemv_core(t, NULL, NULL, NULL, NULL, cl, x_va, y_va, rows, 0, 0, 0, 0); 337 } 338 339 /* MASK form record path (HUM L314 exact head): see the header. Caller holds omega_gpu_session_lock(). */ 340 int omega_gpu_bf16_gemv_mask_record(OmegaGpuCmdList *cl, const OmegaGpuBf16Tensor *t, uint64_t x_va, uint64_t y_va, uint64_t hi_va, uint64_t tau_va) { 341 if (!cl || !hi_va || !tau_va) return OMEGA_GPU_BF16_BAD_ARGS; 342 return gemv_core(t, NULL, NULL, NULL, NULL, cl, x_va, y_va, 0, 0, 0, hi_va, tau_va); 343 } 344 /* XBATCH form record path (the lm_head of several conversations in one stroke): see the header. Caller holds the lock. */ 345 int omega_gpu_bf16_gemv_xbatch_record(OmegaGpuCmdList *cl, const OmegaGpuBf16Tensor *t, uint32_t xbatch, uint64_t x_va, uint64_t y_va, uint32_t ystride) { 346 if (!cl || xbatch == 0) return OMEGA_GPU_BF16_BAD_ARGS; 347 if (xbatch == 1u) return gemv_core(t, NULL, NULL, NULL, NULL, cl, x_va, y_va, 0, 0, 0, 0, 0); 348 return gemv_core(t, NULL, NULL, NULL, NULL, cl, x_va, y_va, 0, xbatch, ystride, 0, 0); 349 }