Repository navigation
Conversation
A shape fixes an MX profile, a row-major matrix blocked by 32 along each row, and the byte lengths of its codes and scales, proved to divide exactly. decodeLane_binary32 shows that a block's finite lane value within binary32's finite range is a binary32 value, so a decoder multiplying an element's binary32 value by the block's power of two can return it exactly. not_isBinary32_half_smallest shows that 2^-150, half binary32's smallest subnormal, fails the bound the theorem's binary32 values carry.
upload, download, decode to binary32 and quantize from binary32, at the scales OCP MX 1.0 section 6.3 selects or at given ones, with SAT or OVF for FP8. Lean computes each profile's values from FloatLib (decoded values, rounding candidates, the FP8 overflow bound and words, the largest power-of-two exponent) and passes them; the native side implements the E8M0 scale's value, the section 6.3 scale selection, the NaN block and the order of ties itself, which the CUDA check ties to FloatLib. Builds without LibTorch link placeholders that return an IO error.
Every code of every profile decoded at seven scales; conversion of every rounding boundary, special and pseudo-random blocks under SAT and OVF, at selected and given scales; each refusal beside a passing twin, an empty tensor and handle ownership.
Member
|
Thanks for this. Main is about to move to Lean 4.36 in one large commit (branch |
Author
|
Sure. |
Member
|
Hi! The Lean 4.36 update has landed on |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TorchLean's LibTorch backend, which runs on NVIDIA's graphics processors (GPU) through CUDA, had no
way to hold or convert tensors in the block-scaled low-precision formats of the Open Compute Project
(OCP) Microscaling Formats (MX) Specification 1.0. Its six formats are named by their exponent and
mantissa bits, E5M2, E4M3, E3M2, E2M3 and E2M1, beside the integer INT8, and store blocks of 32
elements sharing one 8-bit power-of-two scale (E8M0). FloatLib, already TorchLean's dependency,
defined the six formats with their decoding and their conversion of §6.3 in
FloatLib.Floats.Formats.OCP.MX.Standard, but no TorchLean module used it.This adds MX tensors to the LibTorch backend, with FloatLib's definitions as their semantics. A
tensor is a row-major matrix blocked by 32 along each row, held on the device as its codes and
scales. It is uploaded and downloaded as bytes, decoded to a binary32 buffer, and converted from one
at the scales §6.3 selects or at scales the caller gives, saturating (SAT) or overflowing (OVF) for
the 8-bit floating formats (FP8). Lean computes each format's values from FloatLib and passes them
to the native side, which implements the remaining rules itself: the scale's value, the scale
selection of §6.3, the block of NaN and the order of ties; the CUDA check ties those to FloatLib. A
proof shows that every finite decoded value within binary32's finite range is a binary32 value, so
decoding's one binary32 multiplication can be exact, and the CUDA check confirms it bit for bit on
every lane that is not NaN.
Add OCP MX tensor shapes and the exactness of decoding in binary32-- the shape, its bytelengths, and the exactness theorem.
Add CUDA operations on OCP MX tensors-- upload, download, decode and quantize, with theirplaceholders for builds without LibTorch.
Check the MX operations against FloatLib in the CUDA suite-- a CUDA check comparing the fouroperations with FloatLib.
At the branch's tip,
scripts/lake.sh build,test,lintandbuild NNCIpass, and so does theCUDA suite with
TORCHLEAN_REQUIRE_CUDA=1on an RTX 4060 Laptop GPU, with LibTorch 2.15.0 for CUDA13.2 and the CUDA 13.3 toolkit. CI builds only the CPU configuration, so the CUDA operations are
checked by the CUDA suite alone, and no other GPU, LibTorch version or CUDA toolkit was tried.