interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / docs / max / MAX-26.7-FEASIBILITY.md

401 lines · 54538 bytes Raw Blame History Source

MAX 26.7.0 Interoperability Feasibility Report

Status: analysis complete for source-level feasibility. No GPU step was executed (see PROBE-PLAN.md). Repository: https://github.com/modular/modular Pinned ref: tag max/v26.7.0 (also mojo/v1.2.0) Pinned commit: 527d069ee11a41ac5320af1f9402db0a66b2b868 Tree: 0d873aea6bafed021bf6033b3904db392778d76d Local checkout: ~/workspace/maxinterop/max-source (HEAD = pinned commit, sparse, blobless clone)

Evidence conventions used below:


1. Headline answer

  1. The pinned v26.7.0 source tree does not contain MAX's hardware-abstraction "bundle/module" path at all. There is no SDK/, Target/, MLRT/, GraphCompiler/, or max/driver/ directory at the pin (evidence/commands/05-path-divergence.txt). Every file named in the task brief is main-only.
  2. At the pin, the only documented route for externally produced device code is the Mojo API max.gpu.host.DeviceContext.load_function(...), whose docstring says it loads "assembly code (PTX/SASS)" and whose sibling enqueue_function launches a DeviceExternalFunction (PIN max/mojo/max/gpu/host/device_context.mojo:5257-5310, :5324-5360). This runs inside a Mojo custom op, so MAX owns the context, allocations, queue and synchronization for that launch. PTX is exercised by a pinned CUDA test (PIN max/mojo/test/asyncrt/test_cuda.mojo:177-186); no pinned test loads a cubin, and the argument type is String with a valid-UTF-8 precondition (PIN Mojo/stdlib/std/collections/string/string.mojo:380-394), so raw CUBIN ingestion is not a byte-safe public contract.
  3. On main, MAX does have the path the brief describes: M_driver_static_bundle (raw bytes + file_type) → M_driver_bundle_load → cuModuleLoadDataEx → M_driver_function_load → cuModuleGetFunction → M_driver_queue_execute → cuLaunchKernelEx → M_driver_queue_synchronize (MAIN SDK/include/HAL/M_driver_bundle.h:39-51,96-101; MAIN Target/lib/CUDA/Function.cpp:68-90,106-131; MAIN Target/lib/CUDA/M_driver_queue.cpp:155-196; MAIN Target/lib/CUDA/Queue.cpp:258-266). The NeoDriver client explicitly sets file_type = "cubin" for NVIDIA targets (MAIN max/driver/src/max_license/_hal/context.mojo:65-78), and the HAL CUDA implementation does not inspect file_type (MAIN Target/lib/CUDA/Function.cpp:68-90). Structurally, a raw CUDApp-produced CUBIN is accepted by that path; no MAX signature or metadata check exists.
  4. sm_121 is a first-class pinned target. The pinned Mojo toolchain maps DGXSpark to sm_121/sm_121a and emits arch = "sm_121a" (PIN Mojo/stdlib/std/_gpu/host/_builtin_targets.mojo:70,477-496); the public hardware-compatibility table lists sm_121 = DGX Spark (PIN max/docs/site/gpu/hardware-compatibility.mdx:81-85).
  5. Nothing here proves arbitrary SASS ingestion, and no hardware was run. Loading a cubin still requires: the cubin be a valid ELF for the device; the entry-point symbol name be known; the kernel obey the CUDA parameter ABI; the CUDA context be the one MAX uses; and, at the pin, a byte-safe transport into load_function. See §8 for the explicit non-claims.
  6. MAX on NVIDIA is not CUDA-free. The main CUDA backend dlopens libcuda.so.1 (MAIN Target/lib/CUDA/Loader/CUDALoader.cpp:37), and the pinned public docs require NVIDIA driver 580 / CUDA 13.0 or later (PIN max/docs/site/gpu/hardware-compatibility.mdx:20-24).

2. Pin and checkout verification

CheckResultEvidence
git rev-parse HEAD527d069ee11a41ac5320af1f9402db0a66b2b868evidence/commands/01-pin-verification.txt
git rev-parse max/v26.7.0^{commit}same oidevidence/commands/01-pin-verification.txt
git cat-file -t max/v26.7.0commit (lightweight tag)evidence/commands/01-pin-verification.txt
git ls-remote tag oid527d069...b868evidence/commands/01b-remote-tag-oids.txt
tree hash0d873aea6bafed021bf6033b3904db392778d76devidence/commands/01-pin-verification.txt
subtree hashesmax 6b05fe51cb5c75113de512ca4e3f39b534faf96a; Licenses 9763f7484ce927796ac686fb2c243b9c49a19077; Support cae6645b0e3c0c26aca10010917010c92bbb1d21evidence/commands/02-tree-hashes.txt
sparse setAsyncRT, Licenses, Mojo/stdlib/std/_gpu, Mojo/stdlib/std/_plugin, Mojo/stdlib/std/sys, Mojo/stdlib/std/collections/string, Support, docs, maxevidence/commands/07-checkout.txt
working treeonly untracked deliverables (FEASIBILITY-REPORT.md, PROBE-PLAN.md, SHA256SUMS, evidence/)evidence/commands/07-checkout.txt

Clone method: git clone --filter=blob:none --no-checkout https://github.com/modular/modular.git, then git fetch --depth=1 origin refs/tags/max/v26.7.0:refs/tags/max/v26.7.0, then sparse checkout and detached checkout of the pinned commit. The clone also contains origin/main, used only for the divergence mapping requested by the task.


3. Divergence: requested paths at the pin vs main

Command output: evidence/commands/05-path-divergence.txt. Main commit: da0db31d422e19ad5952d8d106b6da1d6899cf0a.

Requested pathAt pin 527d069At main da0db31Pinned equivalent / consequence
SDK/include/HAL/M_driver_bundle.hMISSINGEXISTSNo HAL bundle API at pin. Closest pinned surface: DeviceContext.load_function (PIN max/mojo/max/gpu/host/device_context.mojo:5257).
Target/lib/CUDA/M_driver_function.cppMISSINGEXISTSCUDA plugin source not published at pin.
max/driver/src/max_license/README.mdMISSINGEXISTSNeoDriver does not exist at pin. Pinned driver is max/python/max/driver/.
Target/test/CUDAPluginTest.cppMISSINGEXISTSNo pinned HAL qualification test.
Licenses/MAX_LICENSEMISSINGEXISTSPin has Licenses/LICENSE (MAX Community License) and root LICENSE (Apache-2.0 WITH LLVM-exception LLVM).
GraphCompiler/, MLRT/, max/driver/, Kernels/MISSINGEXISTSCompiler/runtime/HAL internals are not in the pinned source distribution.

Pinned top-level tree (abridged): AsyncRT Cache Config Init LICENSE Licenses MODULE.bazel Mojo README.md REPO.bazel Support bazel bazelw context7.json docs max pyproject.toml rust_kv tools utils. Main top-level tree adds: GraphCompiler Kernels MLRT SDK Target.

Consequence for the core question: at the exact pin, "MAX's own bundle/module path" cannot be inspected, built, or called from source; the HAL analysis in this report is a main-branch analysis and must be labelled as such. The only pinned, source-visible device-code ingestion API is the Mojo DeviceContext API.


4. Capability matrix

Status vocabulary: SUPPORTED, UNSUPPORTED, UNKNOWN, REQUIRES_MODULAR_CHANGE. A row is evaluated against the source named in the Source column; a capability can therefore be SUPPORTED on main and UNKNOWN/UNSUPPORTED at the pin.

