[BugFix][xlite] Fix index_full_mask type checking in extract_kv_cache - #16879
Cancan0320 wants to merge 1 commit into
Conversation
extract_kv_cache() read self.xlite_config.index_full_mask directly, but XModelConfig does not statically declare that attribute (it is set dynamically in _build_model_config). mypy reports "XModelConfig" has no attribute "index_full_mask" [attr-defined], which blocks the repository-wide pre-commit/mypy job for unrelated PRs. Use the same safe getattr(self.xlite_config, "index_full_mask", None) access already used in _build_model(), falling back to a full-True mask. Runtime behavior is unchanged for all cases where the attribute is set. Fixes vllm-project#16658 Signed-off-by: cancan <luckycan@foxmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a static type-checking failure in the 'DeepseekV32XliteModel' class. By using 'getattr' to safely access 'index_full_mask', the code avoids triggering mypy errors caused by dynamically assigned attributes, ensuring that repository-wide type checks pass successfully without altering runtime logic. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Code Review
Suggested PR Title:
[Attention][BugFix] Safely retrieve index_full_mask from xlite_configSuggested PR Summary:
### What this PR does / why we need it?
This PR updates the retrieval of `index_full_mask` from `self.xlite_config` to use `getattr(self.xlite_config, 'index_full_mask', None)` instead of direct attribute access. This prevents potential `AttributeError` exceptions if the attribute is missing from the configuration. It also adds a type annotation `list[bool]` to `index_mask`.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
No tests were provided in this PR.There are no review comments to address.
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. Tip 💡 Consider Linking a Related Issue or RFCYour PR title contains the [BugFix] tag, indicating a bug fix or new feature. Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:
🙏 Thanks for helping us keep the project well-organized! |
What this PR does / why we need it?
DeepseekV32XliteModel.extract_kv_cache()directly accessesself.xlite_config.index_full_mask. However,XModelConfigdoes notstatically declare this attribute; it is assigned dynamically in
_build_model_config().As a result, mypy reports:
This type-checking error can cause the repository-wide pre-commit/mypy
job to fail, including for PRs unrelated to xlite.
This PR uses the same safe access pattern already used in
_build_model():If the attribute is unavailable or empty, it falls back to an all-
Truemask, preserving the existing fallback behavior.
Fixes #16658
Does this PR introduce any user-facing change?
No API or configuration changes.
For normally initialized xlite configurations, runtime behavior remains
unchanged. If
index_full_maskis unavailable, the code now safely usesthe existing all-
Truefallback instead of directly accessing a missingattribute.
How was this patch tested?
No new runtime test was added because this is a static type-checking fix
and does not change the normal KV-cache extraction behavior.
The following checks passed:
The original
index_full_mask [attr-defined]mypy error is no longerreported.