Skip to content

Remove dead Highway guards - #69

Merged
jjang-ai merged 1 commit into
osaurus-ai:mainfrom
rcfa:fix/highway-dead-guards
Nov 28, 2026
Merged

jjang-ai merged 1 commit into
osaurus-ai:mainfrom
rcfa:fix/highway-dead-guards

Conversation

@rcfa

@rcfa rcfa commented Nov 26, 2026

Copy link
Copy Markdown

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.cpp compiles only inside its outer MLX_USE_HIGHWAY_KERNELS guard.
    Its inner tests of that macro are always true, so their #else and #if !defined(MLX_USE_HIGHWAY_KERNELS)
    branches never compile: 334 lines.
  • In mlx/backend/cpu/simd/type.h the inner guard repeats the outer one. Nothing defines
    MLX_USE_HIGHWAY_JIT_SIMD.

What changes

unifdef -DMLX_USE_HIGHWAY_KERNELS removed the dead branches of quantized_highway_backend.cpp, inside its outer
guard only; the outer guard stays. type.h keeps 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 shared

This batch's PRs but the last (fix/float-floor-divide, which came out of this validation), merged together on
main 23f364e with the two overlap resolutions (apple/fixes-2 and apple/r3-core in
python/tests/test_quantized.py; apple/r3-core and apple/fixes-3 in mlx/allocator.h), are mlx 8de1a51; vmlx-swift 31458a0d3 builds on it (osaurus-ai/vmlx-swift main bbd237750 with our open vmlx-swift
patches). Built and run, compared with main:

  • macOS (M4 Max, Release, Metal on): C++ suite 410 of 410 on the CPU and on Metal. vmlx-swift builds for macOS 14.0;
    its suite (swift test --no-parallel, 1046 tests) fails no test that passes on its main.
  • Linux arm64 and amd64 (containers, clang Release, Highway): C++ suite 431 of 431 on both (main 412 of 412).
    vmlx-swift's Linux CI steps pass: VMLXLinuxTests 37 of 37, the CPU kernel tests 61 of 61 at both thread settings.
  • Linux, the CI-equivalent Python run (osaurus-ai's Linux job, built and run the same way: GCC, Debug, Highway,
    DEVICE=cpu, python/tests module by module, torch 2.15 for the CPU). arm64: main 881 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: main
    882 pass, 92 skip, 1 fail; the batch 906 pass, 96 skip, 1 fail, 1 error. No test that passes on main fails on the batch. The failures are
    main's own: test_compile_sigmoid_matches_eager (bfloat16: the compiled CPU sigmoid is less accurate than the
    eager Highway kernel) and, on arm64 only, bfloat16 test_torch_conv_2D, where torch 2.15's own aarch64 bfloat16
    conv2d is off by up to 8.8 against float64 (MLX is within 0.06). test_async_eval_error_in_synchronize failed once on amd64; it fails about 1 run in 5 there on main too: the error it expects from synchronize can come from async_eval (the same code is on ml-explore/mlx main).
  • Three tests of main fail at random, on every branch alike, because they draw unseeded inputs or race:
    test_double.TestDouble.test_unary_ops in about 8% of runs (float32 erf is accurate to 1.5e-7 absolute, which
    misses rtol 1e-5 near 0 against the fork's accurate float64 erf); test_ops.TestOps.test_divmod in about 1%
    (the float16 quotient is off by one when a / b rounds 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's
    fix/float-floor-divide fixes the second; the first gets a PR of its own.
  • osaurus-ai/mlx's GitHub Actions have not run since 2026-10-08, so this PR shows no checks; the runs above follow
    its Linux and macOS jobs.
  • This branch alone, the same Linux Python run (arm64): 881 pass, 92 skip, 2 fail: test_compile_sigmoid_matches_eager, test_torch_conv_2D as on main.

🤖 Generated with Claude Code

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.
@jjang-ai
jjang-ai merged commit 43a802b into osaurus-ai:main Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants