Unit 3 of 10 · about 3 hours · implement

Capability matrices, fallback and compatibility tests

A kernel without a capability contract fails at someone else's machine, not at your desk. The matrix decides before launch; the fallback keeps older hardware working.

You'll be able to

  • Build a capability matrix for your kernels: minimum compute capability, required features and the runtime query that detects each.
  • Implement dispatch with a correct portable fallback and an explicit error on unsupported paths, tested on every branch.
  • Explain PTX compatibility and fatbin contents: what runs where, what JIT-compiles at load, and what fails.

Covers

Device, compiler, library and feature capability matrixCorrect fallback, unsupported-path errors and compatibility tests
1

Read

In this order, only the parts listed

0 of 3 done

  1. Runtime capability queries and feature targetsCUDA Toolkit and Architecture Tuning Guides

    Section 5.1.1: the runtime query triplet (cudaDeviceGetAttribute with cudaDevAttrComputeCapabilityMajor, the driver query and the NVML query); Section 5.1.2: architecture-specific versus family-specific features and compiler targets (baseline, family and arch-only)

  2. Binary compatibility, PTX compatibility and JIT compilationCUDA Toolkit and Architecture Tuning Guides

    Section 1.3.4, Cubins and Fatbins, with Binary Compatibility, PTX Compatibility and Just-in-Time Compilation (CUDA 13.4.2 documentation): what a fatbin carries, what compiles at load, and what fails on newer hardware

  3. Dispatch and fallback contractGPU Microbenchmark and Kernel Suite - Final Evaluation

    Architecture constraints: dispatch never selects an unvalidated shape, dtype or device path, and every custom path has a correct fallback; Milestone F: defend the dispatch, fallback and maintenance choice for each kernel family

2

Focus on

  • Query at runtime, branch on the answer, and test both sides. The check and the fallback are one unit; an untested fallback is a second implementation with zero evidence.
  • Family targets run across the family; arch-only targets run on one architecture. Code built only for an arch-only target such as sm_100a loads on that architecture alone, and every other GPU fails at load with no kernel image unless the fatbin carries another target.
  • PTX in the fatbin is the forward-compatibility path. A cubin runs on later minor versions of its major version; without PTX it fails on a newer major version instead of JIT-compiling at load.
  • An unsupported path must error loudly at the owning API boundary with the capability and feature named, never silently run a wrong kernel.
Common mistakes · 3
  • Compiling only with -arch=sm_86 and calling it portable. That flag emits one sm_86 cubin plus compute_86 PTX: newer GPUs JIT-compile the PTX, older ones have nothing they can run, and native code on newer GPUs needs their own cubins.
  • Checking the driver version instead of the device capability. The device answers through the attribute query; the driver version does not know the chip.
  • Reading the marketing architecture name in code. Code branches on the numeric capability the query returns, not on Ampere or Hopper as strings.
3

Try it yourself

Closed-book, before checking anything

From a blank file, write the capability query plus dispatch for a kernel with a newer-architecture-only path and a portable fallback: correct results on your GPU through whichever path it supports, the fallback selected when the feature query is forced off, an explicit error when forced below the portable minimum, and tests covering all three branches.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.What does cudaDevAttrComputeCapabilityMajor return on your GPU, and which call reads it?Answer

    On an RTX 3050 6 GB it returns 8, read with cudaDeviceGetAttribute for the device, and the minor attribute returns 6. Read both on your GPU and branch on the pair, not on the card name.

  2. 2.Your kernel needs thread-block clusters. Which table gives the minimum capability, and what must the fallback do?Answer

    The feature-support table in Section 5.1.3. The fallback runs a non-cluster path or returns an explicit unsupported error, selected by the runtime query, with both branches tested.

  3. 3.A fatbin holds only an sm_90 cubin and no PTX. What happens on sm_86 and on sm_100 hardware?Answer

    Neither can use that cubin, and with no PTX there is nothing to JIT-compile at load. Ship per-architecture cubins plus PTX, or restrict the matrix honestly.

  4. 4.Why must the unsupported-path error name the capability and the feature?Answer

    So a report distinguishes a missing feature from a wrong dispatch, and the matrix gains a row without guessing which check failed.

You're done when

Your dispatch matrix passes on your GPU, selects the fallback when the feature query is forced off, and errors loudly when forced below the minimum.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 12 more in the section
  • GPU Microbenchmark and Kernel Suite - Final EvaluationRoadmap-Final · required

    Complete Milestones C through F: CUDA and Triton kernel suite, failure injection, model-versus-profile reconciliation, strong baselines, real integration, full shape matrix, dispatch and fallback defense, clean reproduction and negative results.

  • CUDA Toolkit and Architecture Tuning GuidesNVIDIA · reference

    Use the current toolkit root, release notes and the tuning guide matching the measured GPU. Pin the document and toolkit versions, verify capability checks and rerun any claim affected by compiler or architecture change.

Also in this section

  • AI Systems Performance Engineering - Chapters 2, 19 and 20 and the Appendix checklistChris Fregly · primary

    Read Chapter 2 for hardware generations, Chapters 19 and 20 on adaptive engine optimization and AI-assisted optimization, and use the Appendix checklist as an audit list for the final project. Treat every performance number as a hypothesis requiring your own evidence.

  • AI Performance Engineering - Hardware, Frontier and Source PolicyWafer · reference

    A dated map of current hardware and frontier work. Apply its Source Policy to every final claim, and use the hardware and frontier sections only to find primary documentation.

  • Performance Engineering and GPU Programming CheckpointRoadmap-Final · support

    Use the checkpoint as the final adversarial assessment after the source-derived route. Pass the real kernel, compiler or communication modification and end-to-end evidence clauses; ignore its ordering where it conflicts with this track.

  • KernelBench-VerifiedKernelBench-Verified Authors · required

    Study the evaluator hardening and baseline-parity failures found in the original benchmark. Run a very small task slice or port its adversarial testing ideas into the project evaluator; do not optimize for aggregate benchmark score.

  • SOL-ExecBenchNVIDIA · support

    Inspect how correctness and performance are compared with a hardware speed-of-light model. Apply one attainable-efficiency analysis to a project kernel and explain missing hardware or model assumptions.

  • MLPerf EndpointsMLCommons · support

    Read the endpoint-level scenario and load-generation rules. Borrow the workload and result-boundary discipline for the integrated benchmark without claiming an official MLPerf result.

  • MIT 6.S894 Accelerated Computing (Fall 2025) - Lecture 10MIT · support

    Use Lecture 10 (Accelerated Computing Beyond NVIDIA and CUDA) for AMD GPUs, TPUs, NPUs and higher-level kernel languages as portability vocabulary.

  • Modern GPU Programming for MLSysMLC · depth

    Use the Blackwell GEMM and Flash Attention path as a real architecture-specific reconstruction target if compatible hardware is available. Otherwise produce a static mechanism audit and leave all performance claims open.

  • KernelBench - benchmark toolkit and task suiteScalingIntelligence · support

    Clone the repository and check one Level 1 problem with scripts/run_and_check.py in local mode; read EVAL.md for the correctness and timing guidance. Do not chase the aggregate score.

  • Etalon - holistic evaluation for LLM inferenceGeorgia Tech, Microsoft Research India and Intel AI Lab · support

    Read Section 2.2 for TTFT and TPOT pitfalls, then the fluidity-index design (Section 4.1) for deadline-based, SLO-qualified capacity.

  • ROCm Composable KernelAMD · support

    Read the repository README for the tile-based programming model, Tensor Coordinate Transformation and the four CK layers; open one tiled operator and map each CUDA term to its CK counterpart.

  • DistServe: Disaggregating Prefill and Decoding for Goodput-optimized LLM ServingZhong et al. (OSDI 2024) · support

    Read Section 1 with Figure 1 for per-GPU goodput: the highest request rate served while a target share of requests meets the TTFT and TPOT SLOs.