Skip to content

feat(allowlist): add CUDA (.cu/.cuh) and HIP (.hip) review support #1767

Closed

Description

@SU-AN-coder

Problem Statement

.cu / .cuh (CUDA) and .hip (AMD HIP / ROCm) are outside the allowlist, so every GPU kernel in a diff is silently dropped before review. On a repo with a modified .cu, .cuh, .hip and .cpp file, ocr delegate preview built from main (8eb8334) reports:

# Files (1 reviewable / 4 total)

~~- `kernels/attention.cu` [modified] +1/-0 (excluded: unsupported_ext)~~
~~- `kernels/attention.cuh` [modified] +1/-0 (excluded: unsupported_ext)~~
~~- `kernels/hip_softmax.hip` [modified] +1/-0 (excluded: unsupported_ext)~~
  - `src/main.cpp` [modified] +1/-0

ocr rules check kernels/attention.cu resolves the same way: Pattern: default, i.e. the generic default.md checklist, which says nothing about launch configuration, block barriers, warp-level assumptions, or stream ordering.

The repositories where OCR is most often run — vLLM, PyTorch, flash-attention, llama.cpp, CUTLASS — keep a large share of their logic in .cu files, and that share is exactly the code with device-specific failure modes.

Proposed Solution

Treat CUDA and HIP as one language group, following the merged precedent of Solidity/Vyper (#961) and Verilog/SystemVerilog/VHDL (#1050):

  • supported_file_types.json: add .cu, .cuh, .hip
  • system_rules.json: **/*.{cu,cuh} → cuda_hip.md and **/*.hip → cuda_hip.md — two patterns, one doc, the same shape as {ml,mli} and {re,rei} → ocaml.md, since HIP is the same programming model under a different runtime prefix
  • new rule_docs/cuda_hip.md covering launch configuration and error checking, shared-memory and block synchronization, warp-level programming and the memory model, bounds/shapes/type sizes, host-device-stream lifetimes, and numerics/aliasing
  • no new default exclude pattern: CUDA/HIP have no conventional test-path convention (tests/ holds production kernels in several projects, and the C++/C arms deliberately have no extension-scoped test pattern either), so an extension-scoped pattern would drop real source. The test table documents that absence instead.
  • the rule-resolution table in all five locales
  • tests: allowlist cases including case-insensitivity, IsExcludedPath cases for the deliberate non-exclusion, Resolve assertions per extension, and a ResolveDetail test pinning which pattern matched

Alternatives Considered

  • Route .cu to the existing cpp.md rules. Rejected: a kernel's real defects are the GPU-specific ones — a barrier that not all threads reach, an unsynchronized shuffle on Volta or later, an unchecked launch, a buffer touched across two streams — and none of them appear in the C++ checklist.
  • Separate cuda.md and hip.md documents. Rejected: they would state the same rules twice and drift apart; the repository already shares one document across closely related dialects (ocaml.md, verilog.md, handlebars_mustache.md).
  • Add .cu to the allowlist with no rule doc. Rejected: the files would then be reviewed under default.md, which is the current behaviour for the generic checklist and was the reason this group is worth a rule doc at all.

Affected Area

Review Rules

Additional Context

  • Tracking issue: feat(allowlist): expand supported file types — language experts wanted #470 (good first issue, help wanted)
  • CUDA and HIP do not appear in that table, and per its closing line ("Don't see your language? Comment below to propose it!") this is the proposal. No open or closed PR or issue in this repository mentions cuda, hip, or opencl.
  • Disclosure: the issue text and the linked change were drafted with the help of an AI coding agent (Hermes Agent by Nous Research, model deepseek-v4.1-flash); I read every line of the diff myself and verified it against the built CLI and the test suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions