Repository navigation
Conversation
Metal kernels compile with flush-to-zero, so a float32 `greater` reads a positive subnormal as `0.0`. Every symmetric codebook from 3 bits up has a `0.0` boundary, so `f32::from_bits(1)` — one bucket above that boundary on the host — was landing on the boundary on device. The nightly-verify run 46937282079 failed on exactly two values of exactly that shape: device: [... 3, 3, ...] host: [... 4, 3, ...] `boundary_indices_on_device` now compares an unsigned monotonic key whose integer order is the IEEE-754 compare order, so no float compare is involved: fold -0.0 onto +0.0, map NaN to 0 (it is above nothing), then flip the sign bit for non-negative values and every bit for negative ones. Integer compares do not flush. Verified on the night's commit 4d8a05c (Metal, macOS 27.2): - `cache::turbo::` 125 passed, 0 failed (was 2 failed). - `cargo test -p mlxcel-core --lib -- --test-threads=1`: 2687 passed, 7 ignored, 0 failed. - New regression test `device_boundary_indices_keep_subnormals_above_a_zero_boundary` pins the rule at bits 3/4 and head dims 64/128/256; mutation-checked by restoring the float compare, which fails it with `left: [3, 3, 4]` / `right: [4, 4, 4]`. - `cargo fmt --check` and `cargo clippy -p mlxcel-core --lib --tests -- -D warnings` clean. Refs lablup#3652
|
Holding this PR: What landed on main. Your version is also correct. The unsigned key (flip the sign bit for non-negative values, every bit for negative ones, fold Test value. The new #3652 scope. The tracker has more failures than these two tests: the night of What would make it mergeable. Merge |
|
Closing as a duplicate: the FTZ defect this branch fixes is already on
Upstream's version therefore supersedes this one on the same defect, so there is nothing to rebase. Note that #3652 remains open as the nightly-red tracking issue and needs a fresh look at the current run; that is separate from this specific FTZ fix, which is now in |
Refs #3652.
Problem
The nightly-verify run for
4d8a05c4failedmlxcel-core --libon two device-vs-host index tests:The night's diff named the input class: device
3against host4at two positions.Cause
Metal kernels compile with flush-to-zero, so a float32
greaterreads a positive subnormal as0.0. Every symmetric Turbo codebook from 3 bits up has a0.0boundary, sof32::from_bits(1)(one bucket above that boundary on the host) was landing on the boundary on device.Probes against
boundary_indices_on_deviceseparate the layers: the upload round-trip and the sum both keep bits1,greater(denormal, -1.0)is correct, and onlygreater(denormal, 0.0)and evendenormal * 2.0flush.Change
boundary_indices_on_devicecompares an unsigned monotonic key instead, whose integer order equals the IEEE compare order, so no float compare takes part. Two host rules the raw bits do not carry are explicit:-0.0folds onto+0.0(the host treats them as equal)-inf.The rest is the standard transform: flip the sign bit for non-negative values, every bit for negative ones.
Verification
On
4d8a05c4, Metal, macOS 27.2, then re-run on the merge base this PR targets:cache::turbo::: 125 passed, 0 failed (was 2 failed).cargo test -p mlxcel-core --lib -- --test-threads=1: 2722 passed, 7 ignored, 0 failed.device_boundary_indices_keep_subnormals_above_a_zero_boundarypins the rule at bits 3/4 and head dims 64/128/256, negative side included. Mutation-checked: restoring the float compare fails it withleft: [3, 3, 4]/right: [4, 4, 4].cargo fmt --checkandcargo clippy -p mlxcel-core --lib --tests -- -D warningsclean.One file,
codebook.rsonly.