device-code-review
Skill561 starsChanged 8 months agoMITView on GitHub
Review MSCCL++ CUDA/HIP device-side changes for correctness, memory safety, races, synchronization, memory ordering, communication semantics, data types, portability, and concrete GPU performance issues. Use when reviewing pull requests or code that changes kernels, device functions, low-level GPU communication paths, or their host launch context.
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
Show its rules and text
We split this skill into the rules it gives an agent
27 rules. About 0 are common, 24 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈24
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 13
Check indexing, bounds, pointer arithmetic, alignment, aliasing, lifetime, and data layout assumptions.
- Distinctive: line 19
Verify that every barrier is reached convergently by the required participants.
- Distinctive: line 20
Check that warp-, block-, device-, and system-scoped operations use the appropriate scope.
- Distinctive: line 21
Verify release/acquire ordering, fences, atomics, asynchronous copies, and completion waits.
- Distinctive: line 25
Check local, IPC/peer-mapped, and PortChannel paths independently.
- Distinctive: line 26
Verify single-writer contracts, remote offsets, source/destination rank mapping, and epoch or buffer reuse.
- Distinctive: line 30
Look for load imbalance, poor coalescing, unnecessary serialization, excessive atomics, divergence, redundant synchronization, and …
- Distinctive: line 31
Check launch geometry, occupancy constraints, register/shared-memory pressure, and warp utilization.
- Distinctive: line 38
Check that host configuration, device views, transport state, synchronization state, and workspace metadata have clear, non-overlapping …
- Distinctive: line 40
Prefer reusing, merging, or removing structures when they do not have a distinct semantic, ownership, or lifetime boundary.
- Very specific: line 43
Prefer the portable scalar types, vector types, DataType, mscclpp::to, mscclpp::bit_cast, and other helpers from …
- Very specific: line 44
Search gpu_data_types.hpp before recommending a new packed type, alias, bit representation, clipping operation, or numeric conversion.
- Very specific: line 45
If a required reusable type or conversion helper is missing, recommend adding a documented CUDA/HIP-compatible definition or function to …
- Distinctive: line 46
Keep unavoidable backend-native types and intrinsics isolated at hardware or ABI boundaries, and convert to MSCCL++ types at the boundary.
- Distinctive: line 49
Check CUDA/HIP portability and architecture guards when the code is not intentionally backend-specific.
- Distinctive: line 50
Prefer existing MSCCL++ helpers and established patterns when they preserve the required low-level semantics.
- Distinctive: line 59
Check whether existing barriers, atomics, or API guarantees already prevent the issue.
- Distinctive: line 64
Do not reject raw kernels or device intrinsics merely because a higher-level API exists.
- Distinctive: line 65
Do not flag a single-thread control loop when its cost is negligible or parallelization would add synchronization.
- Distinctive: line 66
Do not recommend removing a barrier without proving that all dependent reads and writes remain ordered.
- Distinctive: line 67
Do not assume CUDA behavior applies to HIP, or vice versa.
- Distinctive: line 68
Do not enforce naming or style preferences that are not established by the repository.
- Distinctive: line 69
Do not merge structures solely to reduce the type count.
- Distinctive: line 70
Do not replace a raw backend type when it is required by an intrinsic, assembly constraint, hardware format, or external ABI.
- Distinctive: line 71
Do not produce speculative performance claims without explaining the bottleneck.
- Distinctive: line 82
If there are no high-confidence findings, say so directly and note only material residual risks or validation gaps.
- Distinctive: line 84
Ask for clarification only when correctness depends on an undocumented external contract, target architecture, transport capability, or …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Device Code Review
Perform a read-only review of MSCCL++ device-side code. Review CUDA and HIP kernels, device functions, low-level communication paths, and the host launch code needed to establish their execution context. Do not modify code as part of the review.
Review Priorities
- Correctness and memory safety
- Check indexing, bounds, pointer arithmetic, alignment, aliasing, lifetime, and data layout assumptions.
- Trace ownership of every shared or remotely visible buffer, flag, counter, and queue entry.
- Identify races, deadlocks, hangs, early publication, duplicate publication, and stale-data hazards.
- Thread and synchronization semantics
- Map work across lanes, warps, warp groups, blocks, and cooperative grids.
- Verify that every barrier is reached convergently by the required participants.
- Check that warp-, block-, device-, and system-scoped operations use the appropriate scope.
- Verify release/acquire ordering, fences, atomics, asynchronous copies, and completion waits.
- Communication correctness
- Confirm payload writes complete before readiness signals are published.
- Check local, IPC/peer-mapped, and PortChannel paths independently.
- Verify single-writer contracts, remote offsets, source/destination rank mapping, and epoch or buffer reuse.
- Inspect the relevant MSCCL++ primitive semantics before recommending lower-level replacements.
- Performance
- Look for load imbalance, poor coalescing, unnecessary serialization, excessive atomics, divergence, redundant synchronization, and avoidable global-memory traffic.
- Check launch geometry, occupancy constraints, register/shared-memory pressure, and warp utilization.
- Review asynchronous pipelines for overlap, dependency, and buffer-reuse hazards.
- Report performance concerns only when the mechanism and likely impact are concrete.
- Structure and boundary design
- Flag redundant structures that duplicate fields, mirror another type, or only forward state without defining a distinct abstraction.
- Require each structure to have one coherent responsibility, explicit ownership or borrowing semantics, and invariants that it can maintain within its own boundary.
- Check that host configuration, device views, transport state, synchronization state, and workspace metadata have clear, non-overlapping roles.
- Identify designs that require callers to coordinate hidden invariants across multiple structures.
- Prefer reusing, merging, or removing structures when they do not have a distinct semantic, ownership, or lifetime boundary.
- Data types and conversions
- Prefer the portable scalar types, vector types,
DataType,mscclpp::to,mscclpp::bit_cast, and other helpers frominclude/mscclpp/gpu_data_types.hppover raw CUDA/HIP types or locally duplicated conversion code. - Search
gpu_data_types.hppbefore recommending a new packed type, alias, bit representation, clipping operation, or numeric conversion. - If a required reusable type or conversion helper is missing, recommend adding a documented CUDA/HIP-compatible definition or function to
include/mscclpp/gpu_data_types.hppinstead of an ad hoc helper in a kernel file. - Keep unavoidable backend-native types and intrinsics isolated at hardware or ABI boundaries, and convert to MSCCL++ types at the boundary.
- Prefer the portable scalar types, vector types,
- Portability and maintainability
- Check CUDA/HIP portability and architecture guards when the code is not intentionally backend-specific.
- Prefer existing MSCCL++ helpers and established patterns when they preserve the required low-level semantics.
- Flag confusing naming or duplication only when it increases correctness or maintenance risk.
Review Method
- Establish the kernel's purpose, launch configuration, input/output layout, and synchronization contract.
- Inspect call sites, configuration code, related helpers, and producer/consumer kernels before drawing conclusions.
- Trace representative execution paths, including empty work, partial warps, uneven expert/token distributions, local peers, remote peers, and buffer rollover.
- For each suspected issue, identify the exact failing interleaving, input, architecture, or configuration.
- Check whether existing barriers, atomics, or API guarantees already prevent the issue.
- Report only findings that are actionable and supported by the code.
Avoid Incorrect Review Heuristics
- Do not reject raw kernels or device intrinsics merely because a higher-level API exists.
- Do not flag a single-thread control loop when its cost is negligible or parallelization would add synchronization.
- Do not recommend removing a barrier without proving that all dependent reads and writes remain ordered.
- Do not assume CUDA behavior applies to HIP, or vice versa.
- Do not enforce naming or style preferences that are not established by the repository.
- Do not merge structures solely to reduce the type count; preserve types that enforce a meaningful invariant or boundary.
- Do not replace a raw backend type when it is required by an intrinsic, assembly constraint, hardware format, or external ABI; isolate and document that boundary instead.
- Do not produce speculative performance claims without explaining the bottleneck.
Output Format
List findings in descending severity. For each finding provide:
severity - file:line - concise title- The concrete correctness or performance impact.
- The execution scenario that triggers it.
- A specific fix or safer design direction.
If there are no high-confidence findings, say so directly and note only material residual risks or validation gaps. Do not create empty category sections, repeat the code, or include style-only noise.
Ask for clarification only when correctness depends on an undocumented external contract, target architecture, transport capability, or performance requirement that cannot be established from the repository.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

