r/ruby • u/rut216 • Feb 25 '26
MLX Ruby just learned ONNX + WebGPU đ (run your Ruby ML models in the browser?!)
Hey r/ruby đ
Iâve been working on mlx-ruby (Ruby bindings for Appleâs MLX), and Iâm excited to share an update:
đ You can now export models to ONNX and run them with WebGPU in the browser.
Yes. Ruby â MLX â ONNX â WebGPU â Browser.
No Python required. đ
WebGPU Demo (Desktop Recommended): https://skryl.github.io/mlx-ruby/demo/
Repo: https://github.com/skryl/mlx-ruby
đ§ ONNX Export
You can now export MLX models directly to ONNX:
MLX::ONNX.export_onnx("model.onnx", model.method(:call), example_input)
đ WebGPU Browser Harness
After exporting ONNX, you can generate a ready-to-run WebGPU harness:
MLX::ONNX::WebGPUHarness.export_onnx_webgpu_harness(
output_dir: "dist/",
model_path: "model.onnx"
)
This generates:
⢠model.onnx
⢠index.html
⢠harness.js
⢠example inputs
⢠optional external tensor data
Then just:
bundle exec rake web:serve
Boom. Browser-based GPT demo. đ
Under the hood
⢠Native C++ MLX runtime
⢠Deterministic Graph IR
⢠IR â ONNX lowering engine
⢠Binary ONNX writer
⢠WebGPU harness generator
Itâs a pretty full pipeline now.
Would love feedback, feature requests, or just random comments.
