flagos-ai / flagos-ai/FlagTree
[Bug][npu] not supported float8_e4m3fn on ascend npu
- Dominant language
- Python
- Stars
- 350
- Forks
- 149
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 81
Description
docker image: flagtree-ascend3.5-910c-py311-cann9.0.0-ubuntu22.04-aarch64:202607-torch2.10.0-vllm0.20.2
flagtree version: 0.6.1+ascend3.5
error messages:
```
Traceback (most recent call last):
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/spec/ascend/compiler/compiler.py", line 325, in compile
next_module = compile_ir(module, metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/backends/ascend/compiler.py", line 1030, in
lambda src, metadata: linalg_to_bin_enable_npu_compile_A2_A3(src, metadata, options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/backends/ascend/compiler.py", line 740, in linalg_to_bin_enable_npu_compile_A2_A3
ret = subprocess.run(cmd_list, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.15/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/Ascend/cann-9.0.0/tools/bishengir/bin/bishengir-compile', '/tmp/tmpfyd6t9vt/kernel.mlir', '--target=Ascend910_9382', '--enable-auto-multi-buffer=True', '--enable-auto-bind-sub-block=True', '--link-aicore-bitcode=/usr/local/python3.11.15/lib/python3.11/site-packages/triton/backends/ascend/lib/libdevice.10.bc', '--enable-hfusion-compile=true', '--enable-hivm-compile=true', '--enable-triton-kernel-compile=true', '-o', '/tmp/tmpfyd6t9vt/kernel']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/workspace/AI/test.py", line 21, in
main()
File "/workspace/AI/test.py", line 16, in main
_store_fp8[(1,)](x, y, BLOCK=64)
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/spec/ascend/runtime/jit.py", line 419, in
return lambda *args, **kwargs: self.run(grid=grid, warmup=False, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/spec/ascend/runtime/jit.py", line 733, in run
kernel = self._do_compile(key, signature, device, constexprs, options, attrs, warmup)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/spec/ascend/runtime/jit.py", line 861, in _do_compile
kernel = self.compile(src, target=target, options=options.__dict__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/python3.11.15/lib/python3.11/site-packages/triton/spec/ascend/compiler/compiler.py", line 346, in compile
raise MLIRCompilationError(stage_name, error_detail) from e
triton.compiler.errors.MLIRCompilationError:
///------------------[ERROR][Triton][BEG]------------------
[ConvertLinalgIRToBinary] encounters error:
loc("/workspace/AI/test.py":7:0): error: Failed to run BiShengHIR pipeline
loc("/workspace/AI/test.py":10:32): error: 'hivm.hir.vcast' op currently don't support cast float_to_UNKNOWN_rintmode
loc("/workspace/AI/test.py":10:32): error: unrecognized float type: 'f8E4M3FN'
loc("/workspace/AI/test.py":7:0): error: Failed to run BiShengHIR pipeline
loc("/workspace/AI/test.py":10:32): error: 'hivm.hir.vcast' op currently don't support cast float_to_UNKNOWN_rintmode
loc("/workspace/AI/test.py":10:32): error: unrecognized float type: 'f8E4M3FN'
loc("/workspace/AI/test.py":7:0): error: Failed to run BiShengHIR pipeline
loc("/workspace/AI/test.py":10:32): error: 'hivm.hir.vcast' op currently don't support cast float_to_UNKNOWN_rintmode
loc("/workspace/AI/test.py":10:32): error: unrecognized float type: 'f8E4M3FN'
loc("/workspace/AI/test.py":7:0): error: Failed to run BiShengHIR pipeline
loc("/workspace/AI/test.py":10:32): error: 'hivm.hir.vcast' op currently don't support cast float_to_UNKNOWN_rintmode
loc("/workspace/AI/test.py":10:32): error: unrecognized float type: 'f8E4M3FN'
loc("/workspace/AI/test.py":7:0): error: Failed to run BiShengHIR pipeline
loc("/workspace/AI/test.py":10:32): error: 'hivm.hir.vcast' op currently don't support cast float_to_UNKNOWN_rintmode
loc("/workspace/AI/test.py":10:32): error: unrecognized float type: 'f8E4M3FN'
[ERROR] Failed to run BiShengIR pipeline
[INFO]: The compiled kernel cache is in /root/.triton/cache/LKFGKOHAQW7XGBMXJPZFF243BLNBAGCQOJ2DVNPKTPPXNWXXHMPQ
///------------------[ERROR][Triton][END]------------------
[ERROR] 2026-08-14-14:15:53 (PID:968851, Device:0, RankID:-1) ERR99999 UNKNOWN applicaiton exception
```
testcase:
cat test.py
```python
import torch
import triton
import triton.language as tl
@triton.jit
def _store_fp8(x_ptr, y_ptr, BLOCK: tl.constexpr):
offs = tl.arange(0, BLOCK)
x = tl.load(x_ptr + offs).to(tl.float32)
tl.store(y_ptr + offs, x.to(y_ptr.dtype.element_ty))
def main():
x = torch.rand(64, dtype=torch.float32, device="npu")
y = torch.empty(64, dtype=torch.float8_e4m3fn, device="npu")
_store_fp8[(1,)](x, y, BLOCK=64)
print("OK")
if __name__ == "__main__":
main()
```
reproduce command:
```
python test.py
```
Contributor guide
Research direction
Start with the provided test.py and trace its compilation through triton/backends/ascend/compiler.py, especially linalg_to_bin_enable_npu_compile_A2_A3 and the BiShengHIR error. Reproduce with `python test.py` in the stated Ascend environment; done means the float8_e4m3fn kernel compiles and prints `OK`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100