GPU kernels to accelerator architecture

Build plan / portfolio roadmap · Jul 2026

A five-stage path from moving one vector correctly to explaining how an inference accelerator should move model state. The goal is not a wall of solved exercises. It is a compact body of reproducible evidence that I can reason across CUDA, Triton, profiling, model serving, simulation, and hardware/software co-design.

Status: build plan, not a benchmark report. Nothing below claims a completed kernel, a measured speedup, or an affiliation with an accelerator company. Every number is a completion gate. When a project ships, the target should be replaced by a result linked to its commit, raw benchmark data, and profiler capture.

A hiring manager should be able to answer three questions from this portfolio: can I make a kernel correct, can I locate the real performance limit, and can I turn that diagnosis into a better mapping between a model and a machine? The supplied LeetGPU backlog is useful because it spans all three levels, from coalesced loads to a complete Llama block and then to graph algorithms and multi-agent simulation. The ordering below turns that breadth into one argument instead of a collection of unrelated solutions.

The evidence contract

All stages share one benchmark harness. That matters more than the language used for any one solution. A CUDA implementation exposes the machine model directly; a Triton implementation tests whether the same blocked algorithm can be expressed productively. Both feed the same oracle, shape matrix, timer, profiler, and report.

Evidence Required protocol
Correctness Compare with an independent CPU, PyTorch, cuBLAS, cuDNN, or CUB oracle. Include zero/one-length inputs, odd dimensions, prime-like sizes, non-contiguous layouts, and seeded random cases. Run Compute Sanitizer before publishing.
Timing Warm up at least 50 launches, then time at least 500 launches or one second of steady-state work with CUDA events. Publish median and p95 latency; state whether transfers and allocations are included.
Baseline Measure the reference in the same process and run. Record GPU, driver, toolkit, clocks or power mode, dtype, shapes, compiler flags, and git commit. Never compare numbers copied from another machine.
Model Predict useful FLOPs, requested HBM bytes, arithmetic intensity, and launch count before profiling. Preserve raw JSON or CSV so every chart can be regenerated.
Profile Attach one focused Nsight Compute capture: memory sectors and throughput for bandwidth kernels; occupancy, stalls, shared-memory conflicts, and tensor-core utilization where those mechanisms are relevant.

The shape suite has two jobs. Canonical powers of two make regressions easy to compare, while awkward shapes reveal tail predicates, alignment assumptions, excessive padding, and kernels tuned to one demo. A result is not ready for the portfolio if it silently drops the awkward cases.

Five-stage GPU portfolio learning ladder Five cards rise from memory movement through collective primitives, tiled compute, transformer inference, and complete parallel systems. Every stage rests on the same evidence harness. 1 Move bytes coalescing · layout transactions · tails 2 Combine reduce · scan shuffle · atomics 3 Reuse tiles GEMM · convolution shared memory · MMA 4 Fuse a model attention · KV cache quantization · decode 5 Run systems graph · sort · agents irregular scheduling oracle → byte/FLOP model → benchmark → profile → explanation
The ladder adds mechanisms without discarding earlier ones. A transformer block still succeeds or fails on the coalescing, reductions, and tiled matrix math learned below it.

Stage 1 · Memory transactions and coalescing

Architecture question: which addresses does one warp request, how many memory transactions serve it, and which bytes are moved without doing useful work?

Start with Vector Addition, Matrix Copy, Matrix Addition, Matrix Transpose, Reverse Array, and Interleave Arrays. Color Inversion and RGB to Grayscale make vectorized loads and packed layouts visible. ReLU, Leaky ReLU, Sigmoid, SiLU, Value Clipping, GEGLU, and SwiGLU then show that adding arithmetic often changes nothing because the kernel is still waiting on bytes.

Each task gets a deliberately poor version and a corrected version: scalar versus vectorized access, aligned versus offset input, row- versus column-major traversal, and a branchy tail versus a predicated tail. The write-up should predict transaction count before opening the profiler, then reconcile the prediction with requested and actual sectors.

Completion gate

  • Exact output for copy, reorder, and integer image transforms; fp32 activations within atol=1e-6 and rtol=1e-5 of the reference across aligned, one-element-offset, odd, and larger-than-L2 inputs.
  • Define B_copy from a same-run, warmed, coalesced copy kernel. For inputs of at least 64 MiB, target at least 90 percent of B_copy for Matrix Copy, 75 percent of the byte-derived roof for Vector Addition, and 70 percent for an out-of-place tiled Matrix Transpose.
  • Publish one profile pair in which the optimized mapping reduces sectors per request relative to the intentional anti-pattern. The profile, rather than a generic claim about coalescing, is the evidence.

Stage 2 · Reductions, scans, and selection

Architecture question: when thousands of lanes contribute to one answer, where does synchronization happen and how much intermediate state crosses shared memory or HBM?

The core sequence is Reduction, Dot Product, Prefix Sum, Segmented Exclusive Prefix Sum, and Stream Compaction. Histogramming exposes atomic contention; Count Array Element and the 2D/3D count variants test indexing; Top K Selection, Max Subarray Sum, and Softmax connect collective primitives to model serving. Subarray Sum and its 2D/3D forms are useful checks that the indexing layer remains separate from the collective.

Build a progression from a global-memory tree to shared-memory blocks, warp shuffles, and a multi-block finalization. Record work, depth, launch count, and bytes for every version. For scans, explain the trade between a work-efficient tree and extra synchronization. For histograms, publish both uniform random keys and a single-bin adversary so atomics are not evaluated only on a friendly distribution.

Completion gate

  • Use an fp64 CPU oracle for fp32 reductions and require relative error no worse than 5e-5; integer scans, compaction indices, counts, and histograms must match exactly. Test sizes immediately around block and warp boundaries.
  • At 16 million elements, target at least 70 percent of B_copy as effective bandwidth for Reduction and at least two-thirds of same-run CUB DeviceScan throughput for Prefix Sum.
  • Preserve a profile that accounts for every full-array pass and demonstrates that the final version has no unexplained global round trip. Report deterministic and fastest variants separately when floating-point reduction order changes.

Stage 3 · Tiled linear algebra and convolution

Architecture question: how many multiply-accumulates can be extracted from each HBM byte before registers, shared memory, occupancy, or the compute units become the next limit?

Matrix Multiplication grows into a basic GEMM, Batched Matrix Multiplication, FP16 Batched Matrix Multiplication, INT8 Quantized MatMul, and INT4 weight-only MatMul. Sparse Matrix-Vector and Sparse Matrix-Dense Matrix Multiplication make the cost of metadata and imbalance explicit. The spatial branch covers 1D, 2D, and 3D Convolution, Gaussian Blur, 2D Max Pooling, Batch Normalization, and Group Normalization. Ordinary Least Squares and Logistic Regression exercise composition rather than adding a new primitive.

The implementation ladder should be visible in code and charts: naive global-memory GEMM, shared-memory blocking, register tiling, vectorized and asynchronous copies where supported, then a Tensor-Core or Triton version. Rectangular decoder shapes matter as much as square textbook matrices. Every quantized kernel must state accumulator width, scale granularity, rounding, saturation, and the bytes consumed by scales and zero points.

Completion gate

  • Test square, rectangular, batched, non-multiple-of-tile, and transposed layouts. Compare fp32 against an fp64 oracle with a documented size-aware tolerance; compare int8 accumulation exactly before requantization.
  • On a documented 4096 × 4096 × 4096 fp32 case, target at least 10× the naive in-repo kernel and 50 percent of same-run cuBLAS SGEMM. A second chart must include decode-like skinny matrices, even if that exposes a much larger gap.
  • Close the stage only after one convolution and one GEMM include an arithmetic-intensity calculation, a measured roofline point, shared-memory bank-conflict data, and an explanation of the remaining library gap.

What the ladder is really optimizing

