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_blackwell_codegen_moe2.h # 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_blackwell_codegen_moe2.h` 73 lines ยท 4158 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 #ifndef OMEGA_BLACKWELL_CODEGEN_MOE2_H 18 #define OMEGA_BLACKWELL_CODEGEN_MOE2_H 19 /* 20 * omega_blackwell_codegen_moe2: FP8 (e4m3) block-scaled GEMV, variant 2 ("row-pipelined"), OWN-30B 21 * W-L2c (2026-10-14). New file: omega_blackwell_codegen_moe.{c,h} (variant 1) are untouched; the API 22 * (omega_gpu_fp8_api.c) selects the variant (omega_gpu_fp8_set_variant / AIEN_OMEGA_FP8_GEMV=2). 23 * 24 * Same contract as variant 1 (same OmegaFp8GemvSpec, argument words, grid, thread mapping, lane 25 * mapping, group table, x' / S' folding, mutants) and the SAME ARITHMETIC ORDER per output row: 26 * per lane, per K step: dot = FFMA chain over its lane_bytes weights (word 0..W-1, byte 0..3); 27 * acc_r = fma(dot, S'_step, acc_r) in K order; then SHFL.DOWN 16, 8, 4, 2, 1 with FADD. 28 * so y is bit-identical to variant 1 for every input (checked by the simulator battery and on the chip). 29 * 30 * What changes is only WHEN the loads are issued (bytes in flight per warp): 31 * - a warp's unit of work is a whole row group (rows x k bytes): every weight load and scale load of 32 * the row group is issued back to back (rows * KS LDG.E.64/128 + KS scale words per lane); 33 * - two register sets: while the warp decodes and multiplies row group i (set A), the loads of row 34 * group i + stride (set B) are already in flight on their own scoreboard (SB3). Set A is filled by 35 * register moves from set B after a single wait on SB3, so the arithmetic never waits on the loads 36 * of the next row group (variant 1 waits for every load of a step before using any of them, and has 37 * nothing in flight while it computes); 38 * - x' (the activation row, shared by every row of the group) is staged once per CTA in shared memory 39 * (variant 1's deep-kernel staging, BAR.SYNC) and read per word with LDS.128 (4 registers), so the 40 * global loads a lane keeps in flight are weights and scales only. 41 * Register sets: 2 x (rows * KS * lane_bytes / 4 + KS) registers, plus ~30. The spec is refused unless 42 * rows * KS * lane_bytes <= 128 (instruction and register budgets) and k <= 512 * warps (staging rounds). 43 * The register-file rule (32 * warps * declared <= 65536) is checked by the API as for variant 1; the 44 * intended shapes are 16 warps per CTA (two CTAs per SM) at the OWN-30B widths k = 768, 2048, 4096. 45 * 46 * spec->depth is ignored (the whole row group is always in flight); spec->mutant 1, 2, 3 as variant 1. 47 */ 48 #include 49 #include "omega_blackwell_codegen_moe.h" 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 55 /* 0 on success (prog solved and register-allocated), -1 on a refused spec or an allocator failure. */ 56 int omega_blackwell_codegen_fp8_gemv2_prog(const OmegaFp8GemvSpec *spec, BlackwellIRProgram *prog); 57 58 /* 1 if the spec is one this variant builds (shape rules above), 0 otherwise. */ 59 int omega_fp8_gemv2_spec_ok(const OmegaFp8GemvSpec *spec); 60 61 /* Shared memory bytes the launch must declare: k * 4 (the staged x' row) + 16 (a dummy slot, only when the last staging round is partial). 0 when refused. */ 62 uint32_t omega_fp8_gemv2_shared_bytes(const OmegaFp8GemvSpec *spec); 63 64 /* Hosted build: allocate and encode (omega_blackwell_kernel_free releases). */ 65 int omega_blackwell_codegen_fp8_gemv2(const OmegaFp8GemvSpec *spec, OmegaBlackwellKernel *kernel); 66 67 /* The IR instruction count and peak GPR count of the solved program (for budgets in tests). */ 68 int omega_fp8_gemv2_prog_stats(const OmegaFp8GemvSpec *spec, uint32_t *insns, uint32_t *gprs); 69 70 #ifdef __cplusplus 71 } 72 #endif 73 #endif