Skip to content

Conversation

@fmiao2372
Copy link
Contributor

Motivation

Fix memory fragmentation issue and moe all_reduce issue

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

Modifications

update warmup sequence and moe all_reduce for HPU according to PR #5247

Usage or Command

no command usage change

Accuracy Tests

ERNIE-4.5-21B-A3B-Paddle
100%|██████████| 1319/1319 [09:16<00:00, 2.37it/s]
Accuracy: 0.917
Invalid: 0.001
Latency: 556.834 s

Checklist

  • [Done] Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • [Done] Format your code, run pre-commit before commit.
  • [Done] Add unit tests. Please write the reason in this PR if no unit tests.
  • [Done] Provide accuracy results.
    conducted by local tests
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

Copilot AI review requested due to automatic review settings December 3, 2025 07:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses memory fragmentation and MoE (Mixture of Experts) all_reduce issues for Intel HPU by modifying warmup sequence ordering and consolidating MoE all_reduce logic.

Key Changes:

  • Reversed warmup sequence iteration order (batch sizes and sequence lengths) to improve memory allocation patterns
  • Moved HPU-specific MoE all_reduce logic from backend-specific files to common MoE layer for better maintainability

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
fastdeploy/worker/hpu_model_runner.py Reversed iteration order for prefill batches, prefill lengths, decode batches, and decode block numbers during warmup to reduce memory fragmentation
fastdeploy/model_executor/layers/moe/moe.py Added platform-specific all_reduce handling for Intel HPU by importing tensor_model_parallel_all_reduce_custom and conditionally using it in the forward method
fastdeploy/model_executor/layers/backends/intel_hpu/moe/fused_moe_hpu_backend.py Removed duplicate all_reduce calls and unused import, moving the logic to the common MoE layer

@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@be0c960). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/model_executor/layers/moe/moe.py 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5357   +/-   ##
==========================================
  Coverage           ?   59.44%           
==========================================
  Files              ?      325           
  Lines              ?    40261           
  Branches           ?     6093           
==========================================
  Hits               ?    23934           
  Misses             ?    14428           
  Partials           ?     1899           
Flag Coverage Δ
GPU 59.44% <50.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@zoooo0820 zoooo0820 left a comment

Choose a reason for hiding this comment

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

LGTM

@EmmonsCurse EmmonsCurse merged commit 209006e into PaddlePaddle:develop Dec 4, 2025
13 of 17 checks passed
@fmiao2372 fmiao2372 deleted the develop_hpu_fixbug branch December 5, 2025 01:14
liyonghua0910 pushed a commit to liyonghua0910/FastDeploy that referenced this pull request Dec 5, 2025
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.

5 participants