#CapabilitySourceStatusEvidence
1Custom op registration at Mojo source level (mo.custom + @extensibility.register)PINSUPPORTEDmax/python/max/graph/ops/custom.py:69-129; max/kernels/src/graph_compiler/extensibility/decorators.mojo:46-75; max/python/max/graph/graph.py:296-314
2Register a custom op from a precompiled binary that is not a Mojo packagePINUNSUPPORTEDmax/python/max/graph/graph.py:258-283 accepts only .mojoc or Mojo source; max/python/max/graph/ops/custom.py:109-127 requires the symbol to resolve in the kernel library
3Graph construction into an MLIR modulePINSUPPORTEDmax/python/max/graph/graph.py:551-568,843-865
4Public graph-compile API to a compiled artifactPINSUPPORTEDmax/python/max/engine/api.py:1276-1305; max/python/max/_core/engine.pyi:69-83
5Graph compiler internals / MEF writer implementationPINUNKNOWNSource absent at pin (evidence/commands/05-path-divergence.txt); only the native capsule call is visible (api.py:1294-1296)
6MEF binary format definitionMAINSUPPORTEDMLRT/docs/GraphRT/ModularExecutorFormat.md:136-159, 93-100
7GPU device/context ownership and lifetime, public Python APIPINSUPPORTED (surface)max/python/max/_core/driver.pyi:32-45,229-238,314-315; internals UNKNOWN at pin
8Context identity: primary CUcontext shared with other librariesMAINSUPPORTEDTarget/lib/CUDA/Context.cpp:20-30; MLRT/lib/Driver/DeviceContext/CUDA/CUDADeviceContext.cpp:904
9Device memory allocation through BufferPINSUPPORTEDmax/python/max/_core/driver.pyi:1131-1183
10Guaranteed allocation alignmentPINUNKNOWNOnly a query exists (driver.pyi:1463-1466); no guarantee stated in pinned source. Main: minimum 64 B (MLRT/lib/Driver/DeviceContext/MemoryManager.cpp:851-865)
11DLPack zero-copy import/exportPINSUPPORTEDdriver.pyi:1318-1333,1442-1448; max/python/max/_core/dlpack.pyi:20-43; max/python/max/driver/buffer.py:201-269
12Wrap an arbitrary device pointer without DLPackPINUNSUPPORTED (no public API)Constructors only take dtype/shape/device/stream (driver.pyi:1164-1183); _data_ptr is private (driver.pyi:1479-1480)
13Ownership transfer / producer-retains semanticsPINSUPPORTED (DLPack)driver.pyi:1322-1323; main implementation max/python/max/_core/max_license/lib/Driver/Buffer.cpp:306-335
14Queues/streams/events and ordering primitivesPINSUPPORTEDdriver.pyi:678-696,707-762,830-842; CompletionFlag :378-458; DeviceEvent :475-528
15Synchronization, completion and error propagationPINSUPPORTEDdriver.pyi:707-713 (raises on internal error), :509-528; contract test max/tests/tests/driver/test_buffer_sync_contracts.py:13-29
16Load external PTXPINSUPPORTEDdevice_context.mojo:5257-5310; test max/mojo/test/asyncrt/test_cuda.mojo:177-186
17Load external CUBIN/SASSPINUNKNOWNDoc/release note claim PTX/SASS (device_context.mojo:5269-5281; max/docs/site/releases/v26.5.md:606-614), but only PTX is tested and the type is String with UTF-8 precondition (Mojo/stdlib/std/collections/string/string.mojo:380-394); runtime implementation absent
18Load external CUBIN through MAX's HAL bundle pathMAINSUPPORTED (code path), not productionmax/driver/src/max_license/_hal/context.mojo:65-78,359-369; Target/lib/CUDA/Function.cpp:68-90; Target/lib/CUDA/M_driver_queue.cpp:155-196; production status MAIN max/driver/src/max_license/README.md:31-38
19Ingest LLVM IR as device codePIN/MAINUNSUPPORTEDNo API accepts LLVM IR; load_function documents only PTX/SASS (device_context.mojo:5269-5281); HAL passes bytes to cuModuleLoadDataEx (MAIN Target/lib/CUDA/Function.cpp:80-85), which is PTX/cubin only
20Native launch hook reachable from public PythonPINUNSUPPORTEDNo launch/module API in max.driver or max._core.driver (evidence/commands/20-python-launch-absence.txt); Model.execute only runs a compiled graph (engine.pyi:271)
21Native launch hook reachable from public MojoPINSUPPORTEDdevice_context.mojo:5257-5310 (load), :5324-5360 (enqueue), _device_context_extras.mojo:228-250 (argument packing); DeviceExternalFunction is not re-exported at host/__init__.mojo:21-33
22NeoDriver / HAL bundle APIPINUNSUPPORTED (absent)Directory and headers absent at pin (evidence/commands/05-path-divergence.txt)
23Plugin selection by environment variableMAINSUPPORTEDTarget/include/Target/DriverPlugin.h:47-53; Target/lib/DriverPlugin/DriverPlugin.cpp:286-321 (MODULAR_DRIVER_PLUGINS, colon-separated .so list); MLRT/lib/Driver/DeviceContext/CompilerDeviceArch.cpp:59
24Serving telemetry, opt-out availablePINSUPPORTEDmax/python/max/serve/telemetry/common.py:96,115-124; max/python/max/serve/config.py:311-315
25Engine/driver offline operation without network egressPINUNKNOWNNo network imports in inspected Python driver/engine scope, but the native _core implementation is absent from the pinned tree; compile can be cross-target (engine/api.py:450-455,1070-1076) but offline egress is unproven
26License terms per relevant pathPIN/MAINSUPPORTED§9 below
27CUDA-free NVIDIA executionPIN/MAINUNSUPPORTEDmax/docs/site/gpu/hardware-compatibility.mdx:20-24; Target/lib/CUDA/Loader/CUDALoader.cpp:37

