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/CUDApp/issues/3d7515f05a3e820c # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers # [CUDA++→MAX UPSTREAM P0] Prepare human-reviewed Modular sm_121 kernel contribution and CUBIN HAL integration Open · #69 · open 2026-10-24 03:11 UTC Imported from GitHub aien-dev/CUDApp#69, by drakestapleton drakestapleton wrote on 2026-10-24 03:11 UTC ## Objective — upstream contribution to Modular MAX from CUDApp/Omega User direction (2026-10-23): make code contributions to https://github.com/modular/modular that allow NVIDIA GPUs to execute as fast as or faster than NVIDIA CUDA-based baselines, without dropping correctness, portability, sovereignty or provenance. This issue coordinates upstreamable implementation, not merely an interoperability whitepaper. Parent https://github.com/aien-dev/omega-mv/issues/679 ; CUDApp #68 native artifact export; Bridge #4/#6/#7 MAX ABI work; Omega #680/#681 contracts/verification. ## Source-grounded findings (2026-10-23) - MAX has an existing CUBIN loading/execution surface: `SDK/include/HAL/M_driver_bundle.h` (`M_driver_static_bundle`, `M_driver_bundle_load`), `SDK/include/HAL/M_driver_function.h`, `Target/lib/CUDA/M_driver_function.cpp`, `max/driver/src/max_license/_hal/context.mojo` (NVIDIA bundle type `cubin`), `Target/test/CUDAPluginTest.cpp`; the new NeoDriver client is incubating, MAX still uses legacy DeviceContext by default. Read `max/driver/src/max_license/README.md`. Therefore do not reverse-engineer an already exposed kernel loader. First requirement is producing a valid relocatable/loadable NVIDIA CUBIN code object, not passing raw 16-byte SASS instructions as a CUBIN. - CUDApp `src/omega_blackwell_matmul.h` currently exposes `OmegaBlackwellKernel.code`, `code_digest`, `gpr_count`; `src/omega_blackwell_qmd.h` describes direct low-level launch. MAX owning CUDA contexts/queues means never inject Omega QMD or reuse the direct native device VA/queue. Model semantic+launch metadata -> MAX-owned CUBIN/function launch arguments and barriers. - MAX 26.7's NVIDIA path continues using vendor `libcuda` at runtime and `libnvptxcompiler` when compiling PTX; a CUDApp-produced CUBIN can potentially bypass the latter for that kernel, but does not imply all MAX execution is CUDA-free. - Consumer Blackwell upstream tracker https://github.com/modular/modular/issues/6570 invites help for sm_120/sm_121. `#6961` VMM capability problem appears already fixed in current source (`MLRT/lib/Driver/DeviceContext/CUDA/CUDADeviceContext.cpp` tests GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED). No duplicate PR without latest-version repro. - Current CUDApp source AGPL-3.0-only, archived MIT grant at commit `232332422bfdc31c8918085b50f13c1e18ab702e`; upstream MAX kernels Apache 2.0/LLVM, MAX driver under MAX License. Audit each line and require rights holder's explicit compatible relicensing of any post-MIT first-party code before porting/including. Do not blindly copy AGPL source into Apache files. - Modular contribution rules `CONTRIBUTING.md`, `max/kernels/CONTRIBUTING.md`, `max/docs/contributing/contribution-areas.md`: only bug fixes currently accepted in many areas; substantive new backend/kernel features require maintainer-approved issue first. `AI_TOOL_POLICY.md`: AI-assisted patches/issues require human review and human submission, no fully autonomous agent posts to their project. GitHub connector has no push permission to modular/modular and no fork creation action; no fork/PR has been created. ## Workstreams / acceptance - Pick one verifiable Blackwell regression/missing primitive or proven hotspot tied to a still-reproducible upstream issue, preferably #6570. Pin MAX version and source. Demonstrate correctness and a real performance deficiency rather than hypothesize. - Implement and host-qualify a versioned CUDApp `sm_121` native-code to valid CUBIN module packager/exporter with entry symbol, arg ABI, registers, shared memory, metadata, linking requirements, and architecture; inspect independently (ELF/load checker). Raw `OmegaBlackwellKernel.code` is not a module. Treat new packaging as CUDApp #68 dependency; don't add NVIDIA compiler to the native producer path. - Adapt to existing MAX HAL bundle/function with MAX-owned memory and streams; introduce no duplicate driver. Prove expected refusals for invalid arch, malformed cubin, stale code, wrong ABI, buffer owner mismatch, launch layout, sync hazards. Stage first under user-owned repositories with tests. - Compare single-kernel/whole-graph baselines vs MAX unmodified, NVIDIA CUDA library kernel, and CUDApp native on same GB10, same dtype/layout/shape, equivalent accuracy, memory residency, graph capture, cold/warm, synchronization, p50/p95 and energy if instrumented. >=5 randomized paired trials in approved Spark window. Physical peak and sustained throughput measured; no blanket faster-than-CUDA claim without proof. - Prepare a small upstream first PR for a reproducible bug fix / missing sm_121 intrinsic or library regression, with a test + kbench benchmark, and a separate, reviewable future proposal for optional external CUBIN artifact provider. No giant drop of the AGPL runtime or replacement of CUDA stack. - Secure human author review of the code and AI-assisted description, source provenance and license grants, then user creates/links a fork and submits an upstream issue for maintainer acceptance. Do not autonomously post issues, PRs or comments to Modular under their AI Tool Use Policy. If no fork, remain READY_FOR_HUMAN_SUBMISSION with exact patch/commit/repro. - Gate upstream readiness by actual build/test/reviewer evidence and exact commit hashes; the current issue is design-and-contribution coordination only, NOT IMPLEMENTED. No live model or driver changes and no unauthorized GPU reset. Final AIEN-owned production source must follow Omega #599 .om replacement; modular-facing Mojo/C++ extension remains an external-system artifact with explicit separate licensing. ## Required PR set PR-0 small accepted bug fix or missing primitive on sm_121, independently benchmarked. PR-1 optional native CUBIN artifact acceptance/validation through existing MAX HAL, only after approved proposal. PR-2 bounded matmul/attention improvement/conformance and evidence, after PR-1 and numerical parity. Do not broaden PR-0 to an entire competing runtime. did:key:`z6MkhL6jkVBvyZTg9eMGkJWKQKjnKA1wbA7ym3PkTXt4M6Jd` wrote on 2026-11-18 17:12 UTC Recovered GitHub comment by @aien-spark on 2026-10-24T04:00:15Z. Original comment `6379592938` Partial on `feat/max-artifact-export` @ `fcd7d24`; the load half is blocked by the pinned release. - We can produce a valid cubin container offline (`cuobjdump`/`nvdisasm` accept it), but `max/v26.7.0` (`527d069e…`) exposes no byte-safe native-module entry on its public Python path: `load_function` takes a UTF-8 `String` and only PTX is exercised. The HAL path that accepts a cubin is main-branch, non-production and not reachable from the released package. - The exported artifact is the input a MAX loader would consume: `8dcc18e0…` with manifest, text/cubin digests and launch metadata. - We did not patch MAX or bypass the context: no cross-context pointer or private HAL call was used. - GPU load/run remains NOT_RUN (chip reserved). Concrete unblocker: a byte-slice module-load API in the release with MAX-owned context/queue/allocation, or authorization to test MAX `main`. RFC: `omega-bridge/docs/MAX-INTEGRATION.md`. did:key:`z6MkhL6jkVBvyZTg9eMGkJWKQKjnKA1wbA7ym3PkTXt4M6Jd` wrote on 2026-11-18 17:21 UTC Recovered GitHub comment. Original comment `6534637213` Correction + pin (2026-10-30, maxinterop lane). Status: source-read and host-only; no device run behind this comment. - "Only PTX is tested" is wrong. At the release pin `max/v26.7.0` = `527d069e`: - `max/mojo/max/gpu/host/device_context.mojo:4294` defines `DeviceExternalFunction`. Its constructor (`:4381-4434`) passes `asm` with an explicit byte length to `AsyncRT_DeviceContext_loadFunction`, so cubin bytes go through. - Upstream tests cubins from Mojo (`max/kernels/test/gpu/device_context/test_device_external_function.mojo`) and from Python graph custom ops (`kernel_verification_ops` `op_with_external_cubin`, driven by `max/tests/integration/tensor/test_functional_custom_gpu.py:35,90`). - It has been in the release notes since v26.5 (`v26.5.md:582-585`). - Coverage is sm80/90/100 only. sm_121 is not in upstream's matrix. - On main `8ed65fc6` the implementation moved to `max/mojo/max/gpu/host/_legacy/device_context.mojo` (`3cec4f74`). It has the same C ABI and a new default target, `default_accelerator()`. - The HAL Driver SDK (`SDK/include/HAL/M_driver_bundle.h`) is main-only, MAX-License, experimental. It is in no release. It is the subject of Gate 5, not the first handoff. - The licence inventory is Gate 1, in `~/handoffs/max-g2/gate1/` (to be committed with CUDApp#202). - The pin has no MAX-License source outside `Licenses/`. - The AI clause is pin §1.3(d) and main §1.4(d). It forbids AI use of MAX to build a substitute for MAX and allows interop. - CUDApp main is Apache-2.0 WITH LLVM-exception, so the AGPL concern in the opening comment no longer applies. Plan: `~/handoffs/max-g2/PLAN.md` (posted on omega-mv#679). Sign in to comment