chore: align mlxcel-core and mlxcel-surgery to the root crate (edition 2024, version 0.3.3)#445
Merged
inureyes merged 2 commits intoJun 25, 2026
Conversation
Member
Author
Implementation Review SummaryIntent
Findings AddressedNone. No CRITICAL/HIGH/MEDIUM/LOW correctness or safety findings. Remaining ItemsNone. Verification
|
Align the two workspace member crates with the root mlxcel crate, which is already on edition 2024 and version 0.3.3 (issue #272). mlxcel-core and mlxcel-surgery move from edition 2021 to 2024, and their versions move from 0.2.0 and 0.1.0 respectively to 0.3.3, per the CLAUDE.md release-versioning rule that the members carry the same version as the root from v0.3.3 onward. The root depends on both members by path with no version requirement, so no dependency spec changes; cargo update refreshes Cargo.lock. Edition 2024 migration, applied via cargo fix --edition plus manual review: std::env::set_var and remove_var become unsafe in 2024. The two runtime call sites (ensure_persistent_ptx_cache in lib.rs and apply_metal_ops_per_buffer_default in hardware.rs) are now wrapped in unsafe with an accurate SAFETY comment: both run once at the top of main right after CLI parsing (src/main.rs, src/bin/mlx_server.rs, src/bin/bench_decode.rs), before any model load, MLX op, or worker thread touches the environment, so no other thread is concurrently reading or writing it. The test-only sites in lang_analyzer already serialize env mutation through the env_lock() guard and carry a one-line test-only SAFETY note. extern "C" in hardware.rs becomes unsafe extern "C". The gen identifier (reserved in 2024) is escaped to r#gen at its function-parameter and local test-variable sites. Nested if let blocks collapse into 2024 let-chains where clippy flagged collapsible_if, and both crates are reformatted under the 2024 style edition so cargo fmt --check stays clean. Verified with cargo check, cargo clippy -D warnings, and cargo fmt --check on both crates (mlxcel-core built with metal,accelerate).
b002f5a to
057ceba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bring the two workspace member crates into line with the root
mlxcelcrate, which is already on Rust edition 2024 and version 0.3.3.mlxcel-coreandmlxcel-surgerymove from edition 2021 to 2024, and their[package] versionfields move from 0.2.0 and 0.1.0 respectively to 0.3.3.Version sync to 0.3.3
Per the CLAUDE.md "Release versioning" rule, from v0.3.3 onward the member crates carry the same version as the root. This PR sets both
src/lib/mlxcel-core/Cargo.tomlandsrc/lib/mlxcel-surgery/Cargo.tomltoversion = "0.3.3". The root depends on both members by path with no version requirement, so no dependency spec lines change;cargo update -p mlxcel -p mlxcel-core -p mlxcel-surgeryrefreshesCargo.lock(only the two member version strings change there).Edition 2024 migration
The migration was driven by
cargo fix --editionon each crate, then reviewed and hand-finished. The mechanical and manual touch points:std::env::set_var/remove_varbecomeunsafein edition 2024. The two runtime call sites are now wrapped inunsafe { ... }with an accurate SAFETY comment rather than the generic placeholdercargo fixinserts:ensure_persistent_ptx_cache(src/lib/mlxcel-core/src/lib.rs) andapply_metal_ops_per_buffer_default(src/lib/mlxcel-core/src/hardware.rs). Both functions are documented to run once at the very top ofmain, and all three in-tree callers (src/main.rs,src/bin/mlx_server.rs,src/bin/bench_decode.rs) invoke them right afterCli::parse(), before any model load, MLX op, or worker thread touches the process environment, so no other thread is concurrently reading or writing it. The stale "edition 2021 (set_var is not unsafe here)" comment inhardware.rsis replaced. The test-only sites inlang_analyzer/cache.rsandlang_analyzer/mod.rsalready serialize env mutation through the existingenv_lock()guard; they get theunsafewrap plus a one-line test-only SAFETY note. The pre-wrappedsparse_v_tests.rssite is left as-is.extern "C"inhardware.rsbecomesunsafe extern "C".genis a reserved keyword in 2024. It is escaped tor#genat its sites: themetal_ops_per_buffer_defaultandestimate_bandwidthfunction parameters inhardware.rs, and local test variables in the dflashround_loop.rs/round_loop_batched.rs.r#genkeeps the churn minimal and the public parameter name unchanged for callers.if letblocks collapse into 2024 let-chains where clippy'scollapsible_ifflagged them (29 sites across the cache, drafter, sampling, utils, weights, layers, generate, and lang_analyzer modules).cargo fixalso applied the 2024 match-ergonomics binding fix (|(&id, _)|to|&(&id, _)|) and rewrote twoif let ... else { break }loops into equivalentmatchforms for the changed temporary-scope rules.style_editiondefaults to the crate edition), which re-sorts imports (uppercase before lowercase) and wraps some macro arguments, socargo fmt --checkstays clean on CI.Test plan
cargo check -p mlxcel-surgery --lib --testscargo check -p mlxcel-core --lib --tests --examples --features metal,acceleratecargo clippy -p mlxcel-core --lib --tests --features metal,accelerate -- -D warningscargo clippy -p mlxcel-surgery --lib --tests -- -D warningscargo fmt -p mlxcel-core --checkandcargo fmt -p mlxcel-surgery --checkThe CUDA path (
#[cfg(feature = "cuda")]code, including theensure_persistent_ptx_cachebody) cannot be compiled on this macOS host, so the cuda-feature build and any release/whole-workspace verification are left for the reviewer/CI.Closes #272