The roofline does not prescribe an optimization; it prevents the wrong one. A point far below the sloped bandwidth roof may have poor access or insufficient parallelism. A point on that roof needs fewer HBM bytes, not more FLOPs. Tiling, fusion, quantization, and keeping weights or KV state closer to compute all move a workload toward the right by increasing useful work per off-chip byte.

Schematic roofline and data-movement hierarchy A roofline plot places memory operations, scans, tiled GEMM, transformer decode and prefill, and irregular graph work under bandwidth and compute ceilings. A side stack shows registers, shared memory, L2 cache, and HBM. Schematic roofline HBM bandwidth ceiling compute ceiling arithmetic intensity · useful FLOP / HBM byte → attainable throughput → S1 · copy / transpose S2 · reduce / scan S3 · tiled GEMM S4 · decode S4 · fused prefill S5 · irregular graph reuse · fusion · lower precision Data placement Registers lane-private · fastest Shared memory block reuse · explicit L2 cache chip-wide · managed HBM largest · off-chip traffic capacity and reuse distance increase ↓
Conceptual map, not measured data. Published artifacts should put real axes, ceilings, and counter-derived points on this shape for the exact GPU used.

Stage 4 · Transformer inference kernels

Architecture question: which tensors should be fused, cached, quantized, or sharded differently in prefill and decode, and what does each decision save in bytes, launches, and latency?

Begin with Token Embedding, RMS Normalization, Rotary Positional Embedding, Softmax Attention, and a SwiGLU MLP Block. Add Multi-Head and Causal Self-Attention, Grouped Query Attention, Sliding Window Attention, ALiBi, and INT8 KV-Cache Attention. The serving path then needs Weight Dequantization, INT4 weight-only MatMul, LoRA Linear, MoE Top-K Gating, Top-p Sampling, and Speculative Decoding Verification. A GPT-2 block and a Llama-style block are integration tests, not separate résumé bullets.

SSM Selective Scan and Causal Depthwise Conv1d are valuable stretch kernels because they test whether the harness generalizes beyond attention. Linear, decaying-causal, and sliding-window attention should be compared by state size and data movement, not placed in a single “attention” bucket. The final report separates time to first token from inter-token latency, because prefill and decode occupy different parts of the roofline.

Completion gate

  • Cover batches 1 and 8, sequence lengths 1, 128, 2,048, and 16,384 where memory permits, hidden sizes 1,024 and 4,096, odd head counts, and both causal and padded inputs. State fp32, fp16, and quantized tolerances separately; target cosine similarity of at least 0.999 for the dequantized INT8 KV-cache attention output.
  • Fuse at least one real chain, such as residual plus RMSNorm or dequantization plus linear. Against the unfused in-repo path, target at least 20 percent fewer profiler-reported HBM bytes and 15 percent lower median latency on one predeclared shape.
  • Benchmark the complete Llama-style block against eager PyTorch and torch.compile in the same run. Publish p50 and p95 latency, tokens per second, peak allocation, kernel count, prompt length, KV length, and any graph breaks, even when the custom path loses.

Stage 5 · Graphs, simulation, and sorting

Architecture question: what happens when work is data-dependent, neighborhoods are irregular, queues change size, and the warp cannot follow one dense schedule?

Sorting, Radix Sort, and Parallel Merge develop partitioning and load balance. BFS Shortest Path and All-Pairs Shortest Paths add frontier management and topology-dependent locality. K-Means, Nearest Neighbor, and the Multi-Agent boids simulation turn spatial neighborhoods into a reusable uniform-grid primitive. A 2D Jacobi Stencil, Monte Carlo Integration, FFT/2D FFT, Matrix Power, and Linear Recurrence round out structured scientific workloads without pretending they share one bottleneck.

The capstone is the boids simulation: retain the exact O(N²) implementation as a small-input oracle, then add spatial binning, prefix-summed cell offsets, compacted agent lists, and a neighbor pass. That composition reuses Stages 1 and 2 and produces a simulation primitive relevant to robotics, world models, and reinforcement-learning environments.

