Repository navigation
f16 scalar narrowing on Metal and in intelnpu.pack_f16 match upstream; CUDA recorded unmeasured (#50) - #87
Merged
Merged
Conversation
… intelnpu pack_f16 narrows as upstream x86 (#50) Measured on upstream torch 2.13.0 mps with the #28 witness 0.0312652587899...: add.Scalar / sub.Scalar / rsub.Scalar give 0.03125, i.e. f16(f32(w)) two roundings (4096/4096 random inputs), while the shim rounded once (0.0312805). Alpha, fill, clamp, masked_fill, where already agreed; bf16 already matched. - aten.rs: scalar_operand_narrower(tag, device) narrows f16 operands on Metal through f32; arith_scalar and rsub_scalar use it for `other`. - intelnpu.pack_f16: values pass through f32 before '<e' (upstream x86 builds Half from float, Half.h). - CUDA: candle-kernels casts are UNMEASURED; docs/devices/CUDA.md records upstream's rule; test_cuda.py gains a witness test that skips by name without cuda. Red before: test_mpsnarrow add/sub/rsub (shim 0.031280517578125 vs upstream mps 0.03125); pack_f16 [0.0312805, ..., 1.0009765625] vs [0.03125, ..., 1.0]. Nullified: the base aten.rs and the old pack_f16 each turn their test red.
Contributor
Gate on CI (issue #24)Full gate: 127 suites = 119 run on at least one CI runner + 8 local-only. The local gate (
Local-only: verified by no CI runner (8)
Suites that verified nothing, or failed, on a runner
Every suite, every runner
A SKIP is unverified on that runner, never passed. UNVERIFIED means the suite ran and every one of its tests skipped by name. |
Closed
2 tasks
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.
Closes #50 (CUDA path is recorded as UNMEASURED by name, per the issue's second criterion)
Defect fixed
add.Scalar/sub.Scalar/rsub.Scalar: the scalar operand is narrowed f64 -> f32 -> f16 like upstream mps (measured: 0.03125 for witness 0.031265258789971995; 4096/4096 random inputs match the two-rounding form, 592/4096 the one-rounding form). The issue's premise was reversed: the shim rounded once, upstream mps rounds twice. Alpha, fill, clamp, masked_fill, where and all bf16 cells already agreed.intelnpu.pack_f16: narrows through f32 first, upstream x86's rule (Half.h:Half(float16_t)exists only on aarch64 without CUDA).Documentation corrected:
docs/devices/CUDA.md§6 step 9 records upstream CUDA's rule and that candle-kernels casts are unmeasured.Test added:
tests/devices/mps/test_mpsnarrow.py(4, upstream mps oracle);test_pack_f16_narrows_a_double_as_upstream_x86_does;test_f64_narrowing_on_cuda_agrees_with_upstream_cuda(skips by name: UNMEASURED without cuda).Evidence (local, this Mac, worktree)
add.Scalar ... shim 0.031280517578125, upstream mps 0.03125;pack_f16 [0.0312805..., 1.0009765625] vs [0.03125, 1.0].aten.rsand the oldpack_f16each turn their test red.suites=123/123 ok=2015 FAIL=3; the skipvis FAIL (the new cuda test printed its skip in a form the ledger cannot count) is fixed in this commit and re-run green; the other two are worktree environment (test_toolguard_wheel_staging,test_wheelmatrix).Not done: CUDA measurement (needs a CUDA machine; the CUDA build itself is red on every branch, #86).