Skip to content

docs: document the reduced-precision float32 default and MLX_ENABLE_TF32 - #3894

Merged
zcbenz merged 4 commits into
ml-explore:mainfrom
stoyoda0012-cyber:docs-tf32-default
Aug 4, 2026
Merged

zcbenz merged 4 commits into
ml-explore:mainfrom
stoyoda0012-cyber:docs-tf32-default

Conversation

@stoyoda0012-cyber

@stoyoda0012-cyber stoyoda0012-cyber commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Documents the reduced-precision default discussed in #3860.

Adds a short "Numerical Precision" usage page stating two things:

  • float32 matmul-family operations (matmul, quantized matmul, grouped
    matmul, convolution and attention) may run at reduced precision by
    default on hardware with dedicated matrix-multiplication units;
  • MLX_ENABLE_TF32=0 at launch keeps them in full float32.

Per review, per-backend descriptions and implementation-specific
behaviour are left out, so the page does not need updating when either
changes.

Testing

Built the docs with sphinx-build -b html against
docs/requirements.txt: the page renders, is reachable from the Usage
toctree, and none of the six build warnings originate from it (they are
the pre-existing nn.distributed autosummary imports against the pip
wheel, the doxygen-generated C++ group, and the printoptions stub).

Comment thread docs/src/usage/precision.rst Outdated
reduced-precision path is never taken, not because the setting is
ignored.

TF32-class math keeps the ``float32`` exponent range but rounds the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The technical details should be ignored since Apple silicon might not do exactly same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped, along with the TF32-format paragraph. Agreed that the docs
shouldn't assert equivalence between the Apple silicon path and NVIDIA's
TF32 -- that was inferred from measurements rather than from anything
either vendor specifies, and it is exactly the kind of claim that goes
stale silently.

Comment thread docs/src/usage/precision.rst Outdated

# float32 matmuls now run at full float32 precision

A few details worth knowing:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer omitting the details because they could change at any time and we might not remember to update the docs here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped. I also removed the in-process os.environ example, which is what
made the latching caveat necessary in the first place -- the page now
shows only the launch-time form, so there is no first-use ordering left
to explain.

stoyoda0012-cyber added a commit to stoyoda0012-cyber/mlx that referenced this pull request Aug 3, 2026
Review feedback on ml-explore#3894: per-backend hardware descriptions and
implementation details (first-use latching, the matvec shape exception,
complex64) can change without this page being updated. Keep only what
holds regardless of backend -- that float32 matmul-family ops may run at
reduced precision by default, and that MLX_ENABLE_TF32=0 opts out.

Removing the in-process os.environ example makes the latching caveat
unnecessary: the launch-time form has no first-use ordering to explain.

Co-Authored-By: Claude Opus 5 <[email protected]>
@stoyoda0012-cyber stoyoda0012-cyber changed the title docs: document the TF32-class float32 default and MLX_ENABLE_TF32 docs: document the reduced-precision float32 default and MLX_ENABLE_TF32 Aug 3, 2026
@stoyoda0012-cyber

Copy link
Copy Markdown
Contributor Author

Reduced the page to the two things that hold regardless of backend and
hardware generation: float32 matmul-family ops may run at reduced
precision by default, and MLX_ENABLE_TF32=0 opts out. Anything that
depends on a vendor's current behaviour is gone; those measurements are
recorded in #3860 instead, where they carry their date and device.

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

stoyoda0012-cyber and others added 4 commits August 4, 2026 09:32
float32 matmul-family ops run at TF32-class reduced precision by
default on both current-generation backends (CUDA tensor cores; the
M5 NAX — earlier Apple silicon runs full float32), and the
MLX_ENABLE_TF32 switch was previously undocumented. Adds a short
Numerical Precision usage page: what the default costs (measured
~1e-4..1e-3 vs ~2e-7 relative error), how to opt out, the first-use
latching, the matvec shape exception, the CUDA complex64 case, and
that half-precision inputs are unaffected. Follow-up promised in
ml-explore#3860.
- Metal: reduced precision applies on the M5 generation and newer on
  macOS 26.2 or later; state explicitly that pre-gen-17 machines never
  take the reduced-precision path, so the opt-out reads as a no-op
  there without being ignored
- Add a bullet noting the default applies to anything that lowers to
  matmul-family ops, e.g. attention fallbacks composed from plain GEMMs

Scope measurements: ml-explore#3860 (three-generation matrix by
mabaeyens, PhilipJohnBasile, katlun-lgtm).

Co-Authored-By: Claude Fable 5 <[email protected]>
The bullet stating that float16/bfloat16 inputs are unaffected could
be read as "those dtypes have no reduced-precision behaviour at all".
State the boundary instead: the setting applies to float32 only, and
reduced-precision behaviour involving fp16/bf16 inputs, where it
exists, has other causes and is not controlled by MLX_ENABLE_TF32.

Suggested by mabaeyens in ml-explore#3860.

Co-Authored-By: Claude Fable 5 <[email protected]>
Review feedback on ml-explore#3894: per-backend hardware descriptions and
implementation details (first-use latching, the matvec shape exception,
complex64) can change without this page being updated. Keep only what
holds regardless of backend -- that float32 matmul-family ops may run at
reduced precision by default, and that MLX_ENABLE_TF32=0 opts out.

Removing the in-process os.environ example makes the latching caveat
unnecessary: the launch-time form has no first-use ordering to explain.

Co-Authored-By: Claude Opus 5 <[email protected]>
@zcbenz
zcbenz force-pushed the docs-tf32-default branch from a19966a to 261a349 Compare August 4, 2026 00:32
@zcbenz
zcbenz merged commit 0b5e91f into ml-explore:main Aug 4, 2026
28 checks passed
@stoyoda0012-cyber
stoyoda0012-cyber deleted the docs-tf32-default branch August 4, 2026 06:28
@BrewTestBot BrewTestBot mentioned this pull request Aug 18, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants