fix(ds4): correct HC shard handoff and scope runtime caches per shard#507
Draft
Graffioh wants to merge 2 commits into
Draft
fix(ds4): correct HC shard handoff and scope runtime caches per shard#507Graffioh wants to merge 2 commits into
Graffioh wants to merge 2 commits into
Conversation
Contributor
|
We plan to run two AMD GPUs in the same HIP process. g_scratch is currently shared across devices, so the second shard may reuse scratch memory allocated on the first GPU. Please keep one scratch buffer per HIP device, set the correct device in HC worker threads |
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
Fixes two correctness issues in the DeepSeek4 HC-complete layer-range path:
DeepSeek4CacheStack
The layer-range implementation corrected here is introduced by #503.
Handoff correctness
The layer-range input has two different contracts:
n_tokens × n_embdn_tokens × n_hc × n_embdThe local multi-shard path previously passed
embed.data()to every shard. Later shards therefore interpreted the original embedding buffer as a full HC tensor, instead of consuming the HC state updated by the preceding layer range.The corrected local flow is:
Local shards share
hc_state_in place. The layer-range step now detects that the boundary input aliaseshc_state.data()and avoids an unnecessary copy or a resize that could invalidate the input pointer. IPC shard boundaries continue to copy from their separate boundary-activation buffer.Per-shard runtime cache
The HC weights and cached decode graphs used by
deepseek4_step_layer_range()were previously function-localstaticobjects shared by every shard in the process.That cache was keyed only through partial context checks and was reset as execution alternated between shards with different:
The runtime state now belongs to each shard's
DeepSeek4Cacheand is matched against the complete shard identity:Each shard loads only the HC weights for its assigned layer range. Only the final shard loads the HC output weights.
Commits
a68112a— hand off full HC state between local shardsb6e50aa— scope HC runtime caches per shardValidation
6c7ee19)git diff --check: passedtest_deepseek4_unitanddflash_server[0,22)and[22,43)oncuda:0SIGSEGV, orSIGABRTerrors