5. Capability detail

5.1 Custom op registration ABI

Pinned Python side. max.graph.ops.custom.custom(name, device, values, out_types, parameters) builds an MLIR mo.custom op whose symbol is the registration name, attaches a device attribute and optional parameters, then calls graph._kernel_library.verify_custom_op(custom_op) (PIN max/python/max/graph/ops/custom.py:69-129). inplace_custom builds the same op with an extra chain operand (:132-208). KernelLibrary accepts only:

Pinned Mojo side. @extensibility.register(name, type=..., api=..., arch=..., model=...) registers a struct as an implementation of an mo/mo.custom op. The graph compiler picks the most specific match; arch examples include sm_100a, sm_90a, gfx942 (PIN max/kernels/src/graph_compiler/extensibility/decorators.mojo:46-75,115-124). This is a compile-time, source-level ABI, not a binary plugin ABI: the registration is consumed by the Mojo compilation of the kernel library. A worked example is PIN max/examples/custom_ops/kernels/vector_addition.mojo:83-107.

What this does not establish. A custom op's registration name does not let me hand MAX a SASS blob. The kernel library must be Mojo source or a Mojo-compiled package, and the registered implementation is Mojo code. The Mojo implementation may itself load external assembly at runtime via DeviceContext.load_function (see §5.6), but that is a wrapper technique, not a registration of native code as a graph op.

5.2 Graph compilation and artifact format

Pinned surface:

Gap at the pin: the compiler that performs MLIR → MGP → device code and the MEF encoder are not in the pinned source tree (evidence/commands/05-path-divergence.txt). The pin therefore gives me the shape of the artifact (MEF containing cubins) but not a writable format.

Main adds the format definition. MLRT/docs/GraphRT/ModularExecutorFormat.md documents MEF: magic 0xBEF0, section list, VBR encoding, unknown sections skipped, produced by MLIRToMEF, and explicitly "MEF files can be created by an arbitrary producer" (MAIN MLRT/docs/GraphRT/ModularExecutorFormat.md:93-100,136-159). This is documentation only; there is no public, stable MEF-writer API in the pinned Python surface.

5.3 GPU device and context ownership

Pinned public API:

Main internals (not proof for the pin). MLRT retains the CUDA primary context (cuDevicePrimaryCtxRetain) when constructing a context and releases it on teardown (MAIN MLRT/lib/Driver/DeviceContext/CUDA/CUDADeviceContext.cpp:904 and destructor at :310); the HAL CUDA plugin does the same (MAIN Target/lib/CUDA/Context.cpp:20-39). A context owns allocations, loaded code, queues and events (MAIN max/driver/src/max_license/README.md:83-87). Because both MAX and another library using the CUDA runtime/driver primary context share CUcontext, addresses allocated in one are valid in the other provided both use the same primary context and no competing cuCtxCreate context. CUDA device addresses are CUdeviceptr values in a unified virtual address space; MAX's HAL wrapSync stores the raw address and does not translate handles (MAIN Target/lib/CUDA/Context.cpp:81-91), so a loaded external function receives the same address MAX allocated. This is the structural basis for pointer interop, but it is main-only evidence and was not tested at runtime. If the pinned runtime creates a private context instead, pointers from another primary context are invalid; that is exactly what probe G1 resolves.

Queue semantics on main: NeoDriver has no default queue, a queue guarantees only start-to-start ordering, and a Stream is a queue with end-to-start (FIFO) ordering (MAIN max/driver/src/max_license/README.md:88-102). A DeviceQueue obtained from the pinned Python API behaves as an in-order stream in its documented contract (PIN max/python/max/_core/driver.pyi:678-696). CUDA streams are created non-blocking (MAIN Target/lib/CUDA/Queue.cpp:36-39). Cross-stream dependencies require record_event/wait_for; completion is observed by synchronize() or event signaling, and errors surface as ValueError (pin) or M_driver_status_t (main).

5.4 Device memory: allocation, alignment, import/export, ownership

Pinned:

Alignment: the pin exposes only a predicate (_aligned), tested in max/tests/tests/driver/test_buffer.py:972-1012. No minimum alignment is guaranteed in pinned source. On main, the MLRT memory manager enforces a minimum of 64 bytes (MAIN MLRT/lib/Driver/DeviceContext/MemoryManager.cpp:851-865), and base allocations go through cuMemAlloc (MAIN Target/lib/CUDA/Context.cpp:61-79), whose base alignment is a CUDA driver property rather than a MAX constant. Treat 64 B as the documented main-side allocator floor and 256 B as a typical cuMemAlloc base alignment only after measuring.

Ownership:

This means MAX can operate on externally allocated memory, but the caller must guarantee the pointer came from the same CUDA context/device and stays alive.

5.5 Queues, events, ordering, synchronization, error propagation

Pinned:

Main internals:

5.6 Module loading and acceptance of SASS/cubin/PTX/LLVM IR

Pinned Mojo API (the only pinned external-code loader). DeviceContext.load_function[func_type](function_name=..., asm=...) constructs a DeviceExternalFunction; the docstring says it loads a pre-compiled GPU function from "assembly code (PTX/SASS)" instead of compiling from Mojo source (PIN max/mojo/max/gpu/host/device_context.mojo:5257-5310). The constructor forwards function_name, asm, asm.byte_length(), a debug level and an optimization level to the runtime symbol AsyncRT_DeviceContext_loadFunction (:4377-4425). enqueue_function accepts that value and packs each argument's address into an array (PIN max/mojo/max/gpu/host/_device_context_extras.mojo:228-266), matching the CUDA void** kernelParams convention.

Main HAL path (structurally accepts cubin).

MEF vs .mojoc vs shared object.

Bundle format, restated exactly. For NVIDIA on main, the expected object is a cubin ELF (or PTX text) passed as a byte slice, plus a file_type annotation of "cubin"; it is not a .mojopkg, not a .mojoc, not a shared object, and not a MAX-wrapped container (MAIN max/driver/src/max_license/_hal/context.mojo:65-78,359-369; MAIN SDK/include/HAL/M_driver_bundle.h:39-51; MAIN Target/lib/CUDA/Function.cpp:68-90). The MEF is the graph artifact that contains such code objects; it is not the input to M_driver_bundle_load.

5.6.1 Entry-point and launch ABI (main HAL)

5.7 Native launch hook from public Python / Mojo

5.8 Plugin loader / env-var targeting (requested by the parent)

5.9 Telemetry and offline operation


6. Concrete end-to-end trace

6.1 Pinned v26.7.0 (what is visible in source)

StepConcrete function/typeEvidence
1. Graph opmax.graph.ops.custom.custom() emits mo.custom with symbol = registration name; inplace_custom() adds a chainmax/python/max/graph/ops/custom.py:69-129,132-208
2. Kernel selection (lowering input)@extensibility.register(name, type, api, arch, model) selects the most specific Mojo implementation at compile timemax/kernels/src/graph_compiler/extensibility/decorators.mojo:46-75
3. Lowered/fused form (observable)Model.kernel_summaries: one summary per mgp.generic.execute fused kernelmax/python/max/_core/engine.pyi:247-255
4. ModuleGraph builds mo.graph in builtin.ModuleOp; Module.mlir_modulemax/python/max/graph/graph.py:551-568,843-865
5. Compile callInferenceSession._compile_module → self._impl.compile(module.mlir_module._CAPIPtr, ...)max/python/max/engine/api.py:1276-1305
6. ArtifactCompiledModels / export_mef; MEF embeds host ELF + cubinsmax/python/max/_core/engine.pyi:69-83; max/python/max/_interpreter_ops/unary_elementwise_gc.py:195-199
7. Driver module loadNot present in pinned source. Native runtime boundary onlyevidence/commands/05-path-divergence.txt
8. AllocationBuffer(dtype, shape, device=...); Model.execute copies inputs to devicemax/python/max/_core/driver.pyi:1164-1183; max/python/max/_core/engine.pyi:271-283
9. DispatchModel._execute_device_tensors (native); no Python launch APImax/python/max/_core/engine.pyi:359-361; evidence/commands/20-python-launch-absence.txt
10. SyncDeviceQueue.synchronize() / Device.synchronize(); read-backs are synchronousmax/python/max/_core/driver.pyi:69-74,707-713; max/tests/tests/driver/test_buffer_sync_contracts.py:13-29
11. Outputlist[Buffer] returned from Model.executemax/python/max/_core/engine.pyi:271

6.2 Main branch internals (source-visible, not the pin)

