Skip to content

Use the current interpreter in the comparative benchmark runner - #4016

Merged
zcbenz merged 1 commit into
ml-explore:mainfrom
ayaangazali:fix-benchmark-compare-interpreter
Aug 6, 2026
Merged

Use the current interpreter in the comparative benchmark runner#4016
zcbenz merged 1 commit into
ml-explore:mainfrom
ayaangazali:fix-benchmark-compare-interpreter

Conversation

@ayaangazali

Copy link
Copy Markdown
Contributor

Proposed changes

benchmarks/python/comparative/compare.py shells out to a literal "python", so it fails immediately on any setup where only python3 is on PATH, which includes a stock macOS shell:

$ python benchmarks/python/comparative/compare.py ...
FileNotFoundError: [Errno 2] No such file or directory: 'python'

Switched the four subprocess calls to sys.executable. Besides fixing the crash, this makes the child benchmarks run under the same interpreter as the parent, so running compare.py from a virtualenv now benchmarks that environment's MLX rather than whatever python happens to resolve to.

mlx.launch already does the same thing for the same reason (--python defaults to sys.executable).

After the change the subprocesses actually start, which you can see because bench_mlx.py gets far enough to parse its own arguments. On this machine the run then stops in bench_torch.py because torch is not installed, which is the expected behaviour for a comparison benchmark without torch.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

(no tests since this is a benchmark helper script; verified by running it before and after)


as always, being clear about process: freshman contributor and i use Claude Code to help me look around, but i hit this by actually running the benchmark scripts, and i checked that sys.executable is the pattern already used elsewhere in the repo before picking it. i also grepped for other hardcoded "python" subprocess calls and did not find any, so this looks like the only spot.

@zcbenz
zcbenz merged commit 679f3ef into ml-explore:main Aug 6, 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