Skip to content

[IREE][RUNTIME] Failure: OUT_OF_RANGE; count 1318 of iree_hal_fence > 32; while invoking native function hal.fence.join; #11652

Closed

Description

@vivekkhandelwal1

What happened?

Hi, while running a model I'm getting the following error with the iree-runtime:

EXEC @forward
vivekkhandelwal1-iree/runtime/src/iree/modules/hal/module.c:1117: OUT_OF_RANGE; count 1318 of iree_hal_fence > 32; while invoking native function hal.fence.join; while calling import; 
[ 1]   native hal.fence.join:0 -
[ 0] bytecode module.forward:44388 iree_failure_repro.mlir:45375:13
      at iree_failure_repro:39:3; invoking function 'forward'

Steps to reproduce your issue

The iree_hal_fence_falure.mlir file is large, and I didn't find a way to make a smaller repro of this. Hence it needs to be downloaded from here: https://storage.googleapis.com/shark_tank/vivek/iree_hal_fence_failure.mlir
To reproduce this issue first you need to generate a vmfb file, with the following command:

./build/tools/iree-compile --iree-input-type=tm_tensor --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=llvm-cpu --iree-llvm-embedded-linker-path=/build/compiler/bindings/python/iree/compiler/_mlir_libs/iree-lld --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false -iree-llvm-target-triple=x86_64-linux-gnu --iree-stream-resource-index-bits=64 --iree-vm-target-index-bits=64 --iree-util-zero-fill-elided-attrs iree_hal_fence_falure.mlir -o module.vmfb

After getting the vmfb file, you can reproduce the error with the following command:

./build/tools/iree-run-module --module_file=module.vmfb --device=local-task --entry_function=forward --function_input="1x77xi64" --function_input="1x3x512x512xf32" --function_input="49409x768xf32"

What component(s) does this issue relate to?

Compiler

Version information

No response

Additional context

No response

Activity

  1. changed the title [-][IREE[RUNTIME] Failure: OUT_OF_RANGE; count 1318 of iree_hal_fence > 32; while invoking native function hal.fence.join;[/-] [+][IREE][RUNTIME] Failure: OUT_OF_RANGE; count 1318 of iree_hal_fence > 32; while invoking native function hal.fence.join;[/+] on Dec 23, 2022
  2. vivekkhandelwal1 commented on Dec 26, 2022

    @vivekkhandelwal1
    MemberAuthor

    I don't know how but the model ran successfully for CPU by changing this value 32 (https://github.com/iree-org/iree/blob/main/runtime/src/iree/modules/hal/module.c#L1116) to 10240. For GPU it threw the following error:

    RuntimeError: Error invoking function: vivekkhandelwal1-iree/runtime/src/iree/hal/drivers/cuda/stream_command_buffer.c:469: INTERNAL; CUDA driver error 'CUDA_ERROR_INVALID_VALUE' (1): invalid argument; cuLaunchKernel; while invoking native function hal.device.queue.execute; while calling import; 
    [ 1]   native hal.device.queue.execute:0 -
    
  3. stellaraccident commented on Dec 27, 2022

    @stellaraccident
    Collaborator

    Thanks for flagging. This is one of those limits where 32 really should be more than enough, and something isn't compiling correctly. Ben and I are still on vacation, but this will need investigation... likely some invariant that hasn't been fully accounted for in the stream dialect.

  4. jinchen62 commented on Jan 6, 2023

    @jinchen62
    Contributor

    I got the same issue.

    IndexError: Error invoking function: c/runtime/src/iree/modules/hal/module.c:1117: OUT_OF_RANGE; count 102 of iree_hal_fence > 32; while invoking native function hal.fence.join; while calling import;

  5. benvanik commented on Jan 9, 2023

    @benvanik
    Collaborator

    I'll take a look.

    7gb is big for a repro O_O would be good to figure out how to shrink that for future ones - eliding element attrs should help and still allow this to reproduce.

  6. benvanik commented on Jan 9, 2023

    @benvanik
    Collaborator

    Still (very slowly) compiling, but did notice that dispatch region formation is leaving empty tensors around outside of dispatches - @MaheshRavishankar is this a known issue? Lots of these:

      %4519 = flow.tensor.empty : tensor<81920xf32>
      %4520 = flow.dispatch @_forward_dispatch_2888::@_forward_dispatch_2888_generic_81920[%c81920](%4517, %4518, %4519) : (tensor<81920xf32>, tensor<81920xf32>, tensor<81920xf32>) -> %4519

    (this prevents us from treating the result tensor as write-only)

    There's quite a few of these in the model (89+ at this stage), the source looks like:

      %8636 = tensor.empty() : tensor<49409x768xf32>
      %8637 = linalg.fill ins(%cst_1108 : f32) outs(%8636 : tensor<49409x768xf32>) -> tensor<49409x768xf32>
      %8638 = tensor.empty() : tensor<77xi32>
      %8639 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%8632 : tensor<77xi64>) outs(%8638 : tensor<77xi32>) {
      ^bb0(%in: i64, %out: i32):
        %8655 = arith.trunci %in : i64 to i32
        linalg.yield %8655 : i32
      } -> tensor<77xi32>
  7. benvanik commented on Jan 9, 2023

    @benvanik
    Collaborator

    Looks like SimplifyGlobalAccesses may be doing something wrong with the global seed. Will have to look in to that separately.

  8. MaheshRavishankar commented on Jan 9, 2023

    @MaheshRavishankar
    Collaborator

    Still (very slowly) compiling, but did notice that dispatch region formation is leaving empty tensors around outside of dispatches - @MaheshRavishankar is this a known issue? Lots of these:

      %4519 = flow.tensor.empty : tensor<81920xf32>
      %4520 = flow.dispatch @_forward_dispatch_2888::@_forward_dispatch_2888_generic_81920[%c81920](%4517, %4518, %4519) : (tensor<81920xf32>, tensor<81920xf32>, tensor<81920xf32>) -> %4519

    (this prevents us from treating the result tensor as write-only)

    There's quite a few of these in the model (89+ at this stage), the source looks like:

      %8636 = tensor.empty() : tensor<49409x768xf32>
      %8637 = linalg.fill ins(%cst_1108 : f32) outs(%8636 : tensor<49409x768xf32>) -> tensor<49409x768xf32>
      %8638 = tensor.empty() : tensor<77xi32>
      %8639 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%8632 : tensor<77xi64>) outs(%8638 : tensor<77xi32>) {
      ^bb0(%in: i64, %out: i32):
        %8655 = arith.trunci %in : i64 to i32
        linalg.yield %8655 : i32
      } -> tensor<77xi32>

    THere was a regression on that but I fixed it. Maybe regressed again. empty tensors should be pull in.

  9. benvanik commented on Jan 9, 2023

    @benvanik
    Collaborator

    This fence issue seems to be caused by the FuseGlobals pass not fusing the constant timepoints. I'm not sure why yet but should be an easy fix.

  10. 11 remaining items

  11. added a commit that references this issue on May 1, 2023
    98a71a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug 🐞

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions