Skip to content

[BugFix][HPU] Add paddle.compat compatibility check for HPU environment#6387

Draft
mattheliu wants to merge 3 commits intoPaddlePaddle:developfrom
mattheliu:fix/hpu_paddle_compat_check
Draft

[BugFix][HPU] Add paddle.compat compatibility check for HPU environment#6387
mattheliu wants to merge 3 commits intoPaddlePaddle:developfrom
mattheliu:fix/hpu_paddle_compat_check

Conversation

@mattheliu
Copy link
Collaborator

@mattheliu mattheliu commented Feb 7, 2026

Motivation

Fix FastDeploy import failure on Intel HPU (Habana Gaudi) environment.

In HPU environment, PaddlePaddle 3.1.1 (stable) does not have the paddle.compat module (introduced in 2025-09-05), causing an AttributeError during FastDeploy import:

AttributeError: module 'paddle' has no attribute 'compat'. Did you mean: 'concat'?

Modifications

Add hasattr check before calling paddle.compat.enable_torch_proxy() to ensure compatibility across different Paddle versions and hardware platforms.

Modified files:

  1. fastdeploy/init.py
  2. fastdeploy/model_executor/layers/attention/flash_attn_backend.py
# Enable torch proxy if paddle.compat is available
# Some Paddle versions (e.g., stable versions on HPU/GCU) may not have the compat module
if hasattr(paddle, "compat") and hasattr(paddle.compat, "enable_torch_proxy"):
    paddle.compat.enable_torch_proxy(scope={"triton"})

Usage or Command

No special command needed. After this fix, FastDeploy can be imported normally on HPU environment.

Accuracy Tests

  • This fix only adds a conditional check without affecting original functionality
  • Behavior remains unchanged on environments that support paddle.compat
  • On environments without paddle.compat, the call is skipped to avoid errors

Checklist

  • Add at least a tag in the PR title.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
    • No unit test added: This is a simple compatibility check that does not require dedicated tests.
  • Provide accuracy results.
    • No accuracy impact: This change only adds a conditional check for module existence.

Some Paddle versions (e.g., PaddlePaddle 3.1.1 on Intel HPU) do not have
the paddle.compat module, causing AttributeError during FastDeploy import.

This fix adds a hasattr check before calling paddle.compat.enable_torch_proxy()
to ensure compatibility across different Paddle versions and hardware platforms.

Co-Authored-By: Claude (Claude Opus 4.5) <noreply@anthropic.com>
@paddle-bot
Copy link

paddle-bot bot commented Feb 7, 2026

Thanks for your contribution!

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2026

Codecov Report

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

Files with missing lines Patch % Lines
fastdeploy/__init__.py 50.00% 0 Missing and 1 partial ⚠️
...el_executor/layers/attention/flash_attn_backend.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6387   +/-   ##
==========================================
  Coverage           ?   68.23%           
==========================================
  Files              ?      391           
  Lines              ?    52242           
  Branches           ?     8147           
==========================================
  Hits               ?    35649           
  Misses             ?    13986           
  Partials           ?     2607           
Flag Coverage Δ
GPU 68.23% <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.

…ibility

Add hasattr check before calling paddle.compat.enable_torch_proxy() in
flash_attn_backend.py to fix HPU CI failure. Paddle stable versions
(e.g., 3.1.1 on HPU) don't have the compat module.

Co-Authored-By: Claude <noreply@anthropic.com>
@mattheliu mattheliu marked this pull request as draft February 7, 2026 10:13
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