Open monorimet opened 3 days ago
There are two issues.
func.func @test_layer_norm_single_result(%arg0: !torch.vtensor<[1,4,768],bf16>, %arg1: !torch.vtensor<[768],bf16>, %arg2: !torch.vtensor<[768],bf16>) -> (!torch.vtensor<[1,4,768], bf16>) attributes {torch.onnx_meta.ir_version = 6 : si64, torch.onnx_meta.opset_version = 17 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} {
%0 = torch.operator "onnx.LayerNormalization"(%arg0, %arg1, %arg2) {torch.onnx.axis = -1 : si64, torch.onnx.epsilon = 9.99999974E-6 : f32, torch.onnx.stash_type = 16 : si64} : (!torch.vtensor<[1,4,768],bf16>, !torch.vtensor<[768],bf16>, !torch.vtensor<[768],bf16>) -> !torch.vtensor<[1,4,768],bf16>
return %0 : !torch.vtensor<[1,4,768],bf16>
}
The attribute epsilon
should be f32, and it should come with stash_type
to match bf16 type.
@monorimet Actually we do have decomposition for torch.aten.native_layer_norm
which is lowered from onnx.laynorm. I was able to compile the bf16 test I posted above. For your case, so doesn't it come with the stash_type
attribute?
@jinchen62 Thanks, I forgot to include the MLIR: https://sharkpublic.blob.core.windows.net/sharkpublic/flux.1/flux_1_dev_static_bf16.mlir
It does not seem to come with the stash_type attribute, only {torch.onnx.axis = -1 : si64, torch.onnx.epsilon = 9.99999997E-7 : f32}
Hi all, I'm trying to compile bf16 flux mmdit from onnx export.
Running into the following torch-to-onnx legalization error:
reproducible with the following MLIR and compile command:
onnxln_test.mlir
compile command:
The minimized reproducer may be taking some liberties as to a "correct" usage of bf16 layernorm -- I took our fp32 test in torch-mlir and find+replaced "fp32" with "bf16", which I'm not confident in, but it does reproduce the same error.