数学函数调用错误
- 报错特征:
AttributeError: module 'triton.language' has no attribute 'tanh' - 修复:
- Triton CUDA 后端的数学函数需通过
tl.extra.cuda.libdevice模块调用 - 避免直接使用
tl.math.xxx或tl.xxx
- Triton CUDA 后端的数学函数需通过
# 错误:直接使用 tl.tanh
result = 0.5 * x * (1.0 + tl.tanh(inner))
# 正确:通过 libdevice 调用
result = 0.5 * x * (1.0 + tl.extra.cuda.libdevice.tanh(inner))