interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / evidence / FLASH-NEXT-MOE-SHAPES-20261118 / shape_probe.c

56 lines · 4625 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2/* Before/after table: which Qwen3.8-Flash-Next MoE shapes each unit accepts (0 = accepted, other = the unit's refusal code).
3 * Host only; no device. Same program ran at base 997e1050 (legacy units only, `--base`) and at the branch head. */
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include "cudapp_native.h"
8#include "omega_gpu_fp8_api.h"
9#include "omega_blackwell_codegen_moe.h"
10#include "omega_blackwell_codegen_dec.h"
11#include "omega_blackwell_codegen_router.h"
12static uint64_t lids[1024], ids[1280], work[12672], seg[2052], maps[2832], meta[8];
13static uint64_t lwork[10368], lseg[1028], lmaps[2320];
14int main(void) {
15 uint64_t r;
16 for (unsigned i = 0; i < 1280; i++) ids[i] = (i * 37u) % 512u;
17 memset(lwork, 0, sizeof lwork); r = 99;
18 { uint64_t cfg[8] = {1,1,10,512,512,1408,513,1416};
19 printf("plan legacy slots10 experts512: unit rc=%u result=%llu\n", omega_moe_plan(&r,cfg,8,lids,1024,lwork,10368,lseg,1028,lmaps,2320,meta,8), (unsigned long long)r); }
20 for (unsigned i = 0; i < 1024; i++) lids[i] = (i * 37u) % 256u;
21 { uint64_t cfg[8] = {1,1,8,256,256,1152,257,1160}; r = 99;
22 printf("plan legacy slots8 experts256: unit rc=%u result=%llu (the shape it serves)\n", omega_moe_plan(&r,cfg,8,lids,1024,lwork,10368,lseg,1028,lmaps,2320,meta,8), (unsigned long long)r); }
23#ifndef BASE
24 { uint64_t cfg[8] = {2,1,10,512,512,1408,513,1416}; r = 99;
25 printf("plan wide slots10 experts512: unit rc=%u result=%llu work=%llu segments=%llu\n", omega_moe_plan_wide(&r,cfg,8,ids,1280,work,12672,seg,2052,maps,2832,meta,8), (unsigned long long)r, (unsigned long long)meta[0], (unsigned long long)meta[1]); }
26#endif
27 uint64_t w[8] = {1,11,2560,640,11,512,128,0}; static uint64_t win[1024], wm[4]; r = 99;
28 printf("windows legacy H2560 EI640 c11: unit rc=%u result=%llu\n", omega_moe_windows(&r,w,8,win,1024,wm,4), (unsigned long long)r);
29#ifndef BASE
30 r = 99; printf("windows wide H2560 EI640 c11: unit rc=%u result=%llu windows=%llu rows=%llu\n", omega_moe_windows_wide(&r,w,8,win,1024,wm,4), (unsigned long long)r, (unsigned long long)wm[0], (unsigned long long)wm[2]);
31#endif
32 uint64_t q[16] = {4096,8192,12288,65536,131072,196608,262144,512,11,126,134,11,1,1,1,512}; uint8_t words[64]; r = 99;
33 printf("group legacy slots11 shared512: unit rc=%u result=%llu\n", omega_moe_group(&r,q,16,words,64), (unsigned long long)r);
34#ifndef BASE
35 r = 99; printf("group wide slots11 shared512: unit rc=%u result=%llu\n", omega_moe_group_wide(&r,q,16,words,64), (unsigned long long)r);
36#endif
37 struct { uint32_t k, n, g; const char *name; } cases[] = { {2560,1280,10,"gate+up"}, {640,2560,10,"down"} };
38 for (unsigned i = 0; i < 2; i++) {
39 OmegaFp8GemvSpec s; omega_gpu_fp8_spec_for(cases[i].k, cases[i].n, cases[i].g, &s);
40 BlackwellIRProgram *p = calloc(1, sizeof *p);
41 printf("fp8 %-8s k=%u n=%u: lane_bytes %u warps %u plain kernel: steps %u build %d", cases[i].name, cases[i].k, cases[i].n, s.lane_bytes, s.warps, omega_fp8_gemv_steps(&s), omega_blackwell_codegen_fp8_gemv_prog(&s, p));
42#ifndef BASE
43 printf("; ragged kernel: steps %u build %d, used by device/record form %d, by host-staged form %d", omega_fp8_gemv_ragged_steps(&s), omega_blackwell_codegen_fp8_gemv_ragged_prog(&s, p), omega_gpu_fp8_ragged_for(&s, 1), omega_gpu_fp8_ragged_for(&s, 0));
44#endif
45 printf("\n"); free(p);
46 }
47 OmegaDecSpec d; memset(&d, 0, sizeof d); BlackwellIRProgram *p = calloc(1, sizeof *p);
48 d.kind = OMEGA_DEC_GROUP; d.groups = 11; printf("dec GROUP slots=11: build %d (kernel is shape-generic; simulator test: tests/codegen_dec_group_sim_test.c)\n", omega_blackwell_codegen_dec_prog(&d, p));
49 memset(&d, 0, sizeof d); d.kind = OMEGA_DEC_RES; d.mode = 2; d.width = 2048; d.groups = 11; printf("dec RES COMBINE groups=11 w2048: build %d (NOT in this slice)\n", omega_blackwell_codegen_dec_prog(&d, p));
50 memset(&d, 0, sizeof d); d.kind = OMEGA_DEC_RES; d.mode = 2; d.width = 2560; d.groups = 9; printf("dec RES COMBINE groups=9 w2560: build %d (NOT in this slice)\n", omega_blackwell_codegen_dec_prog(&d, p));
51 OmegaRouterSpec rs; memset(&rs, 0, sizeof rs); rs.warps = 32; rs.depth = 4; rs.experts = 512; rs.shared = 1;
52 printf("router experts=512 shared: build %d (NOT in this slice)\n", omega_blackwell_codegen_router_prog(&rs, p));
53 rs.experts = 256; printf("router experts=256 shared (twin): build %d\n", omega_blackwell_codegen_router_prog(&rs, p));
54 free(p);
55 return 0;
56}