Conversation
KDARecoverSSMCommitContext stores raw device pointers in a torch.int64 tensor. XPU hands out USM addresses above 2**63 (e.g. 0xffffd556b6400000), which a signed int64 tensor cannot hold, so building the metadata raises "ValueError: Overflow when unpacking long long" before any kernel runs. Reuse the two's-complement rewrite already used for the same problem in vllm/v1/worker/mamba_utils.py (vllm-project#48109) and vllm/device_allocator/xpumem.py. The kernels recover the address with tl.pointer_type, which reinterprets the word rather than converting it, so the wrapped value round-trips exactly. The helper is the identity below 2**63, leaving CUDA and ROCm unchanged. _base_addrs is the single funnel for all four pointer buffers, so one call site covers the conv-state, checkpoint, correction-cache and kg-cache addresses. Block, dim and token strides stay int64: they are small signed element counts, not addresses. Signed-off-by: pmanczak <pawel.manczak@intel.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Purpose
KDARecoverSSMCommitContextstores raw device pointers in atorch.int64tensor. XPU USM addresses exceed
2**63, so building the metadata raises beforeany kernel launches:
Not a regression:
recoverssm.pyhas one commit ever (#51855), which added thecode and the failing tests together. CUDA/ROCm pointers are always below
2**63.Fix
Wrap
data_ptr()in the two's-complement rewrite the tree already uses twice forthis exact problem —
_reinterpret_u64_as_i64invllm/v1/worker/mamba_utils.py(#48109) and
_to_i64_ptrinvllm/device_allocator/xpumem.py. The kernelsrecover the address via
tl.pointer_type, which reinterprets rather thanconverts, so the wrapped value round-trips. Below
2**63the helper is theidentity, leaving CUDA/ROCm provably unchanged.
_base_addrsis the single funnel for all four pointer buffers. Strides stayint64— they are element counts, not addresses. Deduplicating the three copiesis RFC #50834's scope (open, unimplemented); this PR stays on the bug.
Not a duplicate
is:pr is:open recoverssm(#55688, #55215, #54495, #54255, #54103, #53298) andis:pr is:open pointer overflow xpu— none touches device pointers in this file.RFC #50834 has no implementation and does not mention K3.
Test plan and result
Arc Pro B70, torch 2.13.0+xpu, triton 3.7.2. Tested file sha256-matched to the
committed blob.
The 11 skips are pre-existing platform gates, unchanged. No CUDA run: the change
is an identity below
2**63.The reachable XPU config is
Kimi-Linear-48B --use-replayssm --num-speculative-tokens N --mamba-backend triton— the validator acceptsKimiLinearForCausalLMand requires the Triton mamba backend. I have not runthat end-to-end; it needs TP=4 and my box is single-card.
Model evaluation
N/A: a provable no-op on CUDA/ROCm, and on XPU the path raised before any kernel
ran, so there is no prior behaviour to compare against. The four existing tests
check RecoverSSM against a reference, not just the absence of a crash.
AI assistance
AI assistance (Claude Code) was used for the investigation, the XPU measurements
and this description. As the submitting human I reviewed every changed line.