Replies: 2 comments
-
|
In a discussion via a video call:
I think the idea with attributes is more practical. If we have to, we can move |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Tracking issue: #23535 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
As of writing, the tuner flow is as follows:
compilation_infoattributesThe problem with this approach is that the tuner has to know a lot about the IREE compiler and it's compilation pipelines (e.g.,
LLVMGPUVectorDistributeorLLVMGPUTileAndFuse), including what inputs they can compile, their configuration space, theirlowering_configformat, etc. This is partially encoded directly as python logic and partially exposed through Python bindings.High-level Proposal
I propose to move most of the responsibilities of dispatch parsers to the IREE compiler itself and have:
iree_codegen.constraintsop that encodes pipeline constraints of one or more root ops. There may be multiple constraint ops, which are disjoint per compilation pipeline. This happens before dispatch configuration.iree_codegen.constraintsops.iree_codegen.constaintsops and serializes them to SMTLIB strings. The tuner will use this binding to collect constraint sets. Uses the pass mentioned above.lowering_configandtranslation_infosatisfy the constraints. This is not strictly needed for the tuner, but it allows us to make sure that the compiler respects its own constraints, which are currently not verified until it's too late (e.g., deep in vector distribution).We don't have to implement it for all the possible pipelines, just like the tuner doesn't support all the backends and pipelines today.
Implementation
You can find my prototype here:
I checked it over a simple matmul and both VectorDistribute and TileAndFuse produce the same set of candidate tuning specs as before.
iree_codegen.constraintsThe key design consideration was to decide how to capture the following:
tensor.dimoperands, so that we can deal with both dynamic and static shapes. Assumptions and static sizes may end up getting constant-folded.lowering_config/translation_info. Whatever constraints we emit, the solver has to ingest and find concrete knob assignments for, and the tuner has to turn back into concrete attributes. I decided to have it structurally match thecompilation_infodictionary attribute, with leaf (value) attributes as new knob attributes.Example 1: Simple
linalg.fillopExample 2: Realistic `linalg.matmul` op
Knob materialization
It's trivial to materialize most knobs, as most leaf values are integers wrapped with
ArrayAttr/DictionaryAttr. What's more challenging is handling something likeiree_gpu.mma_layout. In my prototype, lowering config materialization is mostly hardcoded: https://github.com/kuhar/iree/blob/8bf5b267287d3288435532aecdb5abb422879255/compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/GPULoweringConfigUtils.cpp#L239.materializeCompilationInfo(constraintsOp, assignment, gpuTarget, elemTypes):IntKnobAttr→ value from assignment, keepIntegerAttrfindMMAAttrByShape(target, m, n, k, types)LoweringConfigAttr(workgroup, reduction, subgroup, thread, mma_kind, basis)TranslationInfoAttr(pipeline, workgroup_size, subgroup_size)CompilationInfoAttrIn the proper implementation, we may need some interface so that pipelines can register known
compilation_infokeys as interfaces that materialize them from knob attributes + concrete assignments.New bindings
C API (
iree_codegen.h)ireeCodegenGetConstraintsOps(module, ...)ireeCodegenConstraintsOpToSMTLIB(op)ireeCodegenMaterializeCompilationInfo(op, names, values, n)ireeCodegenIntKnobAttrGet{TypeID,Name}ireeCodegenMMAKnobAttrGet{TypeID,MName,NName,KName}Python bindings (
IREECompilerDialectsModule.cpp)Beta Was this translation helpful? Give feedback.
All reactions