Skip to content

[bugfix][AMD] Fix PPMissingLayer AttributeError for deepseek v2/v3 in aiter_gfx95 code path#21194

Open
RolaoDenthu wants to merge 2 commits intosgl-project:mainfrom
RolaoDenthu:fix/pp-amd
Open

[bugfix][AMD] Fix PPMissingLayer AttributeError for deepseek v2/v3 in aiter_gfx95 code path#21194
RolaoDenthu wants to merge 2 commits intosgl-project:mainfrom
RolaoDenthu:fix/pp-amd

Conversation

@RolaoDenthu
Copy link
Contributor

Motivation

When running DeepSeek-V2/V3 with Pipeline Parallelism (PP) on AMD gfx950 GPUs (MI300/MI350), the server crashes during model initialization with: AttributeError: 'PPMissingLayer' object has no attribute 'embedding_dim'.
This is because the _use_aiter_gfx95 code block in DeepseekV2Model.__init__ directly accesses self.embed_tokens.embedding_dim and self.layers[i].mlp, which are PPMissingLayer placeholders on non-owning PP ranks.

Modifications

Replace 4 bare attribute accesses inside the _use_aiter_gfx95 block with safe getattr calls

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

Your Name and others added 2 commits March 23, 2026 07:25
Use getattr for safe attribute access on embed_tokens.embedding_dim and
layers[i].mlp inside the _use_aiter_gfx95 block, preventing
AttributeError when these are PPMissingLayer placeholders in pipeline
parallel mode on AMD gfx950 GPUs.

Made-with: Cursor
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 critical bug preventing DeepSeek-V2/V3 models from initializing correctly on AMD gfx950 GPUs when Pipeline Parallelism is enabled. The fix involves enhancing the robustness of attribute access within the model's initialization logic, ensuring that the system gracefully handles cases where certain layers are not present on specific parallel ranks, thereby preventing an AttributeError and allowing the models to load successfully.

Highlights

  • Bug Fix for DeepSeek-V2/V3 Initialization: Resolved an AttributeError: 'PPMissingLayer' object has no attribute 'embedding_dim' that occurred during model initialization for DeepSeek-V2/V3 on AMD gfx950 GPUs when Pipeline Parallelism is enabled.
  • Robust Attribute Access: Replaced four direct attribute accesses (self.embed_tokens.embedding_dim and self.layers[i].mlp) with safer getattr calls within the _use_aiter_gfx95 code block. This prevents crashes when PPMissingLayer placeholders are encountered on non-owning PP ranks.

🧠 New Feature in Public Preview: You can now enable Memory 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 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.

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 correctly addresses the AttributeError for PPMissingLayer objects when using pipeline parallelism with DeepSeek-V2/V3 on AMD gfx950 GPUs. The use of getattr with default values is the right approach to safely access attributes that may not exist on non-owning pipeline ranks.

I've added one suggestion to refactor a block of code to improve its readability and efficiency. The core logic of your fix is sound.

@ch-wan
Copy link
Collaborator

ch-wan commented Mar 24, 2026

/tag-and-rerun-ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants