Skip to content

Compilation error in linalg-tensors matmul test #4409

Closed

Description

@stellaraccident

Manifested in one build run on Windows only - may be an indicator of non-determinism.

2021-01-07T00:04:00.7571560Z [3108/3308] Generating check_llvm-ir_llvm_matmul.mlir_module.module
2021-01-07T00:04:00.7572709Z FAILED: iree/test/e2e/linalg_tensor_ops/check_llvm-ir_llvm_matmul.mlir_module.module 
2021-01-07T00:04:00.7576590Z cmd.exe /C "cd /D D:\a\iree\iree\iree-build\iree\test\e2e\linalg_tensor_ops && D:\a\iree\iree\iree-build\iree\tools\iree-translate.exe -iree-mlir-to-vm-bytecode-module --iree-hal-target-backends=dylib-llvm-aot -iree-flow-dispatch-linalg-on-tensors -iree-flow-dispatch-linalg-on-tensors-tile-sizes=1,1 -iree-codegen-llvm-experimental-linalg-on-tensors D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir -o check_llvm-ir_llvm_matmul.mlir_module.module"
2021-01-07T00:04:00.7581181Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
2021-01-07T00:04:00.7582575Z   %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
2021-01-07T00:04:00.7583142Z        ^
2021-01-07T00:04:00.7584389Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %2 = flow.dispatch.input.load %arg0, offsets = [%arg4, %c0], sizes = [%1, %c3], strides = [%c1, %c1] : !flow.dispatch.input<2x3xf32> -> tensor<?x3xf32>
2021-01-07T00:04:00.7586492Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
2021-01-07T00:04:00.7587868Z   %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
2021-01-07T00:04:00.7588433Z        ^
2021-01-07T00:04:00.7589721Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %8 = flow.dispatch.input.load %arg1, offsets = [%c0, %arg5], sizes = [%c3, %7], strides = [%c1, %c1] : !flow.dispatch.input<3x4xf32> -> tensor<3x?xf32>
2021-01-07T00:04:00.7591789Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
2021-01-07T00:04:00.7593696Z   %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
2021-01-07T00:04:00.7594273Z        ^
2021-01-07T00:04:00.7595533Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %13 = flow.dispatch.input.load %arg2, offsets = [%arg4, %arg5], sizes = [%1, %7], strides = [%c1, %c1] : !flow.dispatch.input<2x4xf32> -> tensor<?x?xf32>
2021-01-07T00:04:00.7597580Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'linalg.matmul'?): falling back to runtime resolution
2021-01-07T00:04:00.7598817Z   %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
2021-01-07T00:04:00.7599372Z        ^
2021-01-07T00:04:00.7600553Z D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %19 = linalg.matmul {__internal_linalg_transform__ = "workgroup"} ins(%6, %12 : tensor<?x3xf32>, tensor<3x?xf32>) outs(%18 : tensor<?x?xf32>) -> tensor<?x?xf32>
2021-01-07T00:04:00.7602064Z PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
2021-01-07T00:04:00.7602867Z Stack dump:
2021-01-07T00:04:00.7606318Z 0.	Program arguments: D:\\a\\iree\\iree\\iree-build\\iree\\tools\\iree-translate.exe -iree-mlir-to-vm-bytecode-module --iree-hal-target-backends=dylib-llvm-aot -iree-flow-dispatch-linalg-on-tensors -iree-flow-dispatch-linalg-on-tensors-tile-sizes=1,1 -iree-codegen-llvm-experimental-linalg-on-tensors D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir -o check_llvm-ir_llvm_matmul.mlir_module.module
2021-01-07T00:04:00.7609873Z 1.	2.	In-Flight Diagnostics:
2021-01-07T00:04:00.7611020Z     loc("D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir":8:8): error: expected dispatch function to have a single call operation
2021-01-07T00:04:00.7612411Z     loc("D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir":8:8): error: expected dispatch function to have a single call operation
2021-01-07T00:04:00.7614153Z     loc("D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir":8:8): remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
2021-01-07T00:04:00.7616289Z     loc("D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir":8:8): remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
2021-01-07T00:04:00.7618322Z     loc("D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir":8:8): remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
2021-01-07T00:04:00.7620279Z     loc("D:/a/iree/iree/main_checkout/iree/test/e2e/linalg_tensor_ops/matmul.mlir":8:8): remark: unable to materialize shape calculation (unsupported op 'linalg.matmul'?): falling back to runtime resolution

Activity

  1. MaheshRavishankar commented on Jan 7, 2021

    @MaheshRavishankar
    Collaborator

    I think this is due to the recent PR for linalg on tensors. Will take a look (have to spin up my windows build again) in a bit.

  2. stellaraccident commented on Jan 7, 2021

    @stellaraccident
    CollaboratorAuthor
  3. benvanik commented on Jan 7, 2021

    @benvanik
    Collaborator

    First place I look with things like this is use of unordered maps - the msft STL differs from libc++ and often exposes issues related to them.

  4. MaheshRavishankar commented on Jan 7, 2021

    @MaheshRavishankar
    Collaborator

    There is probably a DenseMap iteration somewhere.

  5. ScottTodd commented on Jan 8, 2021

    @ScottTodd
    Member

    FWIW, I'm also seeing this on my Windows machine.

  6. MaheshRavishankar commented on Jan 8, 2021

    @MaheshRavishankar
    Collaborator

    Sorry, i didnt get a chance to look at this. Ill try to repro it on my windows machine

  7. nicolasvasilache commented on Jan 8, 2021

    @nicolasvasilache
    Contributor

    I've seen this expected dispatch function to have a single call operation message in the the WorkGroupFn thing, I'll send a simple tentative fix. Could someone give it a quick shot on Windows?
    I don't have a repro myself, which I find quite weird ..

  8. added 2 commits that reference this issue on Jan 8, 2021
    1e08d31
    a81b04f
  9. stellaraccident commented on Jan 8, 2021

    @stellaraccident
    CollaboratorAuthor

    FYI - I just got this one time on a Linux/GCC build and then it worked the next. So definitely a non-determinism.

  10. 4 remaining items

  11. MaheshRavishankar commented on Jan 20, 2021

    @MaheshRavishankar
    Collaborator

    Building in debug mode I see the following assertion hit :

    Assertion failed: llvmFuncOp.getNumArguments() > 0, file C:\Users\ravishankarm\Development\iree\iree\compiler\Conversion\LinalgToLLVM\ConvertToLLVM2.cpp, line 180
    

    @nicolasvasilache this is new code, and I dont have full context on the ABI. Can you take a look?

  12. nicolasvasilache commented on Jan 21, 2021

    @nicolasvasilache
    Contributor

    Unable to repro locally with 1e5 runs..

    @MaheshRavishankar this is fishy: as if there was a race condition in conversion pattern application.
    Can you run with -debug-only=dialect-conversion -print-ir-after-all and paste what you see on failure ?

    Once the enclosing llvmFunc exists (i.e. the MLIR func has been converted), it must have arguments otherwise there is nowhere to get the pointers to the buffers.

  13. MaheshRavishankar commented on Jan 21, 2021

    @MaheshRavishankar
    Collaborator

    FYI, on my windows machine (with Debug build) this is not intermittent. The assert triggers always. I am using MSVC 2019.

  14. MaheshRavishankar commented on Jan 21, 2021

    @MaheshRavishankar
    Collaborator

    Its a problem of competing patterns. The ConvertToLLVM2 pass adds a pattern from func -> llvm.func and so does populateStdToLLVMPatterns. THe latter is triggered and causes the issue.

  15. benvanik commented on Jan 21, 2021

    @benvanik
    Collaborator

    Ahh good catch - that would explain the differences between compilers. I did notice there's an LLVM_REVERSE_ITERATION:BOOL flag that causes all unordered containers to be iterated in reverse order and that may be useful to have on a CI to catch issues like this vs. how we are doing it now by just compiling with different compilers that iterate differently :P

  16. added a commit that references this issue on Jan 21, 2021
    4a21065
  17. added a commit that references this issue on Jan 21, 2021
    4d6c7c1
  18. ScottTodd commented on Jan 22, 2021

    @ScottTodd
    Member

    This could be tracked separately, but I'm still seeing warnings (not errors/failures) that spam the build log each time I build all:

    [237/246] Generating check_llvm-ir_llvm_matmul.mlir_module.module
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %6 = flow.dispatch.input.load %arg0, offsets = [%arg4, %c0], sizes = [%5, %c3], strides = [%c1, %c1] : !flow.dispatch.input<2x3xf32> -> tensor<?x3xf32>
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %12 = flow.dispatch.input.load %arg1, offsets = [%c0, %arg5], sizes = [%c3, %11], strides = [%c1, %c1] : !flow.dispatch.input<3x4xf32> -> tensor<3x?xf32>
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %17 = flow.dispatch.input.load %arg2, offsets = [%arg4, %arg5], sizes = [%5, %11], strides = [%c1, %c1] : !flow.dispatch.input<2x4xf32> -> tensor<?x?xf32>
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'linalg.matmul'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %23 = linalg.matmul {__internal_linalg_transform__ = "workgroup"} ins(%10, %16 : tensor<?x3xf32>, tensor<3x?xf32>) outs(%22 : tensor<?x?xf32>) -> tensor<?x?xf32>
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %9 = flow.dispatch.input.load %0, offsets = [%arg0, %c0], sizes = [%8, %c3], strides = [%c1, %c1] : !flow.dispatch.input<2x3xf32> -> tensor<?x3xf32>
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %18 = flow.dispatch.input.load %1, offsets = [%c0, %arg1], sizes = [%c3, %17], strides = [%c1, %c1] : !flow.dispatch.input<3x4xf32> -> tensor<3x?xf32>
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: remark: unable to materialize shape calculation (unsupported op 'flow.dispatch.input.load'?): falling back to runtime resolution
      %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
           ^
    D:/dev/projects/iree/iree/test/e2e/linalg_tensor_ops/matmul.mlir:8:8: note: see current operation: %26 = flow.dispatch.input.load %2, offsets = [%arg0, %arg1], sizes = [%8, %17], strides = [%c1, %c1] : !flow.dispatch.input<2x4xf32> -> tensor<?x?xf32>
    [246/246] Generating check_vmla_vmla_bert_encoder_unrolled_fake_weights.mlir_module.module
    

    these are also visible on Linux and in our presubmit logs: https://source.cloud.google.com/results/invocations/03718313-dccb-4f52-b604-4a1cf455248e/targets/iree%2Fgcp_ubuntu%2Fcmake%2Flinux%2Fx86-swiftshader%2Fpresubmit/log

  19. MaheshRavishankar commented on Jan 22, 2021

    @MaheshRavishankar
    Collaborator

    Yeah thats a separate issue. It has to do with the shape dialect. It might be a few days before I get around to this. It could be as simple as just removing the remark, but it would probably be better if someone with more knowhow about shape dialect (@silvasean ?) take a look.

  20. silvasean commented on Jan 26, 2021

    @silvasean
    Contributor

    This is basically what gets printed if we don't have a shape transfer function registered when we materialize shape calculations. My suggestion is to not use the tie shape pass / materialize shape calculations within flow.dispatch.workgroups, and instead just insert raw dim ops and let them canonicalize to a fixed point.

  21. nicolasvasilache commented on Jan 27, 2021

    @nicolasvasilache
    Contributor
  22. silvasean commented on Jan 27, 2021

    @silvasean
    Contributor

    Sure. I'm deep in an npcomp change. Will try to get to this in the next week.

  23. silvasean commented on Jan 29, 2021

    @silvasean
    Contributor

    This PR should remove most of the tie_shape nonsense: #4664

    (there is still flow.dispatch.tie_shape and the shapex.tie_shape on the flow.dispatch.workgroups op itself, but those are much more constrained in how they affect the code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions