Skip to content

Add dinov2-mlx reference entry - #1450

Open
bahaehmimdi wants to merge 1 commit into
ml-explore:mainfrom
bahaehmimdi:add-dinov2-mlx-link
Open

Add dinov2-mlx reference entry#1450
bahaehmimdi wants to merge 1 commit into
ml-explore:mainfrom
bahaehmimdi:add-dinov2-mlx-link

Conversation

@bahaehmimdi

Copy link
Copy Markdown

Summary

Adds a dinov2/ entry linking to dinov2-mlx, a DINOv2 port for Apple Silicon verified against real, unmodified PyTorch (correctness and speed both checked with real numbers, not assumed).

I want to flag upfront that this takes a different approach from this repo's other examples, and I'm genuinely open to your guidance on whether/how it fits. Every example here (e.g. clip/, segment_anything/) is a native mlx.nn model definition, with torch used only for one-time offline weight conversion. dinov2-mlx instead runs the real, unmodified transformers.AutoModel through torch-mlx (a from-scratch PyTorch-API-compatible layer backed by mlx.core) at inference time — so the model code itself is real transformers, not a hand-written MLX port. Given that, this PR is a short linking README rather than inline runnable code (every other entry here is self-contained code, so this is unusual on that front too).

If this isn't a fit for the example gallery as-is, totally understand — happy to close this, or restructure it however you think makes more sense.

Results

  • pooler_output verified against real PyTorch: ~0.32% relative error (consistent with expected float accumulation noise across 24 layers).
  • Beats real PyTorch's own MPS backend by ~1.12-1.15x, both backends timed on the identical full pipeline (image → resize → crop → forward) to avoid a benchmark-asymmetry bug found and fixed in a sibling project's history.
  • Full accounting, including negative results, in the linked repo's BENCHMARK_RESULTS.md.

Test plan

  • Single new dinov2/README.md, no changes to existing files
  • Link verified working

🤖 Generated with Claude Code

https://claude.ai/code/session_01HooZphcpzukceMrdArswsP

Links to a DINOv2 port verified against real PyTorch (correctness and
speed both checked, not assumed). Flagged in the README: this runs the
real transformers model through torch-mlx rather than a native mlx.nn
reimplementation, a different shape of contribution than this repo's
usual examples -- open to restructuring or closing based on maintainer
feedback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HooZphcpzukceMrdArswsP
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.

1 participant