openvinotoolkit / openvinotoolkit/npu_compiler

Very long compile times for moderately sized matmuls

Open
#143 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MLIR
Stars
100
Forks
50
Avg merge
3h 57m
Merged PRs (30d)
1

Description

TL;DR

When I construct an OpenVINO model consisting of just a single, moderately sized square matmul operation (in addition to the parameter and result ops), in order to launch on the NPU, the compile step takes really long.

The problem

I construct the model as follows:

def make_model (n):
    dtype = ov.Type ('float16')
    size = (n, n)

    A = ops.parameter (size, dtype, name = "A")
    B = ops.parameter (size, dtype, name = "B")
    C = ops.matmul (A, B, False, False)
    res = ops.result (C)

    return ov.Model ([res], [A, B], "matmul")

And I compile it as follows:

compiled_model = core.compile_model (make_model (11264), "NPU")

Some numbers:

  • n=11264 (i.e. matmul with 11264x11264 matrices) takes 10 minutes to compile
  • n=12288 takes 23 minutes
  • n=13312 takes 114 minutes

After compilation, inference (i.e. running the matmul on random inputs) is as quick as I'd expect it to be. Subsequent runs for a single matrix size spend no time on compilation, probably since they are satisfied by the NPU model cache.

I've tried raising the thread limit for the compiler, but it still runs on a single thread.

System info

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Python model from the issue with 11264, 12288, and 13312 matrix sizes, compiling each with core.compile_model(..., "NPU"). Measure compile time and thread usage, then trace the NPU compiler path responsible for matmul compilation. Done means moderately sized matmuls compile substantially faster without regressing inference or model-cache behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python, ubuntu
Domain
compilers, machine-learning, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.