Repository navigation
feat(mlxcelverse): standalone cuda-oxide fused residual-add + RMSNorm kernel with a GB10 oracle - #2953
Conversation
… kernel with a GB10 oracle Second step of the cuda-oxide experiment (docs/mlxcelverse/cuda-oxide-feasibility.md): an isolated package, spike/cuda-oxide-fused-norm, with five entry points (f32, f16, bf16 activations with the weight in the same dtype, and f16/bf16 activations with an f32 weight) that follow kernels/fused_norm.cpp's CUDA port term for term, a host harness (run / compare / bench), one ABI schema and validated manifest per entry, and an mlxcel-core example (oxide_fused_norm_oracle) that replays the fixtures through the existing fused CUDA kernel and the graph path. On a DGX Spark GB10 (sm_121) all 130 cases (2,181,390 elements) pass the frozen fused_norm_parity_tests budgets against both references and are bit-identical to the existing fused CUDA kernel; Compute Sanitizer memcheck/racecheck/synccheck/initcheck report 0 errors; results, artifacts and the evidence report are committed. Closes lablup#2832
… lines and device code Record, for issue lablup#2832, where each numerical point of the contract lives in the reference kernel and in the standalone kernel, what the compiled code of both executes on the GB10 (FMA-contracted square accumulation, butterfly order, rsqrt, constant-width reciprocal in the reference), the control build without the explicit FMA intrinsic, and the lablup#2831 smoke re-run this work depends on.
…result compare.sh wrote the absolute path of gpu-lock, which says nothing about a stand-in lock and leaks a home directory. Record the path relative to HOME and a gpu_lock_kind note (GPU_LOCK_KIND), and regenerate the result from the same fixtures and oracle dump: only the notes changed, 130 of 130 cases still pass and stay bit-identical.
An empty or truncated cases.tsv could produce a successful comparison without qualifying all dtype and shape cases. Require the canonical matrix in its deterministic seed order before reading oracle outputs. The focused Rust test accepts the complete matrix and rejects empty, header-only, truncated, reordered and duplicate cases. Device kernel code and artifacts are unchanged. Refs lablup#2953, lablup#2832
|
Implementation hardening for #2953. Reviewed #2832: the standalone artifact, launch guards, dtype tolerances, and reference comparisons match the intended experiment. Fixed a reliability defect: an empty or incomplete cases.tsv could yield a vacuous all-pass comparison. The harness now requires the complete canonical case matrix, with regression coverage for empty, truncated, duplicate, and reordered cases. Validation: The pinned oxide build, fmt/clippy, eight guard checks, and fixture regression test passed. The GPU host-reference run covered 130 cases and 2,181,390 elements, rejecting all five invalid launches. The built |
Summary
Adds the second gated experiment from
docs/mlxcelverse/cuda-oxide-feasibility.md: a standalone fused residual-add + RMSNorm kernel written in Rust, compiled with the cuda-oxide toolchain that #2831 validated, plus the numerical oracle the issue asks for. On a GB10 all 130 cases (2,181,390 elements) are bit-identical to the existing fused CUDA kernel and inside the frozen graph-path budgets.The kernel lives in a new isolated package,
spike/cuda-oxide-fused-norm(its own workspace root, never part of the mlxcel build graph; the application Rust pin stays at 1.97.1). Five entry points cover f32 / f16 / bf16 activations with the weight in the same dtype, and the two mixed pairs (16-bit activations, f32 weight). The only change inside the mlxcel workspace is a newmlxcel-coreexample,oxide_fused_norm_oracle, which replays the package's fixtures throughfused_add_rms_normandlayers::graph_add_rms_normand dumps their bits. No production code path changes.Related issues
Closes #2832
Follows #2831. #2833 and #2834 can reuse the artifacts, fixtures and timing method.
Type of change
feat— new user-visible featurefix— bug fixperf— performance improvement (include before/after numbers in the PR body)refactor— internal restructuring without behavior changechore— build, CI, dependencies, release infrastructuredocs— documentation onlytest— tests onlyAcceptance criteria (issue #2832)
kernels/fused_norm.cppterm for term.results/compare-sm_121.jsonshows everynormedandnew_residualelement equal to the existing fused CUDA kernel bit for bit.fused_norm_parity_tests::tolerance_for(f321e-6 / 1e-5, f162e-3 / 1.2e-2, bf161.6e-2 / 7e-2, normalized RMS / max), recorded in the README and the harness before the oracle ran. Fixtures are per-case seeded LCG normals already rounded to the case dtypes. Worstnormedvs graph, normalized RMS: f32 9.1e-8, f16 9.4e-6, bf16 0, f16 with f32 weight 5.2e-4, bf16 with f32 weight 3.9e-3.rows = 0,dim = 0, length mismatches and more than 2^32-1 elements with a message; the run reports those fiveREJECTlines.gpu-lock.results/compare-sm_121.jsonandresults/bench-sm_121.jsoncarry dtype, shape, error metrics, PTX/cubin SHA-256, GPU, driver, toolkit, mlxcel commit and executed case counts. The harness output is checked against the manifests, so a skipped or shortened run fails the script. See the note ongpu-lockbelow.scripts/bench.shrecords CUDA-event timings for 18 shapes (cold first launch, warm mean of 200). No speedup claim is made.Out of scope, as the issue states: no MLX runtime integration, attention, quantized matmul or inference engine.
Why the bits match
docs/mlxcelverse/cuda-oxide-fused-norm-evidence.mdmaps each numerical point of the contract to its lines inkernels/fused_norm.cppand in the new kernel, and records what both compiled kernels execute (cuobjdump -sasson the NVRTC-cached reference cubins and on the committed cubin):acc += sr * srinto one FMA per element, use the same warp butterfly order, and useMUFU.RSQ.total / dim + epsto one FMA with a constant reciprocal. That scaling is exact and equals the runtime division used here; other widths use a true division in both.fma_rn_f32withacc + sr * srin an isolated copy gave the same PTX instruction stream and the same 130 of 130 identical cases. The pinned toolchain contracts by default; the explicit intrinsic keeps that from depending on a compiler default.Test plan
Run on a DGX Spark GB10 (sm_121, driver 580.178.04, CUDA 13.0, LLVM 21.1.0 release tarball, Rust 1.99.1 for the package and 1.97.1 for the application), at
28d884a5.cargo fmt --all -- --checkcargo clippy --workspace --all-targets --features metal,accelerate -- -D warnings(not run; Linux host. Rancargo clippy -p mlxcel-core --features cuda --example oxide_fused_norm_oracle -- -D warningsfor the one file added to the workspace, clean.)cargo test --workspace --profile test-fast --features metal,accelerate --no-fail-fast -- --test-threads=1(not run. Ran the existingfused_norm_parity_testson the CUDA build of the same tree: 10 passed.)cargo deny check(not run; the workspaceCargo.lockand dependency set are unchanged, and the package has its own lockfile outside the workspace.)Package gates, all passing:
memcheck,racecheck,synccheck,initcheck: 0 errors each over the full run.b54c1c93…,677d6d6d…); launch check valid.Notes for reviewers
gpu-lock. The host used here is not one of the maintainers' machines and has no upstreamgpu-lock. A user-localflock(1)shim with the samerun --tag <tag> -- <cmd>shape serialized every GPU command;results/compare-sm_121.jsonrecords it asgpu_lock_kind. If the criterion needs the real tool, the scripts run unchanged on a host that has it.artifacts/fused_add_rms_norm.sm_121.cubin(77.5 KB) is declared inscripts/ci/check_binary_assets.py, following the Validate cuda-oxide artifacts and standalone execution on GB10 #2831 precedent, because rebuilding it needs LLVM 21, CUDA 13.0 and the pinned cuda-oxide compiler.rms_normusesresult_type); the fused reference is never converted.f16casts; bf16 uses the explicit round-to-nearest-even intrinsic.Checklist
feat:,fix:, etc.)docs/if user-facing behavior or supported models changed// Used by: ...comments on any shared function I modified (seedocs/code-guidelines.md) (no shared function modified).envfiles committed