Completion gate

  • Sorting and BFS outputs must match exact CPU references; K-Means must publish convergence criteria and seeded initialization; boids must test finite state, bounded speed, periodic boundaries, and a small-step match against the all-pairs oracle.
  • For 16 million random uint32 keys, target at least 60 percent of same-run CUB radix-sort throughput, including allocation and temporary-storage policy in the report.
  • For 100,000 uniformly distributed boids, target p95 simulation step latency below 16.7 ms. From 25,000 to 100,000 agents, the binned version must grow by less than 6×, while the retained all-pairs baseline documents the quadratic reference behavior.

The bridge to accelerator work

Etched and MatX are reference points because their public material emphasizes large-model hardware and the system around it; they are not affiliations or claims about undisclosed architectures. The public Etched site describes co-design across chips, racks, software, and manufacturing for inference. MatX publicly describes a large-model target spanning training, reinforcement learning, prefill, and decode, with weights typically in SRAM, KV state typically in HBM, scale-up/scale-out interconnect, and direct hardware control. The portfolio response should be a set of inspectable models, not speculation about either company’s silicon.

Kernel evidence Hardware question it unlocks Portfolio artifact
Coalescing, transpose, reductions How much requested traffic becomes HBM traffic? Trace-driven memory model with transactions, banks, outstanding requests, and achieved bandwidth.
GEMM, convolution, quantized MatMul Which tile, scratchpad size, precision, and stationary dataflow keep a MAC array fed? Configurable output-, weight-, and row-stationary simulator that reports cycles, reuse, bytes, and utilization.
KV attention, SwiGLU, MoE gating What belongs in SRAM versus HBM, and when does the interconnect dominate decode or expert routing? Transformer trace replay across prefill/decode and dense/MoE cases, with a latency-energy-area Pareto sweep.
Boids, BFS, sorting How much programmability is needed beside the dense engine? Workload fallback study comparing fixed-function, vector, and SIMT scheduling on irregular phases.

The hardware capstone should extend the existing FPGA matrix-multiply accelerator with a DMA-facing tiled buffer, double buffering, a quantized MAC path, and randomized verification. A companion compiler prototype can lower a small graph IR containing GEMM, RMSNorm, RoPE, attention, and elementwise fusion into tile schedules for the simulator. The minimum evidence is an analytical traffic model, tests that conserve every byte, a sweep that emits machine-readable Pareto data, and synthesis timing/resource reports clearly labeled by tool and device.

The underlying theory and measured examples already have natural homes on this site: Parallel Computing covers work-depth analysis, CUDA, Triton, scan, reduction, and tiling; Advanced Systems Architecture covers HBM, rooflines, systolic dataflows, precision, and interconnects. This roadmap turns those course-style explanations into a portfolio whose unit of progress is a reproducible artifact.

A concise project rubric

Score every published stage before calling it finished. The release gate is at least 80/100, at least 24/30 in correctness, and no missing benchmark or raw-data link.

Dimension Weight What earns the score
Correctness 30 Independent oracle, awkward shapes, stated tolerances, race/memory checks, and deterministic seeds.
Performance evidence 25 Same-run baseline, predeclared shapes, warmup and timing protocol, p50/p95, profile, and raw results.
Architecture reasoning 20 Predicted bytes/FLOPs, roofline placement, counter reconciliation, and a specific next bottleneck.
Engineering 15 Reproducible environment, CI correctness tests, parameterized kernels, readable commits, and one-command report generation.
Communication 10 One clear diagram, a result table, limitations, failed experiments, and no claim unsupported by an artifact.

A smaller project that passes this rubric is stronger hiring evidence than a long kernel checklist with no oracle, baseline, or explanation. The intended final shape is one repository, one benchmark schema, five stage reports, and one accelerator capstone that can trace every hardware choice back to a measured workload.

Primary references

  1. NVIDIA, CUDA Programming Guide and Nsight Compute Profiling Guide.
  2. Triton project, official documentation and kernel tutorials.
  3. NVIDIA CCCL, CUB documentation, used for same-run collective and sorting baselines.
  4. Etched, Frontier Inference Clusters and the official role index.
  5. MatX, official product and workload overview.