agentleFS
MicrosoftKnown publishermicrosoft/mscclpp/.github/skills/device-code-review/SKILL.md

device-code-review

Skill578 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.

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
  1. Distinctive:

    Check indexing, bounds, pointer arithmetic, alignment, aliasing, lifetime, and data layout assumptions.

    line 13
  2. Distinctive:

    Verify that every barrier is reached convergently by the required participants.

    line 19
  3. Distinctive:

    Check that warp-, block-, device-, and system-scoped operations use the appropriate scope.

    line 20
  4. Distinctive:

    Verify release/acquire ordering, fences, atomics, asynchronous copies, and completion waits.

    line 21
  5. Distinctive:

    Check local, IPC/peer-mapped, and PortChannel paths independently.

    line 25
  6. Distinctive:

    Verify single-writer contracts, remote offsets, source/destination rank mapping, and epoch or buffer reuse.

    line 26
  7. Distinctive:

    Look for load imbalance, poor coalescing, unnecessary serialization, excessive atomics, divergence, redundant synchronization, and …

    line 30
  8. Distinctive:

    Check launch geometry, occupancy constraints, register/shared-memory pressure, and warp utilization.

    line 31
  9. Distinctive:

    Check that host configuration, device views, transport state, synchronization state, and workspace metadata have clear, non-overlapping …

    line 38
  10. Distinctive:

    Prefer reusing, merging, or removing structures when they do not have a distinct semantic, ownership, or lifetime boundary.

    line 40
  11. Very specific:

    Prefer the portable scalar types, vector types, DataType, mscclpp::to, mscclpp::bit_cast, and other helpers from …

    line 43
  12. Very specific:

    Search gpu_data_types.hpp before recommending a new packed type, alias, bit representation, clipping operation, or numeric conversion.

    line 44
  13. Very specific:

    If a required reusable type or conversion helper is missing, recommend adding a documented CUDA/HIP-compatible definition or function to …

    line 45
  14. Distinctive:

    Keep unavoidable backend-native types and intrinsics isolated at hardware or ABI boundaries, and convert to MSCCL++ types at the boundary.

    line 46
  15. Distinctive:

    Check CUDA/HIP portability and architecture guards when the code is not intentionally backend-specific.

    line 49
  16. Distinctive:

    Prefer existing MSCCL++ helpers and established patterns when they preserve the required low-level semantics.

    line 50
  17. Distinctive:

    Check whether existing barriers, atomics, or API guarantees already prevent the issue.

    line 59
  18. Distinctive:

    Do not reject raw kernels or device intrinsics merely because a higher-level API exists.

    line 64
  19. Distinctive:

    Do not flag a single-thread control loop when its cost is negligible or parallelization would add synchronization.

    line 65
  20. Distinctive:

    Do not recommend removing a barrier without proving that all dependent reads and writes remain ordered.

    line 66
  21. Distinctive:

    Do not assume CUDA behavior applies to HIP, or vice versa.

    line 67
  22. Distinctive:

    Do not enforce naming or style preferences that are not established by the repository.

    line 68
  23. Distinctive:

    Do not merge structures solely to reduce the type count.

    line 69
  24. Distinctive:

    Do not replace a raw backend type when it is required by an intrinsic, assembly constraint, hardware format, or external ABI.

    line 70
  25. Distinctive:

    Do not produce speculative performance claims without explaining the bottleneck.

    line 71
  26. Distinctive:

    If there are no high-confidence findings, say so directly and note only material residual risks or validation gaps.

    line 82
  27. Distinctive:

    Ask for clarification only when correctness depends on an undocumented external contract, target architecture, transport capability, or …

    line 84

≈ “Common” is an estimate: at least 1 in 5 of the 383,637 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Data types and conversions
    • Prefer the portable scalar types, vector types, DataType, mscclpp::to, mscclpp::bit_cast, and other helpers from include/mscclpp/gpu_data_types.hpp over raw CUDA/HIP types or locally duplicated conversion code.
    • Search gpu_data_types.hpp before 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.hpp instead 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.
  7. 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

  1. Establish the kernel's purpose, launch configuration, input/output layout, and synchronization contract.
  2. Inspect call sites, configuration code, related helpers, and producer/consumer kernels before drawing conclusions.
  3. Trace representative execution paths, including empty work, partial warps, uneven expert/token distributions, local peers, remote peers, and buffer rollover.
  4. For each suspected issue, identify the exact failing interleaving, input, architecture, or configuration.
  5. Check whether existing barriers, atomics, or API guarantees already prevent the issue.
  6. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.