Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DIPU] 关于linear custom_fallback导致的错误。 #593

Open
Reinerzhou opened this issue Jan 4, 2024 · 0 comments
Open

[DIPU] 关于linear custom_fallback导致的错误。 #593

Reinerzhou opened this issue Jan 4, 2024 · 0 comments

Comments

@Reinerzhou
Copy link
Member

背景

dipu对有针对部分算子的 custom_fallback 逻辑。

问题描述

在这个commit将linear的custom_fallback设为true之后。

- schema: "linear(Tensor input, Tensor weight, Tensor? bias=None) -> Tensor"
custom_fallback: True

在燧原以及华为上运行llama_finetune时会有如下报错:
image

问题分析

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

改进建议

custom_fallback的逻辑主要在这里:

#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)。

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

No branches or pull requests

1 participant