Fix alignment for in-memory allreduce buffer#12082
Open
RAMitchell wants to merge 2 commits intodmlc:masterfrom
Open
Fix alignment for in-memory allreduce buffer#12082RAMitchell wants to merge 2 commits intodmlc:masterfrom
RAMitchell wants to merge 2 commits intodmlc:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Replaces std::string with a custom AlignedByteBuffer backed by std::max_align_t storage to guarantee proper alignment for typed reinterpret_casts during in-memory allreduce.
Changes:
- Introduced
AlignedByteBufferclass providing aligned byte storage with astd::string-like interface - Updated all functor signatures and buffer operations to use
AlignedByteBuffer - Added alignment/size checks in the allreduce path
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/collective/in_memory_handler.h | Added AlignedByteBuffer class; changed buffer_ member type |
| src/collective/in_memory_handler.cc | Updated functors to use AlignedByteBuffer; added checks; fixed Accumulate signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
trivialfis
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix alignment for the shared buffer used by in-memory collective allreduce.
The previous implementation stored bytes in a
std::stringand then reinterpreted the buffer as typed data for reduction. That provides contiguous storage, but not the alignment guarantees required for typed access. This change switches the shared buffer to aligned storage while preserving the existing byte-oriented behavior for the in-memory collective path.No intended user-facing changes.
Verification
Built
src/collective/in_memory_handler.ccin the existingbuild/tree.