[codex] Fix Kunlun Qwen2.5 greedy inference#476
Draft
zhangyue207 wants to merge 1 commit into
Draft
Conversation
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
This PR fixes the InfiniLM-side issues found while bringing up Qwen2.5-7B-Instruct single-card inference on Kunlun XPU.
Changes
LLM/InferEngine/ HF config loading so--dtype float32and other overrides are honored.kunlundevice string to the underlying InfiniCore CUDA-compatible device mapping used by the Kunlun backend.q_proj/k_proj/v_projandgate_proj/up_projmodules, keeping checkpoint parameter names direct.top_k == 1, copy logits to CPU and compute argmax there to avoid the incorrect Kunlun random sampling result.Root Cause
The main correctness issue was in static attention: Q RoPE wrote into a non-contiguous permuted tensor. Embedding and input RMSNorm matched Hugging Face exactly, but layer 0 attention diverged immediately. Switching Q RoPE to the in-place single-tensor path made layer 0 match Hugging Face within about 1e-6 and restored the expected first generated token.
Kunlun sampling also selected the wrong token even when logits were correct, so greedy decoding now uses a CPU argmax fallback for
top_k=1on Kunlun.Validation
Validated with Docker image
fixing:v1, local InfiniCore/InfiniLM builds, and model/workspace/models/Qwen2.5-7B-Instruct._infinilm.11460231.068昆仑max-new-tokens=1:11460231.06昆仑max-new-tokens=2:昆仑芯Runtime note: the verified path uses
DISABLE_XPYTORCH=1to avoid loading an incompatible XPU runtime fromtorch_xmlir. FP32 decode is currently slow, about 29 seconds per generated token in this setup.