Closed nsmithtt closed 1 month ago
We need a flatbuffer type that reflects metal's ComputeConfig
:
ComputeConfig{
.math_fidelity = MathFidelity::HiFi4,
.fp32_dest_acc_en = fp32_dest_acc_en,
.math_approx_mode = math_approx_mode,
.compile_args = compute_kernel_args,
.defines = get_defines(BinaryOpType::ADD)
}
At least for now, the fields that we really care about are math_fidelity
, fp32_dest_acc_en
, and math_approx_mode
.
This new, optional, table ComputeDesc
, should live in include/ttmlir/Target/TTMetal/program.fbs
and become a member of table KernelDesc
.
This new flatbuffer attribute, if present, should also be consumed by runtime and for programming metal API CreateKernel
, here runtime/lib/ttmetal/command_queue.cpp
.
Thx Nick. Adding @ddilbazTT as asignee too. Defne, let's look at this issue next when previous issue is ~finished.
So this is the bit I will add right now to /tt-mlir/include/ttmlir/Target/TTMetal/program.fbs, as I haven't figured out how to handle maps in fbs file - which I believe defines is.
table ComputeDesc {
math_fidelity: MathFidelity;
fp32_dest_acc_en: bool;
math_approx_mode: bool;
compile_args: [uint32];
// defines:
}
Let's elide compile_args
and defines
for now. Not sure how we want to handle these yet.
I haven't figured out how to handle maps in fbs file
For future reference, maps can be implemented as just a list of pairs:
table MapEntry {
key: ...;
value: ...;
}
table Foo {
my_map: [MapEntry];
}
Offline we decided to go a new direction, and make a few additional cleanups that should help us in the long term. On the flatbuffer side of things I think we want to remove SourceType
and instead embed a variant config type that serves 2 purposes:
See attached: program.fbs.zip
On the compiler side we want:
TTMetal_DispatchOp
to take a TTKernel_KernelConfigArrayAttr
instead of TTKernel_ThreadTypeArrayAttr
.TTKernel_KernelConfigAttr
defined in TTKernelOpsTypes.td
. These kernel configs will work in the same way as the flatbuffer schema definition and will be a variant type, something like:
def TTKernel_KernelConfig : TTKernel_Attr<"KernelConfig", "kernel_config"> {
let arguments = (ins AnyAttrOf<[NocConfig, TensixConfig, EthConfig]>:$attr);
}
NocConfig
, TensixConfig
, EthConfig
should mirror the schema typeCreateKernelSourceDirect
We'll need the relevant flatbuffer attributes that the compiler can pass through to program this attribute