Repository navigation
Conversation
Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
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.
NumPy's argmin and argmax now stop when they encounter the first least or greatest representable value of a finite-only dtype. For
float4_e2m1fn,float6_e2m3fn, andfloat6_e3m2fn, no later element can beat that value. The scan compares the native values directly and retains the first index on ties, including signed zero and noncanonical upper padding bits. NaN-bearing formats keep the existing scan: a NaN after a finite maximum must still win.Measurement
I used the first 512 rows of
model.layers.0.self_attn.q_proj.weightfrom NVIDIA's Qwen3-8B NVFP4 checkpoint. The packed tensor isuint8[4096, 2048], representing4096 × 4096weights. The 1 MiB sample contains 131,072 blocks of 16 weights, the quantization group size in the model config. About 66% of blocks contain +6 and about 66% contain −6.Both source builds used GCC Release and NumPy 2.5.5 on Linux x86-64. Times are median milliseconds for one complete
axis=1reduction, with baseline9cad2fdand this revision interleaved over 12 rounds on one CPU core.The last two cases still scan the full or nearly full row. Those timings measure the native comparisons without a useful early exit. These results cover CPU index reductions, not model inference.
Correctness
An independent decoder checked the first minimum and maximum index for all 65,536 ordered pairs of stored bytes per finite format, including every upper-padding pattern, repeated equal values, both signs of zero, reversed views and axis changes. The built wheel passed the Python suite with 27,015 passed, 133 skipped and 45 expected failures. The upstream Test workflow has no jobs yet and needs approval to run its platform matrix for
e0a2412.Reproduce the checkpoint measurements
Run this with NumPy and each revision of ml_dtypes installed. The byte range is the first 1 MiB of the pinned tensor; it does not download the whole model shard.