Repository navigation
Remove dead Highway guards - #69
Merged
Merged
Conversation
quantized_highway_backend.cpp compiles only inside its outer MLX_USE_HIGHWAY_KERNELS guard. So its inner tests of that macro are always true, and their #else and #if !defined(...) branches never compile. `unifdef -DMLX_USE_HIGHWAY_KERNELS` removed them, inside the outer guard only. In simd/type.h the inner guard repeated the outer one. Nothing defines MLX_USE_HIGHWAY_JIT_SIMD. No build compiles different code: every removed line was unreachable.
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.
What was wrong
Dead preprocessor branches around the Highway kernels, found in review (2026-10-14) and left for after #10:
mlx/backend/cpu/quantized_highway_backend.cppcompiles only inside its outerMLX_USE_HIGHWAY_KERNELSguard.Its inner tests of that macro are always true, so their
#elseand#if !defined(MLX_USE_HIGHWAY_KERNELS)branches never compile: 334 lines.
mlx/backend/cpu/simd/type.hthe inner guard repeats the outer one. Nothing definesMLX_USE_HIGHWAY_JIT_SIMD.What changes
unifdef -DMLX_USE_HIGHWAY_KERNELSremoved the dead branches ofquantized_highway_backend.cpp, inside its outerguard only; the outer guard stays.
type.hkeeps only the outer guard.No build compiles different code: every removed line was unreachable. The diff only removes lines (337).
Tests
None needed. Linux arm64 (clang Release, Highway on): full C++ suite 412/412, as
main.Validation of the batch in
sharedThis batch's PRs but the last (
fix/float-floor-divide, which came out of this validation), merged together onmain23f364e with the two overlap resolutions (apple/fixes-2andapple/r3-coreinpython/tests/test_quantized.py;apple/r3-coreandapple/fixes-3inmlx/allocator.h), are mlx 8de1a51; vmlx-swift 31458a0d3 builds on it (osaurus-ai/vmlx-swiftmainbbd237750 with our open vmlx-swiftpatches). Built and run, compared with
main:its suite (
swift test --no-parallel, 1046 tests) fails no test that passes on itsmain.main412 of 412).vmlx-swift's Linux CI steps pass:
VMLXLinuxTests37 of 37, the CPU kernel tests 61 of 61 at both thread settings.DEVICE=cpu,python/testsmodule by module, torch 2.15 for the CPU). arm64:main881 pass, 92 skip, 2 fail;the batch 906 pass, 96 skip, 2 fail (tree c43a37eec, which differs from 8de1a51 only in a C++ test). amd64:
main882 pass, 92 skip, 1 fail; the batch 906 pass, 96 skip, 1 fail, 1 error. No test that passes on
mainfails on the batch. The failures aremain's own:test_compile_sigmoid_matches_eager(bfloat16: the compiled CPU sigmoid is less accurate than theeager Highway kernel) and, on arm64 only, bfloat16
test_torch_conv_2D, where torch 2.15's own aarch64 bfloat16conv2d is off by up to 8.8 against float64 (MLX is within 0.06).
test_async_eval_error_in_synchronizefailed once on amd64; it fails about 1 run in 5 there onmaintoo: the error it expects fromsynchronizecan come fromasync_eval(the same code is on ml-explore/mlx main).mainfail at random, on every branch alike, because they draw unseeded inputs or race:test_double.TestDouble.test_unary_opsin about 8% of runs (float32erfis accurate to 1.5e-7 absolute, whichmisses
rtol1e-5 near 0 against the fork's accurate float64erf);test_ops.TestOps.test_divmodin about 1%(the float16 quotient is off by one when
a / brounds up to an integer, e.g. 73.625 / 1.248 = 58.99 gives 59;ml-explore/mlx main has the same code); and, on amd64,
test_async_eval_error_in_synchronize(above). This batch'sfix/float-floor-dividefixes the second; the first gets a PR of its own.its Linux and macOS jobs.
test_compile_sigmoid_matches_eager,test_torch_conv_2Das onmain.🤖 Generated with Claude Code