StepConcrete function/typeEvidence
1–4Same Python graph/custom-op surface as aboveas above
5. ArtifactMEF (0xBEF0) produced by MLIRToMEF; format documentedMAIN MLRT/docs/GraphRT/ModularExecutorFormat.md:93-100,136-159
6. Bundle loadContext.load_bundle(asm: StringSlice) builds M_driver_static_bundle{mapped_data, file_type="cubin"} → M_driver_bundle_loadMAIN max/driver/src/max_license/_hal/context.mojo:65-78,359-396; MAIN SDK/include/HAL/M_driver_bundle.h:96-101
7. Module loadM_driver_runtime_bundle::load → cuModuleLoadDataExMAIN Target/lib/CUDA/Function.cpp:68-90
8. FunctionM_driver_function::load → cuModuleGetFunction + cuFuncSetAttributeMAIN Target/lib/CUDA/Function.cpp:106-131
9. AllocationM_driver_context::allocSync → cuMemAlloc in primary context; or wrapSyncMAIN Target/lib/CUDA/Context.cpp:20-30,61-91
10. DispatchM_driver_queue_execute → cuLaunchKernelEx(args, extra=nullptr); arg_sizes/num_args are not used by CUDAMAIN Target/lib/CUDA/M_driver_queue.cpp:155-196
11. Sync/eventsM_driver_queue::synchronize → cuStreamSynchronize; events cuEventRecord/cuStreamWaitEventMAIN Target/lib/CUDA/Queue.cpp:221-240,258-266
12. OutputBuffers returned to caller; MLRT legacy path returns DeviceBufferRefMAIN Target/lib/CUDA/Context.cpp:61-79; PIN max/python/max/_core/engine.pyi:271

MLRT's legacy CUDA path is equivalent: CUDADeviceContext::loadFunction → cuModuleLoadDataEx → cuModuleGetFunction (MAIN MLRT/lib/Driver/DeviceContext/CUDA/CUDADeviceContext.cpp:2212-2280), enqueueFunctionExecDirect → cudaCallKernelDirect → cuLaunchKernelEx (:2296-2312, :1573-1611), synchronize → cuStreamSynchronize (:2387-2399).


7. Interoperability boundary candidates for Omega sm_121 code (ranked)

Ranking criterion: smallest new surface + least MAX modification + lowest legal/ownership risk. All candidates assume the CUDApp-produced artifact is a valid cubin ELF for the device; that assumption is not verified here.

Rank 1 — Co-scheduled execution: DLPack + native_stream_handle (no MAX code change)

Boundary. MAX allocates/owns a Buffer (or imports a CUDApp allocation via DLPack). Export the pointer with Buffer._data_ptr() or, preferably, wrap CUDApp memory with max._core.dlpack.make_dlpack_capsule and let MAX import it. Order work with DeviceQueue.native_stream_handle: Omega/CUDApp enqueues its own kernel on that exact CUstream via the CUDA driver, after MAX's prior work and before MAX's subsequent work. MAX remains responsible for its own graph; Omega's kernel is not a graph node.

Why smallest. No MAX compilation, no plugin, no artifact format, no MAX modification. native_stream_handle is explicitly documented for this use ("Lets native code outside MLRT order its own work against this stream", PIN max/python/max/_core/driver.pyi:830-842). DLPack zero-copy import/export is supported (driver.pyi:1318-1333,1442-1448; dlpack.pyi:20-43).

What is missing / must be validated.

Rank 2 — Mojo custom op wrapper around DeviceContext.load_function (MAX owns execution)

Boundary. Build a small Mojo custom-op library (.mojoc) that registers an op (e.g. omega_kernel, type="gpu", api="cuda", arch="sm_121a") and, in execute, calls ctx.load_function(...) with the cubin, then ctx.enqueue_function(...) with the op's tensors. MAX's graph compiler then schedules the op, MAX owns device buffers, the queue and synchronization, and the output is a normal graph result.

Why second. This is the smallest path that gives MAX end-to-end ownership at the pin. All required public-ish APIs exist: @extensibility.register (decorators.mojo:46-75), load_function (device_context.mojo:5257-5310), enqueue_function for DeviceExternalFunction (:5324-5360), argument packing (_device_context_extras.mojo:228-266).

What is missing.

Rank 3 — MAX HAL/NeoDriver bundle path on main (MAX owns everything, but not at the pin)

Boundary. Using a build from origin/main, call M_driver_bundle_load with a static bundle whose bytes are the CUDApp cubin and file_type="cubin", then M_driver_function_load for the symbol, allocate with M_driver_memory_alloc_sync (or wrap), create a queue, M_driver_queue_execute, M_driver_queue_synchronize. Alternatively use the Mojo client Context.load_bundle (MAIN max/driver/src/max_license/_hal/context.mojo:359-396).

