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_pattn256.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_blackwell_codegen_pattn256.c` 65 lines ยท 2702 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_blackwell_codegen_pattn256.c: causal prefill attention for Qwen3.8-27B on tensor cores. 18 * Implementation lives in pure OM-2 (om/gpu/cg_pattn256.om); this file is the thin fail-closed C ABI wrapper. */ 19 #include "omega_blackwell_codegen_pattn256.h" 20 #include "omega_bw_om_ir.h" 21 #include "omega_native.h" 22 #include 23 24 static void pattn256_pack_spec(const OmegaPrefillAttn256Spec *s, uint64_t sp[4]) { 25 memset(sp, 0, 4u * sizeof(uint64_t)); 26 sp[0] = (uint64_t)(int64_t)s->mutant; 27 sp[1] = s->q_heads; 28 sp[2] = s->kv_heads; 29 } 30 31 int omega_pattn256_shape(const OmegaPrefillAttn256Spec *spec, OmegaPattn256Shape *s) { 32 if (!spec || !s) return -1; 33 const uint32_t qh = spec->q_heads ? spec->q_heads : 24u, kvh = spec->kv_heads ? spec->kv_heads : 4u; 34 if (kvh == 0 || qh % kvh || qh / kvh > 8u) return -1; 35 s->qh = qh; s->kvh = kvh; s->group = qh / kvh; s->out_words = qh * 256u; s->qf_pair_bytes = qh * 1024u; 36 return 0; 37 } 38 39 int omega_pattn256_spec_ok(const OmegaPrefillAttn256Spec *s) { 40 if (!s) return 0; 41 uint64_t sp[4], ok = 0; 42 pattn256_pack_spec(s, sp); 43 if (omega2_cg_pattn256_spec_ok(&ok, sp, 4u) != 0) return 0; 44 return ok != 0 ? 1 : 0; 45 } 46 47 int omega_blackwell_codegen_prefill_attn256_prog(const OmegaPrefillAttn256Spec *spec, BlackwellIRProgram *prog) { 48 if (!prog) return -1; 49 omega_bw_ir_init(prog); 50 if (!spec) return -1; 51 uint64_t sp[4], ins[8192], meta[512], rc = 1; 52 memset(ins, 0, sizeof ins); 53 memset(meta, 0, sizeof meta); 54 pattn256_pack_spec(spec, sp); 55 if (omega2_cg_pattn256_emit(&rc, sp, 4u, ins, 8192u, meta, 512u) != 0 || rc != 0) return -1; 56 return omega_bw_ir_from_om_limit(ins, meta, prog, BW_PHYS_GPR_HW_LIMIT); 57 } 58 59 int omega_prefill_attn256_prog_stats(const OmegaPrefillAttn256Spec *spec, uint32_t *insns, uint32_t *gprs) { 60 static BlackwellIRProgram p; 61 if (omega_blackwell_codegen_prefill_attn256_prog(spec, &p) != 0) return -1; 62 if (insns) *insns = (uint32_t)p.count; 63 if (gprs) *gprs = p.regalloc.peak_gpr_usage; 64 return 0; 65 }