Skip to content

Instantly share code, notes, and snippets.

View aditvenk's full-sized avatar

Aditya Venkataraman aditvenk

  • Meta
  • San Jose
View GitHub Profile
@aditvenk
aditvenk / softmax_mlx_torch.py
Last active October 19, 2025 05:12
MLX vs Torch softmax microbenchmark
"""Softmax microbenchmark comparing Torch and MLX on Apple Silicon.
The script measures six variants of softmax (manual/native implementations in
eager and compiled form) on identical all-ones inputs. Torch executes on MPS
while MLX runs on the Apple GPU. Each variant is verified once against the
``torch.softmax`` reference before timing.
Optionally set ``MTL_CAPTURE_ENABLED=1`` to record MLX Metal captures
while the correctness checks run. Traces are written to the current
directory.