Why third. This is the exact architectural fit for "MAX owns device memory, queues and synchronization", and the CUDA implementation treats bundle bytes as cubin/PTX with no MAX-specific wrapper (MAIN Target/lib/CUDA/Function.cpp:68-90). But it does not exist at the pin.

What is missing.

Rank 4 — Custom HAL plugin via MODULAR_DRIVER_PLUGINS (backend replacement, not minimal)

Boundary. Ship a .so implementing the M_driver_* ABI that registers a new API, and point MODULAR_DRIVER_PLUGINS at it (MAIN Target/lib/DriverPlugin/DriverPlugin.cpp:286-321). The plugin could load CUDApp cubins and own memory/queues.

Why fourth. This does not reuse MAX's CUDA plugin; it reimplements a large, versioned ABI (M_DRIVER_INTERFACE_VERSION_*, MAIN SDK/include/HAL/M_driver_common.h:30-66), and the graph compiler would still need to know the new device. It is effectively a backend port, not a minimal boundary. The .so loader path is source-visible only on main and unverified at the pin.

Rank 5 — Inject a cubin into a MEF (not supported without upstream help)

Boundary. Write a MEF whose invokable references the external function and embeds the cubin bytes, then load it with max._core.engine.read / InferenceSession.

Why lowest. MEF is documented and "can be created by an arbitrary producer" (MAIN MLRT/docs/GraphRT/ModularExecutorFormat.md:93-100), and it embeds cubins in MAX's own artifacts (PIN .../unary_elementwise_gc.py:195-199). However, the pinned surface has no MEF writer API; the code-object encoding and the primitive that launches an external function are compiler/runtime internals, and no public primitive is documented for "call this cubin symbol". This requires a Modular change or a deep, version-fragile reimplementation. Status: REQUIRES_MODULAR_CHANGE for a supported path.

Rank 6 — Register a binary-only op / ingest SASS as a .mojoc (unsupported)

KernelLibrary accepts only .mojoc or Mojo source (PIN max/python/max/graph/graph.py:258-283), and @extensibility.register is a compile-time Mojo construct (decorators.mojo:46-75). There is no binary op ABI. UNSUPPORTED without an upstream change.

7.1 Licence boundary for CUDApp code

This is an engineering analysis, not legal advice. Two materially different acts:

  1. Runtime loading of a separately produced cubin (Rank 1/2/3): MAX reads bytes or a file and hands them to the CUDA driver. The cubin remains a separate artifact under Apache-2.0 WITH LLVM-exception; this is the cleanest boundary.
  2. Bundling/embedding the cubin in a MAX artifact (MEF injection, .mojoc, a redistributed wrapper): the LLVM exception permits redistribution of compiled object code under terms of the recipient's choosing, so no CUDApp source-disclosure obligation follows. MAX's own licence and NOTICE/attribution terms still apply to the MAX portions. Keep the CUDApp NOTICE with redistributed CUDApp-derived material.

The MAX Community License's AI clause expressly permits reading/analyzing MAX and developing software that "runs on or interoperates with MAX", while forbidding use of MAX as training input to produce a substitute (PIN Licenses/LICENSE:81-86; MAIN Licenses/MAX_LICENSE:66-71). This report is analysis; no MAX code was copied into AIEN production paths, and no MAX substitute is being generated.


8. What is NOT proven

  1. No GPU execution was performed. Every hardware-dependent statement is structural analysis. PROBE-PLAN.md lists the window-only steps; all are NOT_RUN.
  2. A CUDApp-produced sm_121 cubin was not loaded. The claim "structurally accepted" is based on cuModuleLoadDataEx receiving raw bytes and file_type="cubin", plus CUDA driver semantics. It is not a successful-load result.
  3. Pinned SASS support is not empirically established. The pin's only loader test uses PTX text; cubin support at the pin rests on a docstring and a release note, and the implementation is not in the pinned source.
  4. The String transport risk is not resolved. load_function(asm: String) documents a valid-UTF-8 precondition. Whether MAX's internal object-emission path bypasses it, and whether an external caller can safely pass cubin bytes, is unverified.
  5. Pinned context identity is unknown. Main uses the CUDA primary context; the pinned native runtime may differ. Pointer sharing across MAX/CUDApp at the pin must be probed.
  6. Pinned allocation alignment is unknown. Only _aligned() exists; the main 64-byte floor is not a pinned guarantee.
  7. Offline engine operation is unproven. No network imports were found in the inspected Python scope, but the pinned source tree ships only .pyi stubs for max._core (its native implementation is absent), and the license states telemetry may be collected.
  8. Custom Mojo ops do not prove arbitrary SASS ingestion. They prove a source-level Mojo registration mechanism; external assembly enters only through load_function, with the caveats above.
  9. No MEF writing/injection was demonstrated. The format is documented on main; the pinned API only exports/reads MEFs.
  10. No claim about sm_121 vs sm_121a cubin compatibility. The toolchain targets sm_121a for DGX Spark; whether an sm_121 cubin runs on an sm_121a device is a hardware/driver question, not established here.
  11. No claim of CUDA-free execution. MAX's NVIDIA path depends on libcuda.so.1 and driver 580+.
  12. Main evidence is not release evidence. All MAIN citations are from da0db31, not from the pinned release; behavior may differ in the v26.7.0 binaries.

9. License map (per relevant path)

PathLicenseEvidence
/LICENSE (repository root)Apache-2.0 WITH LLVM-exception with LLVM ExceptionsPIN LICENSE:1-3
max/python/max/** (driver, engine, graph)Apache-2.0 WITH LLVM-exception with LLVM Exceptions (file headers)PIN max/python/max/driver/__init__.py:4; max/python/max/graph/ops/custom.py:4
max/mojo/max/** (GPU host, plugins)Apache-2.0 WITH LLVM-exception with LLVM ExceptionsPIN max/mojo/max/gpu/host/device_context.mojo:4
max/kernels/** (extensibility, kernels)Apache-2.0 WITH LLVM-exception with LLVM ExceptionsPIN max/kernels/src/graph_compiler/extensibility/decorators.mojo:4
max/include/max/c/*.hApache-2.0 WITH LLVM-exception with LLVM ExceptionsPIN max/include/max/c/context.h:4
Licenses/LICENSE (shipped MAX components)Modular MAX Community LicensePIN Licenses/LICENSE:1-7; product split Licenses/README.md:6-13; separately licensed components :88-90
Licenses/Third-Party-NoticesLLVM Apache-2.0 WITH LLVM-exception LLVM; NVSHMEM under NVIDIA SDK license; other OSSPIN Licenses/Third-Party-Notices:5-8,228-233
MAIN SDK/**, Target/**, MLRT/**, max/driver/**MAX License (file headers)MAIN SDK/include/HAL/M_driver_bundle.h:4-5; MAIN max/driver/src/max_license/_hal/context.mojo:1-12
MAIN Licenses/MAX_LICENSEModular MAX Community License §1.4(d) AI clauseMAIN Licenses/MAX_LICENSE:66-71
AI_TOOL_POLICY.mdContribution policy (not a license): label AI-assisted work, human reviewPIN AI_TOOL_POLICY.md:10-22,42-47,61-72

Obligations relevant to this work:


10. Evidence index

EvidenceContents
evidence/commands/01-pin-verification.txtHEAD, tag peel, tag object, tree hash
evidence/commands/01b-remote-tag-oids.txtremote ls-remote oids for max/v26.7.0 and mojo/v1.2.0
evidence/commands/02-tree-hashes.txtmax, Licenses, Support subtree hashes
evidence/commands/03-main-head.txtmain oid + directory listings for requested paths
evidence/commands/04-main-file-extraction.txtmain reference extraction log
evidence/commands/05-path-divergence.txtrequested paths at pin vs main; top-level trees
evidence/commands/06-main-reference-hashes.txtgit blob oid + SHA-256 for every main reference file
evidence/commands/07-checkout.txtsparse list, HEAD, status, file count, sizes
evidence/commands/10-custom-op-abi.txtcustom-op/registration line numbers
evidence/commands/11-graph-artifact.txtgraph/module/MEF line numbers
evidence/commands/12-driver-api.txtdevice/queue/buffer/DLPack line numbers
evidence/commands/13-stream-sync.txtstream/sync/alignment/test line numbers
evidence/commands/14-load-function.txtload_function, external function, PTX-only test, release note
evidence/commands/15-sm121.txtsm_121 target and hardware table
evidence/commands/16-telemetry-offline.txttelemetry endpoints/defaults/opt-outs/env vars
evidence/commands/17-license.txtlicense headers and clauses
evidence/commands/18-main-hal-citations.txtmain HAL/loader/launch/sync line numbers
evidence/commands/19-main-license-mef.txtMAX_LICENSE 1.4(d), MEF format, NeoDriver, main bindings
evidence/commands/20-python-launch-absence.txtabsence of Python launch/module API; debug flags
evidence/main-references/**verbatim main-branch files used for MAIN citations
SHA256SUMSSHA-256 manifest over this report and evidence/