Chapter 36
Accelerator Ecosystems Beyond CUDA and NVIDIA
On this page
Moving a model is easier than moving its performance. The weights and attention equations may survive unchanged while kernels, memory layouts, compilation, collectives, and serving behavior all need new evidence.
Consider moving the running model and serving workload to a second accelerator platform. Perhaps NVIDIA capacity is scarce, the team already operates an AMD cluster, or a cloud accelerator offers a promising deployment path. The task is not to translate every CUDA kernel immediately. It is to find the smallest supported stack that can serve the same model correctly, then determine whether its latency, operating cost, and maintenance burden justify adoption.
This chapter assumes the prefill/decode and memory models developed earlier in this part. It separates three often-confused choices: the accelerator, the software stack that operates it, and the language used to write a kernel. The ecosystem notes were checked against primary documentation on September 13, 2026. They are entry points for an evaluation, not a permanent hardware or model support matrix.
First separate the layers¶
CUDA names more than a kernel language: an application may depend on its runtime, libraries, compiler, graph execution, and development tools. Replacing CUDA C++ with Triton can change how kernels are written while leaving the application on NVIDIA hardware. Moving to AMD changes the underlying stack as well. Moving to TPU or Trainium changes the device execution model enough that a literal translation of warp-level code is usually the wrong starting point.
Keep the model contract above the porting boundary. Below it, choose a supported implementation path and revalidate kernels, state layout, and distributed execution. These are representative paths, not an exhaustive compatibility matrix; Pallas also has GPU backends.
There are three separate acceptance tests. Source portability asks how much code can be reused. Semantic portability asks whether it still implements the required computation and state transitions. Performance portability asks whether the target meets the workload's service objective. A successful import or compilation establishes none of the latter two by itself.
We will follow that boundary in three stages: port an operator, place the model's state and compiled variants, then judge a deployment against the service's workload. Triton supplies the worked tiled kernel; HIP exposes block synchronization; TPU and NKI illustrate different tile schedules. At each stop, ask who owns the row, where working values live, how tails remain correct, and what evidence establishes performance.
The SYCL standard offers another heterogeneous C++ programming model, including implementations for Intel GPUs. Its libraries and serving integrations still depend on the selected implementation; this chapter concentrates on the four paths in the diagram.
Carry one operation across the boundary¶
Use RMSNorm as a small porting exercise before moving the whole model. For an input row x of actual width N, learned weights w, and positive epsilon, the operation is y[i] = x[i] * rsqrt(sum(x[j]^2) / N + epsilon) * w[i]. Unlike LayerNorm, it does not subtract a mean. The contract is short; the implementation decisions are not. Who owns a row? Where does its partial sum live? Which participants synchronize? What happens to a padded lane?
For the examples here, input rows and weights are separate read-only tensors; the output is newly allocated. Convert loaded values to FP32 before squaring and accumulating, then convert the final result to the output storage dtype.
Padding changes the tile, not the mathematical row width.
For x = [3, 4, 0], unit weights, and epsilon 1e-6, the squared sum is 25. Using the actual width N=3 in the mean-square term produces approximately [1.0392304, 1.3856406, 0]. Mistakenly using the padded width four produces approximately [1.1999999, 1.5999999, 0]. Both look plausible. A width-4096-only test would never expose this bug. The repository's examples/accelerator_portability.py provides a higher-precision CPU oracle and rejection tests for out-of-range arithmetic.
Keep two references when validating a real kernel: higher-precision arithmetic for the mathematics, and a framework expression with the chosen accumulation and output dtypes. Set tolerances for a bounded activation range: finite FP32 inputs can still overflow when squared, and a very small positive epsilon can round to zero. Reduction trees and reciprocal-square-root implementations need not agree bitwise, but an overly loose tolerance can conceal a systematic error. Follow operator tests with model-quality checks; a training port also needs backward and gradient tests.
Triton: change the kernel language, not necessarily the GPU¶
Triton lets a programmer express operations over tiles of tensor elements instead of spelling out every thread's scalar work. Its upstream project lists NVIDIA and AMD GPU support. It is distinct from the similarly named NVIDIA Triton Inference Server. A Triton kernel targeting NVIDIA still needs the relevant NVIDIA execution stack; selecting an AMD backend does not port surrounding CUDA libraries or extensions. See the Triton project and compatibility notes.
Consider RMSNorm over a row of width 4096. A tiled implementation loads the row, accumulates its squared values, computes the normalization factor, applies the learned scale, and stores the result. The useful algorithm survives a backend change. The best tile layout, number of participating warps, and reduction schedule may not. Test awkward widths and noncontiguous inputs as well as the common case; padding lanes must not contribute to the reduction.
For a first port, use the framework's supported operator. Write or retune a Triton kernel only when profiling identifies a meaningful gap. A portable source file with two backend-specific tuning configurations can be a better maintenance choice than either two unrelated implementations or one universally mediocre configuration.
Here is the body of the accompanying forward-only implementation. A program handles one row; BLOCK is the next power of two at least as large as N. Input strides are measured in elements. Output rows are contiguous, so their stride is N, not the input row stride. Promoting indices before stride multiplication avoids an accidental 32-bit offset limitation.
Example status: Source-only Triton kernel excerpt; no device run recorded.
@triton.jit
def rmsnorm_rows(X, W, Y, sx0, sx1, sw,
N: tl.constexpr, EPS: tl.constexpr, BLOCK: tl.constexpr):
row = tl.program_id(0).to(tl.int64)
col = tl.arange(0, BLOCK).to(tl.int64)
valid = col < N
x = tl.load(X + row*sx0 + col*sx1,
mask=valid, other=0).to(tl.float32)
w = tl.load(W + col*sw, mask=valid, other=0).to(tl.float32)
square_sum = tl.sum(x*x, axis=0)
y = x * tl.rsqrt(square_sum/N + EPS) * w
tl.store(Y + row*N + col, y, mask=valid)
The host wrapper is part of the operation. This inference-only example accepts matched input types, positive strides, width at most 8192, and epsilon in 1e-12..1e-2. It allocates contiguous output on the input device and skips empty launches. Its four-warp configuration needs target-specific tuning. The complete wrapper and optional target tests are in examples/accelerators/triton_rmsnorm.py; the bounded-value contract avoids a synchronizing scan on every call.
Test a strided view, not just a contiguous matrix: if storage has shape (M, 2*N+3) and the view is storage[:, 1:1+2*N:2], the row stride is 2*N+3, the column stride is 2, and the new output's row stride is N. Sweep unit widths, either side of powers of two, and the implementation limit. Moving from 4096 to 4097 doubles this kernel's logical tile size; that can change register pressure and occupancy. Correct indexing and coalesced access are separate goals.
The Triton softmax tutorial is a useful reference for masked power-of-two tiles and strides. The LayerNorm tutorial explains row reductions and launch choices; its operation includes centering and is not this RMSNorm kernel. Read them alongside the original example rather than assuming a tutorial's benchmark transfers to this workload.
AMD GPUs: ROCm, HIP, and the code that translation misses¶
AMD Instinct GPUs are an alternative hardware family for datacenter training and inference. ROCm supplies the surrounding software; HIP offers a CUDA-like C++ interface, and HIPIFY tools help translate supported CUDA constructs. The hard cases include architecture-specific instructions, inline PTX, library dependencies, and assumptions about execution-group width. Treat AMD's CUDA-to-HIP porting guide as a migration inventory, not a claim of drop-in binary compatibility.
The reduction kernels earlier in this part explain why names alone are insufficient. A hard-coded 32-lane mask, a warp shuffle, or a shared-memory layout may encode an NVIDIA-specific assumption. Audit the target's wavefront behavior and compiler semantics; do not simply replace every 32 with 64. Rewrite ownership and synchronization first, then retune register use, local storage, and matrix instructions. CUDA graphs and asynchronous pipelines likewise require validation through the chosen backend rather than a name-for-name substitution.
For multi-device work, RCCL supplies AMD-oriented collective operations, including reductions, gathers, and all-to-all communication. API familiarity does not imply the same collective schedule or latency on a different topology. Measure representative payloads on the actual node and network. The RCCL overview describes its communication scope.
Start with a supported framework and serving-engine build, then enumerate custom extensions, attention backends, quantization formats, and MoE kernels. Pin the GPU, operating system, driver, ROCm release, framework, and engine together. The ROCm compatibility matrix is the starting point; an AMD product name alone is not a support guarantee.
Suppose the service needs separate prefill and decode pools. Local attention support is only the first gate. In the official vLLM ROCM_ATTN implementation inspected on September 13, 2026, supports_kv_connector() returns false: that backend's KV layout is incompatible with the blocks-first connector layout. This is a restriction of the inspected backend, not every ROCm deployment. Record the installed build, actual attention dispatch, head geometry, cache layout, and required connector together. If the connector gate fails, keep those phases on one compatible path or select a separately supported backend.
A HIP reduction makes ownership explicit¶
A simple HIP baseline uses exactly one 256-thread block per nonempty row, valid FP32 pointers, and positive element strides. Each thread accumulates columns tid, tid+256, ...; shared memory combines the partial sums, independently of warp/wave width. The excerpt is the reduction portion: a complete kernel also loads weights and stores normalized values in a second loop.
Example status: Source-only HIP kernel excerpt; no compile or device run recorded.
const int64_t row = static_cast<int64_t>(blockIdx.x);
const unsigned tid = threadIdx.x;
__shared__ float sums[256];
float local = 0.0f;
for (int64_t c = tid; c < n; c += 256) {
float v = x[row * sx0 + c * sx1];
local += v * v;
}
sums[tid] = local;
__syncthreads();
for (unsigned step = 128; step != 0; step >>= 1) {
if (tid < step) sums[tid] += sums[tid + step];
__syncthreads();
}
float inv_rms = rsqrtf(sums[0] / static_cast<float>(n) + eps);
For a three-element row, 253 threads contribute zero, but all 256 still reach every block barrier. Adding if (tid >= n) return; would break that synchronization contract. This baseline rereads inputs for the output pass, unlike the source-level single-load Triton version; similar arithmetic is not necessarily similar memory traffic. A supported block-reduction primitive may be a better production choice after profiling.
The launch boundary matters too. Check allocation/copy calls, check the launch error, and synchronize at a test boundary to detect asynchronous execution errors. Do not free or reuse input, output, or transfer buffers until their consumers finish. A producer on another stream needs an explicit dependency; residing on the same device does not order it. See the HIP asynchronous execution guide. Do not put a global synchronization after every production operation merely because it simplifies the test.
The launch below assumes checked buffers, positive dimensions, and a live stream; HIP_CHECK stops the test on an error.
Example status: Source-only HIP launch excerpt; no compile or device run recorded.
hipLaunchKernelGGL(rmsnorm_f32, dim3(rows), dim3(256), 0, stream,
d_x, d_w, d_y, n, sx0, sx1, sw, eps);
HIP_CHECK(hipGetLastError());
HIP_CHECK(hipStreamSynchronize(stream)); // correctness-test boundary
If another stream produces d_x, record an event after that production and make this stream wait on it before the launch. Synchronizing the consumer after launch does not retroactively establish the missing producer dependency. The optional examples/accelerators/hip_rmsnorm.cpp companion supplies the kernel, output pass, allocation, and test boundary; its compile/run status is recorded separately from CPU tests.
Some familiar names intentionally remain: ROCm PyTorch uses the torch.cuda interface and the cuda device type. Replacing them with an invented hip device string is not the port. Conversely, low-level masks need an actual audit: HIP documents unsigned 64-bit warp masks even for 32-lane targets. Consult PyTorch HIP semantics and the release-matched HIP language extensions, rather than making a global textual substitution.
Follow the time before collecting counters¶
Start with an unprofiled correctness run and warm timings, then capture host calls, dispatches, and copies. On current ROCm, the ROCprofiler-SDK workflow uses rocprofv3; older rocprof/rocprofv2 tooling is marked deprecated. The SDK quick reference gives current trace and counter commands.
Example status: Source-only rocprofv3 recipe; not run here.
rocprofv3 --version
rocprofv3 --hip-trace --kernel-trace \
--memory-copy-trace -- ./rmsnorm_bench
rocprofv3-avail list --pmc
First ask whether time disappears into host gaps, transfers, or the kernel. Only then select supported counters for that kernel. Record dimensions, strides, dtype, architecture, compiler/runtime versions, warm-up, repetition policy, and clock/power conditions. Profiled timings can include instrumentation overhead; keep the unprofiled baseline.
Parameterize subgroup participation explicitly¶
A portable block reduction cannot replace CUDA's literal 32 with a different number in only the lane-index expression. Subgroup width determines the shuffle tree, the count of partials, the neutral lanes in the final reduction, and the launch divisibility requirement. Write these as a single contract: for width W and block size B, a full-subgroup implementation requires B mod W=0, allocates B/W partials, and proves that the final subgroup has enough lanes or performs multiple rounds.
If the target's subgroup width is selected at compile time, compile and test each supported choice. If it is variable, choose an API whose collectives describe the actual subgroup instead of assuming a fixed mask representation. The numerical operation can remain identical while the barrier scope and scratch-allocation contract change. A translation that preserves source syntax but violates those contracts is not a correct port.
Other execution models¶
The optional accelerator platform notes cover TPU/Pallas and Trainium/Neuron/NKI. Their tile and compilation models require target-specific work; a translated CUDA kernel does not establish compatibility. The remainder of this chapter returns to model state, compiled variants, and deployment acceptance.