Skip to content

Conversation

@HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Nov 26, 2025

PR Category

User Experience

PR Types

Bug fixes

Description

Pcard-75624

修复FLAGS_enable_api_kernel_fallback变量在XPU设备上不起效的问题,具体表现为:设置为false或0后,仍然会fallback到CPU上,核心原因在于原先的分支逻辑错误地使用了 ||,这会导致一旦出现kernel不支持,一定会进入fallback分支。

This pull request improves the handling and testing of the FLAGS_enable_api_kernel_fallback flag for XPU kernel selection in PaddlePaddle. The main changes include a bug fix to the flag logic in the kernel factory and the addition of a new unit test to verify the flag's behavior.

Kernel fallback flag logic:

  • Fixed the condition in KernelFactory::SelectKernelOrThrowError to ensure that kernel fallback is only attempted when FLAGS_enable_api_kernel_fallback is enabled and the kernel is unsupported on XPU. This prevents unintended fallback behavior.

Testing:

  • Added a new test file test/xpu/test_fallback_flag.py that verifies disabling FLAGS_enable_api_kernel_fallback raises a runtime error when running an unsupported operation, and restores the flag to its previous state after the test.

@paddle-bot
Copy link

paddle-bot bot commented Nov 26, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

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