Skip to content

[BACKEND][MTHREADS] Low-precision float support: resolve_dot capability rules, fp8 dual whitelist, SQMMA/WMMA fp8 lowering fixes - #1114

Closed
zeroherolin wants to merge 2 commits into
flagos-ai:mainfrom
zeroherolin:feature/precision_mtt
Closed

[BACKEND][MTHREADS] Low-precision float support: resolve_dot capability rules, fp8 dual whitelist, SQMMA/WMMA fp8 lowering fixes#1114
zeroherolin wants to merge 2 commits into
flagos-ai:mainfrom
zeroherolin:feature/precision_mtt

Conversation

@zeroherolin

Copy link
Copy Markdown
Collaborator

Depends on #1112 — this branch is stacked on feature/precision-core; the first commit is that PR. Please review only the second commit (third_party/mthreads/ only). Will rebase once #1112 merges.

Summary

MThreads implementation of the low-precision float capability contract from #1112.

  • backend/compiler.py: dual-whitelist field family — supported_fp8_dtypes (dot operands) vs supported_fp8_storage_dtypes (storage-only fnuz/e4b15 formats stay out of tl.dot); supported_fp8_cast_dtypes / custom_cast_fp8_dtypes (renamed from custom_fp8_dtypes); resolve_dot — same-type OCP fp8 dot with fp32 accumulator is native from cap31 when the block shape hits an 8-bit instruction tile, otherwise EMULATED via the FMA fallback with the concrete reason in the diagnostic; resolve_dot_scaled — always EMULATED (no native scaled-MMA path).
  • AccelerateMUSAMatmul.cpp: SQMMA operands staged through a same-width bit container (i8 loads bitcast to fp8) are retyped with MemDescReinterpretOp to the element type the dot consumes; accelerated WMMA now bails out to the FMA fallback for fp16 accumulators/results outside the PH1 f16×f16 carrier path.
  • Utility.cpp: replaceUsesAndPropagateType handles same-shape MemDescReinterpretOp views.
  • Dialect.cpp: WmmaDotOp::verify requires A/B to share an element type (previously only bit width was checked, so e.g. fp8e4nv × fp8e5 passed the verifier and lowered incorrectly).
  • enable_fp8_burst2: plumbed from MUSAOptions through the pass pipeline instead of getenv at lowering time, so it participates in the compile cache key; the pybind signature keeps a default for backward compatibility.
  • spec/triton/: the overlay copies of backends/compiler.py, language/semantic.py, runtime/interpreter.py mirror the [FRONTEND] Low-precision float support: resolve_dot capability contract, fp8 cast routing, interpreter float conversion rewrite #1112 changes; the shared helper blocks are byte-identical to the core files (verified by diff), adapted only around the spec's _assert_dot_dtypes_valid dual-whitelist gate.

Behavior changes to be aware of

  • custom_fp8_dtypescustom_cast_fp8_dtypes rename changes the options dataclass, which invalidates existing compile caches (no code references the old name anywhere in the tree).
  • WmmaDotOp::verify is stricter (same element type), which could reject IR that previously passed verification with mixed same-width operand types; no in-tree pass emits such IR.

…, fp8 cast dtype routing, interpreter float conversion rewrite, precision tutorials

Common-layer groundwork for per-backend low-precision float support:

- backends/compiler.py: DotCap/DotSupport, the answer type for the new
  optional resolve_dot / resolve_dot_scaled codegen-function queries.
  Backends that do not register them keep the legacy dot dtype rules.
- language/semantic.py: query resolve_dot(_scaled) once shapes are known;
  reject UNSUPPORTED combinations and warn on EMULATED ones. fp8 cast
  routing via supported_fp8_cast_dtypes / custom_cast_fp8_dtypes options;
  the default preserves the legacy fp8e4b15-only custom-cast routing.
- runtime/interpreter.py: rewrite _convert_float as exact decode/encode
  through fp64 with strict RTNE/RTZ and correct fn/fnuz/none special-value
  conventions (the old path rounded half-up and mishandled specials);
  fnuz zero results encode as +0, never the sign-only NaN code. Also add
  the flagtree_hints parameter to create_load/create_masked_load to match
  the semantic layer's call signature.
- backends/__init__.py: dunder probes on the lazy language-extensions
  proxy raise AttributeError instead of failing module resolution.
- tutorials/precision: runnable fp8 (E4M3FN) and fp4 (E2M1) walkthroughs
  driven by the declared capabilities, portable across backends.
… contract, fp8 dual-whitelist field family, SQMMA/WMMA fp8 lowering fixes, enable_fp8_burst2 plumbing
@zeroherolin

Copy link
Copy Markdown
Collaborator Author

goto #1116

@zeroherolin
zeroherolin deleted the feature/precision_mtt branch September 7, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant