Skip to content

Conversation

@sufubao
Copy link
Collaborator

@sufubao sufubao commented Nov 10, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sufubao, 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 integrates the Deepseek3.2 model into the system, extending the existing Deepseek2 framework. The changes involve significant architectural additions to support Deepseek3.2's distinct attention mechanism and FP8 quantization, ensuring efficient inference. This includes new data structures for managing attention states, specialized memory allocation, and highly optimized Triton kernels for core computational tasks.

Highlights

  • Deepseek3.2 Model Support: Introduced comprehensive support for the Deepseek3.2 model, including new inference structures, specialized memory management, and custom Triton kernels tailored for its unique attention mechanism and FP8 quantization.
  • Non-Standard Attention (NSA) Indexing: Implemented a dedicated NSA Indexer (NSAIndexerInfer) and associated structures (Deepseek3_2FlashAttentionStateInfo, NSAIndexerWeight) to manage and compute indices for Deepseek3.2's attention mechanism, which involves dynamic top-k selection.
  • Custom Memory Management: Added Deepseek3_2MemoryManager and Deepseek3_2FP8KVMemoryManager to handle the specific memory requirements of Deepseek3.2, including a sub-memory manager for indexer KV data. The base MemoryManager was updated to support sub-managers.
  • New Triton Kernels for Optimization: Developed several new Triton kernels: act_quant for block-wise FP8 activation quantization, destindex_copy_indexer_ks and extract_indexer_ks for efficient handling of indexer KV data, and fp8_paged_mqa_logits for optimized FP8 Multi-Query Attention logits computation.
  • Refined Weight Loading and Verification: Enhanced the TransformerLayerWeight class to recursively load and verify nested transformer layer weights, ensuring proper initialization for complex model architectures like Deepseek3.2.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for the Deepseek3.2 model. The changes are extensive, including new model classes, layer inference logic, weight structures, memory managers, and several custom Triton kernels to handle the model's specific architecture, such as the NSA indexer. The review identified a few issues: a critical import error that would cause a runtime failure, an incorrect model registration that would prevent the new model from being used, a commented-out autotune call that could affect performance, and some non-English comments that impact code maintainability. Overall, the changes are substantial and add significant new functionality.



@ModelRegistry(["deepseek_v2", "deepseek_v3"])
@ModelRegistry(["deepseek_v2", "deepseek_v3", "deepseek_v32"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The model name "deepseek_v32" is being registered to the Deepseek2TpPartModel class. This seems incorrect as it's for the new Deepseek3.2 model. The new Deepseek3_2TpPartModel class in lightllm/models/deepseek3_2/model.py should be registered for this model name instead. Please revert this change.

Suggested change
@ModelRegistry(["deepseek_v2", "deepseek_v3", "deepseek_v32"])
@ModelRegistry(["deepseek_v2", "deepseek_v3"])

from lightllm.utils.envs_utils import get_env_start_args
from lightllm.models.deepseek3_2.infer_struct import Deepseek3_2FlashAttentionStateInfo
from lightllm.models.deepseek3_2.mem_manager import Deepseek3_2MemoryManager, Deepseek3_2FP8KVMemoryManager
# @ModelRegistry(["deepseek_v32"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The @ModelRegistry decorator is commented out. To correctly register the Deepseek3_2TpPartModel for the "deepseek_v32" model, this line should be uncommented. This is related to the incorrect registration in lightllm/models/deepseek2/model.py.

Suggested change
# @ModelRegistry(["deepseek_v32"])
@ModelRegistry(["deepseek_v32"])

self._init_custom()
self._init_inferstate_cls()
self._autotune_warmup()
# self._autotune_warmup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The call to _autotune_warmup() has been commented out. If this was for debugging, it should be removed. If autotuning is intentionally disabled for this model, it would be better to control this with a configuration flag for clarity and to avoid accidental performance degradation.

Suggested change
# self._autotune_warmup()
self._autotune_warmup()


logits = deep_gemm.fp8_mqa_logits(q_fp8, (k_fp8_, k_scale_), weights.squeeze(-1), ks, ke)

# 返回 : [seq_q_len, topk] 无效的位置使用-1填充
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment is in Chinese. For better maintainability and consistency with the rest of the codebase, please translate it to English.

Suggested change
# 返回 : [seq_q_len, topk] 无效的位置使用-1填充
# Returns: [seq_q_len, topk], invalid positions are filled with -1

@ModelTC ModelTC deleted a comment from gemini-code-assist bot Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants