Skip to content

Investigate a fusion opportunity on Layer Normalization #9139

Closed

Description

@okkwon

ONNX pattern-matches multiple layer normalization patterns with/without bias and skip data, and uses a single CUDA kernel for it. On the IREE side, we have three dispatches: mean (reduction), variance (reduction), and normalizations (element-wise operations).

ONNX got ~7% perf improvement by pattern matching 23 layer normalization instances from miniLM.

Activity

  1. added
    bug 🐞
    help wanted
    performance ⚡
    and removed
    bug 🐞
    on May 16, 2022
  2. benvanik commented on May 16, 2022

    @benvanik
    Collaborator

    To clarify, this just means we should be fusing those dispatches together such that they are accessing the source data once for all 3 reductions, correct?

    ("pattern matching ML layers" is precisely what we don't want to do, so just want to make sure the terminology is right here that it's a fusion opportunity at the linalg level, where multiple linalg ops consuming the same data should be fused into a single dispatch)

  3. okkwon commented on May 16, 2022

    @okkwon
    MemberAuthor

    Yes, I carefully chose "investigate a fusion opportunity" instead of "do pattern matching" according to our design principles. ;) Thanks Ben!

  4. benvanik commented on May 16, 2022

    @benvanik
    Collaborator

    Cool! This will be a really great improvement!

  5. julianwa commented on May 16, 2022

    @julianwa
    Member

    @okkwon, you mentioned this was dependent on some in-progress work from @MaheshRavishankar. Is that tracked with an issue yet?

    @benvanik, yep, we have been looking at ONNX fusions for inspiration and empirical data, but are only considering opportunities that have meaningful impact and are generalizable at the linalg level.

  6. okkwon commented on May 16, 2022

    @okkwon
    MemberAuthor

    @MaheshRavishankar is working on #8970. But, we need a vertical fusion of unrelated operations (some calls it horizontal fusion) to fuse reductions.

  7. MaheshRavishankar commented on May 16, 2022

    @MaheshRavishankar
    Collaborator

    Thats the PR, it needs some upstream fixes. I sent a patch out for that already. Have to work on one more.

    I am not sure we need "horizontal fusion". The mean is used in variance, so there is a dependence.

  8. added
    codegen
    compiler/dialects
    on May 16, 2022
  9. self-assigned this
    on May 25, 2022
  10. 11 remaining items

  11. okkwon commented on Jul 7, 2022

    @okkwon
    MemberAuthor

    A PR for the first part is under review. #9693

  12. okkwon commented on Jul 28, 2022

    @okkwon
    MemberAuthor

    There is an ongoing discussion about how to solve the general fusion problems. No ETA yet.

  13. allieculp commented on Jul 28, 2022

    @allieculp

    From today's meeting: assigning to @MaheshRavishankar

  14. allieculp commented on Aug 11, 2022

    @allieculp

    Adding @okkwon to this issue in case there have been any updates while Mahesh is out.

  15. MaheshRavishankar commented on Aug 11, 2022

    @MaheshRavishankar
    Collaborator

    This is on my plate. The resolution is about 2-3 weeks out.

  16. allieculp commented on Aug 25, 2022

    @allieculp

    From meeting 8/25: Draft PR in place, still looking into backend issues

  17. MaheshRavishankar commented on Sep 29, 2022

    @MaheshRavishankar
    Collaborator

    This is implemented at HEAD but is guarded by the flag --iree-flow-enable-aggressive-fusion pass. This is disabled by default now due to backend issue. So the work for this bug itself is done.

  18. Repository owner moved this from In Progress to Done in IREEon Sep 29, 2022
  19. Repository owner moved this from In Progress to Done in IREE - ARCHIVED (do not update)on Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

codegenperformance ⚡

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions