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 / docs / ARCHITECTURE.md

154 lines · 13257 bytes Raw Blame History Source

CUDApp architecture: today's layers and the portable-top / thin-backend split

Status: PROPOSED design (2026-10-27). Only the host-side pieces listed in §3a are implemented. No code moves until the gate below is met. The decision record is ADR 0043 in aien-dev/aien-architecture-mv (docs/adr/0043-gpu-stack-portable-top-thin-backend.md, draft). Read that first; this file is the file-level map for CUDApp at main 780a0af1.

Companions, not repeated here: docs/runtime/PORTABILITY.md and portability_table.tsv (per-file chip and OS binding, checked by make test-runtime-portability; this file agrees with its finding that the session, command list and kernel APIs hide the driver but not the GPU). PORTABILITY.md cites docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md and OMEGA_GPU_ENGINE.md; those live in omega-mv (present on omega-mv main e5b32567), not in this repo.

Gate. Work under this design starts after P0 publishes a same-box head-to-head and bars C2–C5 are QUALIFIED on the GB10 (GPU-stack plan, phases P2–P4).

Language. Existing C stays where it is and is not reworked. New host-runtime code, every new backend and the backend ABI are written in Omega (.om). Any new C needs a missing-feature reason with an Omega extension proposal filed, behind a migration-pending build switch.

1. Target layers

 Omegese kernels ──► kernel IR + checker2 (omega-mv, pinned)
                          │ per-target lowering
 ┌──────────────── portable top (.om, CUDApp) ───────────────────┐
 │ model graphs, decode scheduling, batching, serving, memory      │
 │ planner (weights, KV pool, scratch), streams/events, sharing,   │
 │ watchdog policy, public runtime API                             │
 └───────────────────────┬────────────────────────────────────────┘
              OmegaBackend ABI 2.0: 30 calls (backend/abi.om)
 ┌────────────┬────────────┬─────────────┬───────────┬───────────┐
 │ gb10       │ amd        │ vulkan      │ metal     │ cpu-ref   │
 │ sm_121     │ gfx942 /   │ SPIR-V      │ MSL text  │ AArch64   │
 │ nvrm + UVM │ gfx1151    │ (loader:    │ (needs    │ CI and    │
 │ QMD/PB     │ KFD + AQL  │ needs E2)   │ E2)       │ negative  │
 │            │ (needs E1) │             │           │ controls  │
 └────────────┴────────────┴─────────────┴───────────┴───────────┘
 Integrations (omega-bridge connected repos): ggml-omega, vLLM platform plugin, ORT plugin EP

E1, E2 and E3 are the Omega extension proposals named in ADR 0043: E1 a KFD devctl allowlist, E2 checked shared-library calls and Mach-O output, E3 IR v7 (subgroup width, shared budget, nesting cap and accuracy class as target parameters; address spaces, atomics, f16/bf16/fp8, one tiled MMA op), filed as aien-dev/omega-mv#883.

2. Where today's files sit

Classes: TOP portable; ENC encoder, QMD, pushbuffer words; KER tuned sm_121 kernel generators; DRV driver client; MIXED has to be split logically. Line numbers are at 780a0af1.

ClassFiles
TOPomega_core, omega_canonical, omega_types.h, omega_vector, sha256, omega_runtime_api.h, omega_gpu_platform.{c,h} (interface), omega_gpu_engine (interface), omega_gpu_wait, omega_gpu_mem_cached, omega_gpu_serving, omega_gpu_chip, omega_gpu_hostmath, omega_gpu_fmt
ENComega_blackwell_codegen.{c,h} core (BlackwellIR, regalloc, encode), omega_blackwell_encoder, omega_blackwell_qmd, omega_bw_em.h, omega_bw_em_q.h, omega_bw_reconv.h, omega_gpu_code_alloc.h, omega_cubin, omega_blackwell_realize, omega_blackwell_matmul
KERomega_blackwell_codegen_{attn,bf16,dec,gemm,moe,moe2,pattn,pf,pfhost,qg,qmma,router,tc,tc2,tern}, the matmul generators inside omega_blackwell_codegen.c, omega_gpu_fp8_pack.c, omega_gpu_pfgemm.c
DRVnvrm/ (nvrm.c 908 lines, RM client against the 580.173.02 headers), m16/, omega_gpu_platform_linux.c, omega_blackwell_engine.c, omega_blackwell_submit.c
MIXEDomega_gpu_session.c (QMD and pushbuffer construction in omega_gpu_session_launch :445; includes qmd/submit :18-19), omega_gpu_cmdlist.c (emit_tail :199, emit_stamp :219, emit_inline_qmd :226, PCAS method words :308-309), omega_native_artifact.c (packaging is TOP, QMD template bytes are ENC), every omega_gpu_*_api.c (tensor lifetime is TOP; inline emitters in attention_api.c :69-143 and elementwise_api.c :61-145 are KER)
Already .omnative/nvrm/context.om, native/blackwell/{trace-emit,trace,vector,launch}.om; in the default hosted build: om/encoder/bw_enc_sm121.om, om/cubin/cubin_elf.om, om/encoder/ampere_enc_sm86.om, om/encoder/amp_runtime.om and the aien-gpu platform's decisions and request bytes, native/aiengpu/context.om (CUDApp#128; its effects stay migration-pending C). om/units.sh emits separate portable src/cudapp_om_*.c units through the pinned omega-bridge, with source-to-C provenance in src/cudapp_om_units.ident. No AArch64 executable-code trampoline is needed on x86. Historical C encoder/cubin bodies remain only for freestanding or differential-oracle switches. Ampere qualification is NOT_RUN.

Three structural defects the split removes (in the .om stack; the C stack is frozen, not reworked):

  1. Two backend tables over one driver client. OmegaGpuPlatform 1.2 (omega_gpu_platform.h, 22 function pointers) under session and cmdlist; OmegaGpuBackend (omega_gpu_engine.h, 15 ops, VECTOR_1D only) under the job engine, installed at omega_blackwell_submit.c:102.
  2. Raw NVIDIA method words cross the seam. queue_submit(words) makes QMD and pushbuffer encoding happen above the backend, in session and cmdlist.
  3. Two bypasses. omega_blackwell_engine.c (:125-516) and omega_blackwell_submit.c (:185-328) call nvrm_* and m16_native_* directly.

3. The backend ABI (30 calls)

The full contract table, with today's GB10 function for each call, is in ADR 0043 Decision 2.

GroupCalls
Negotiate and device (7)ob_negotiate, ob_device_count, ob_device_open, ob_device_close, ob_device_caps, ob_device_status, ob_diag_text
Memory (7)ob_mem_alloc, ob_mem_import_host (zero-copy), ob_mem_free, ob_mem_flush, ob_mem_invalidate, ob_mem_advise, ob_mem_info
Code (3)ob_code_load, ob_code_info, ob_code_free
Queues and dispatch (4)ob_queue_open, ob_queue_close, ob_dispatch, ob_submit
Graphs (4)ob_graph_begin, ob_graph_end, ob_graph_launch (one doorbell per token, patch list), ob_graph_free
Sync and recovery (5)ob_fence_wait, ob_event_record, ob_queue_wait_event, ob_queue_reset, ob_clock_ns

Leaving the backend compared with OmegaGpuPlatform 1.2: time_now_ms/ns, wait_ms, lock, unlock, host_alloc, host_free (the top gets them from Omega host words), mmio_* and irq_wait (NULL on Linux today), queue_submit(words) (replaced by ob_dispatch + ob_submit).

Code-object formats accepted by ob_code_load: SM121_RAW, AMDGPU_HSACO, SPIRV_VK, SPIRV_CL (OpenCL-environment SPIR-V: Kernel capability, Physical64 addressing, for OpenCL runtimes), MSL_SOURCE, AARCH64. CUBIN is reserved and unused. omega-mv #864 (seed/sm80/cubin.om) was closed unmerged; see docs/CUBIN_WRITERS.md.

3a. First pieces that exist (IMPLEMENTED; host EXERCISED; hardware NOT_RUN off the GB10)

PLAN P3 lets multi-target work that needs no GB10 time start before the gate above; no existing file moves. All of it is seeded Omega except one migration-pending C launcher.

PieceFileStatus
Target table, one row per GPU family; make doctor OMC=… prints itbackend/targets.om (targets doctor)IMPLEMENTED. GB10 (sm_121) SUPPORTED; every other GPU row PLANNED, hardware NOT_RUN; PoCL and lavapipe rows are HOST-ONLY (not a GPU)
Code-object loader checks for ob_code_loadbackend/targets.om (targets load FORMAT FILE [ENTRY or gfx])IMPLEMENTED: SPIR-V header, instruction stream, capability/addressing/memory model per environment, entry point; HSACO ELF64, HSA OSABI with code object v4/v5, EM_AMDGPU, e_flags mach, PT_NOTE NT_AMDGPU_METADATA msgpack (amdhsa.target, amdhsa.version, amdhsa.kernels); SM121_RAW shape. MSL_SOURCE and AARCH64 refused (PLANNED), CUBIN refused (reserved)
SPIR-V builder: FP32 vadd and FP32 16-term sum (fsum16), OpenCL and Vulkan forms, plus planted-wrong mutantsbackend/spirv/emit.omIMPLEMENTED; every module passes spirv-val. Hand-built words because the pinned seed omc IR mode lacks the needed floating-point operations. E3 (omega-mv#883) tracks OSC IRv7, a separate compiler path; it does not by itself enable this seed SPIR-V path
Host reference and bit comparebackend/spirv/conform.omIMPLEMENTED; vadd reference digest equals hello_gpu --sim output digest
Launcher that hands a module to PoCL (CPU) or Mesa lavapipe (CPU)tools/multitarget/spirv-host.cmigration-pending C, CUDAPP_MIGRATION_PENDING_SPIRV_HOST default OFF; reason: no checked shared-library call (E2, omega-mv#888); successors backend/opencl/host.om, backend/vulkan/host.om
gfx1151 vadd code objectbackend/amd/vadd-gfx1151.sORACLE fixture assembled by llvm-mc + ld.lld to test the loader (see §6); not a first-party encoder

make test-multitarget OMC=… (tests/multitarget/run.sh) runs all of it with negative controls: corrupted modules fail spirv-val and the loader, wrong environment or entry is refused, planted-wrong kernels and a flipped output byte fail the compare, the launcher's isolation scan fails when told to forbid the CPU driver it loads, and patched HSACO copies (wrong gfx, e_flags, OSABI, ABI version, note type, note target, truncation) are refused. Bit-exact on PoCL and lavapipe means those CPU implementations only; no AMD, Intel, Apple, Qualcomm, Arm, Imagination, Broadcom or Vortex device has run anything (hardware NOT_RUN). A real AMD run next needs a queue: KFD + AQL through E1 (KFD devctl allowlist) or the HSA runtime through E2, on a machine with that GPU.

4. Per-token path, today and target (GB10)

Today (omega_gpu_decode_graph, Qwen3-30B-A3B)Target
Launches per token436 (9 per layer × 48 + 4)same graph
Submissions / doorbells1 / 1 (PCAS mode, cmdlist.c:325-333)1 / 1 via ob_graph_launch
CPU writes per token1 KB constants + 1 KB QMD per launch, ≈872 KiB [INFERENCE]patch list only; QMDs pre-encoded at ob_graph_end
Weightscopied: omega_gpu_fp8_api.c:269-275 memcpy + syncmmapped file mapped by ob_mem_import_host

Every row in the Target column is PROPOSED and needs a paired A/B receipt before it is described as faster.

5. Public API consequences

6. Provenance rules for any backend

7. Review

See docs/REVIEWING.md and .github/CODEOWNERS. GitHub enforces code-owner review only after the default-branch ruleset requires it. That ruleset is Drake's change. @drakestapleton is the only owner until the GPU-core and IP-review teams exist and are added back with write access.