Skip to content

fix: make device header self-contained#51

Open
voltjia wants to merge 1 commit into
masterfrom
fix/include-cstdint-for-memory-space
Open

fix: make device header self-contained#51
voltjia wants to merge 1 commit into
masterfrom
fix/include-cstdint-for-memory-space

Conversation

@voltjia

@voltjia voltjia commented Jul 17, 2026

Copy link
Copy Markdown

Summary

Make src/device.h self-contained by including <cstdint> directly and using std::uint8_t as the underlying type of MemorySpace.

This removes reliance on a transitive declaration of uint8_t. It does not add collective functionality or change runtime behavior, enum values, or supported platforms and backends.

Changes

  • Header dependency

    • Include <cstdint> directly in src/device.h.
  • Fixed-width type

    • Qualify the underlying type of MemorySpace as std::uint8_t.

Platform and Backend Affected

src/device.h is shared by every device implementation and the common communication paths, so all supported configurations are affected at compile time. Runtime behavior is unchanged.

Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU

Backend

  • OpenMPI
  • MPICH
  • NCCL
  • MCCL

Performance Impact

  • No performance impact
  • Performance improved
  • Performance regression possible

N/A. This change only makes a header dependency explicit and preserves the existing fixed-width enum representation.

Known Issues & Future Work

  • No known issues are introduced by this change.
  • Runtime validation for this PR is limited to NVIDIA GPU with NCCL. Other affected platform/backend combinations were not exercised.
  • This PR does not add or expand collective, platform, or backend functionality.

Test Results

Environment:

  • Container: accelerator-dev/nvidia:latest (NVIDIA PyTorch 25.12)
  • Hardware: 2 x NVIDIA A100-SXM4-80GB
  • Configuration: NVIDIA device with NCCL backend, two local ranks

Results:

  • clang-format-16 --dry-run --Werror src/device.h: passed.
  • ruff check .: passed.
  • ruff format --check .: passed.
  • Standalone C++17 compilation including only src/device.h: passed.
  • scripts/run_examples.py for ccl/all_reduce: passed with two NVIDIA GPUs.
  • Downstream InfiniLM Qwen3-0.6B inference: passed with tensor parallelism 1 and 2.

The applicable example was run as:

python scripts/run_examples.py \
    --config /workspace/ccl-cluster.yaml \
    --examples ccl/all_reduce \
    --log-path /workspace/ccl-example-logs \
    --timeout 600 \
    -- -g 2 -w 1 -p 1 -n 1048576

Generated ccl_all_reduce.log result:

[Main Process] Host: master | Target GPUs: 2

=== AllReduce Results ===
Correct: YES
Expect:  3.00
Actual:  3.00

=== Single-Node Threaded AllReduce Results ===
Data size: 1048576 floats (4 MB)
Time:           0.119 ms
Throughput:     32.71 GB/s (Bus BW)
Alg Bandwidth:  32.71 GB/s

[Main Process] All worker threads joined. InfiniCCL finalized safely.

Test Involved Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU

Test Involved Backend

  • OpenMPI
  • MPICH
  • NCCL
  • MCCL

Checklist

Title, Branch, and Commits

  • PR title follows Conventional Commits.
  • Branch name follows <type>/xxx-yyyy-zzzz, with the type matching the PR title.
  • Each commit message follows Conventional Commits.
  • This small PR is a single squashable commit.
  • The branch is rebased cleanly on top of the current master with no stray merge commits.
  • No fixup!, squash!, or wip commits remain.

Scope and Design

  • Changes are minimal and contain no unrelated modifications.
  • No dead code, commented-out blocks, debug prints, or unowned TODO items were introduced.
  • No unrelated formatting churn obscures the diff.
  • N/A - Public API behavior, ABI, and enum values are unchanged.

General Code Hygiene

  • The change is self-explanatory and needs no additional comment.
  • The modified file ends with a single trailing newline.
  • No trailing whitespace, inconsistent indentation, or mixed formatting styles remain.
  • N/A - No comments or error messages were added or modified.
  • N/A - No comments or error messages were added or modified.
  • N/A - No comments or error messages were added or modified.

C++ Specific (if C++ files changed)

  • Code follows the Google C++ Style Guide.
  • clang-format version 16 has been run against the modified file; the diff is clean.
  • N/A - No exception or error path was added or modified.
  • N/A - No error or warning message was added or modified.
  • N/A - No constructor or initializer list was added or modified.
  • N/A - No class or function spacing was changed.
  • N/A - No class member spacing was changed.
  • N/A - No namespace layout was changed.

Python Specific (if Python files changed)

  • N/A - No Python files changed.
  • N/A - No Python files changed.
  • N/A - No Python comments changed.
  • N/A - No Python framework-specific messages changed.
  • N/A - No Python function signatures changed.
  • N/A - No Python control flow changed.
  • N/A - No Python return statements changed.
  • N/A - No Python docstrings changed.
  • N/A - No Python type hints changed.

Testing

  • The applicable example program was built and tested successfully with two NVIDIA GPUs and NCCL.

Build, CI, and Tooling

  • N/A - No backend, device, or auto-detection logic changed.
  • The clang-format.yml and ruff.yml checks pass locally.

Documentation

  • N/A - No behavior, build flag, or developer workflow changed.
  • N/A - This PR has no user-visible breaking change.

Security and Safety

  • No secrets, access tokens, internal URLs, customer data, or personal hardware identifiers were committed.
  • N/A - No third-party code was added or modified.
  • No unsafe pointer arithmetic, uninitialized read, or missing bounds check was introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant