-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
背景
dipu对有针对部分算子的 custom_fallback 逻辑。
问题描述
在这个commit将linear的custom_fallback设为true之后。
deeplink.framework/dipu/scripts/autogen_diopi_wrapper/diopi_functions.yaml
Lines 747 to 748 in 583de90
| - schema: "linear(Tensor input, Tensor weight, Tensor? bias=None) -> Tensor" | |
| custom_fallback: True |
在燧原以及华为上运行llama_finetune时会有如下报错:

问题分析
由于dipu存在自定义的dispatch逻辑(包括custom_fallback),影响了dynamo中对meta key的dispatch行为,在linear设为custom_fallback后,会影响linear_backward的dispatch行为:

改进建议
custom_fallback的逻辑主要在这里:
deeplink.framework/dipu/torch_dipu/csrc_dipu/aten/RegisterDIPU.hpp
Lines 63 to 79 in 583de90
| #define DIOPI_ATEN_FUNC_CUSTOM_FALLBACK(opname, diopi_func, force_fallback, \ | |
| wapper_func, custom_fallback_func) \ | |
| do { \ | |
| if ((reinterpret_cast<void*>(diopi_func) != nullptr) && \ | |
| !((force_fallback) || dipu::get_force_fallback(opname))) { \ | |
| m.impl(opname, TORCH_FN(wapper_func)); \ | |
| } else { \ | |
| if ((reinterpret_cast<void*>(diopi_func) == nullptr)) { \ | |
| DIPU_OP_LOG_WARNING_ONCE(#diopi_func << " is not yet implemented, "); \ | |
| } else { \ | |
| DIPU_OP_LOG_WARNING_ONCE("force fallback has been set, "); \ | |
| } \ | |
| DIPU_OP_LOG_WARNING_ONCE((opname) << " will be fallback to cpu" \ | |
| << "\n"); \ | |
| m.impl(opname, TORCH_FN(custom_fallback_func)); \ | |
| } \ | |
| } while (false); |
通过增设一个环境变量DIPU_DISABLE_CUSTOM_FALLBACK以及disable_custom_fallback_ops_list在必要时禁用custom_fallback的逻辑(默认开启custom_fallback)。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels