Repository navigation
fix: include input dtypes in compiled kernel names - #19
Merged
Merged
Conversation
Apply ml-explore/mlx@c594e6ec38 (ml-explore/mlx#3427) to the vendored MLX. Compiled::Compiled built the kernel name from the moved-from inputs, so graphs that differ only in input dtype got the same name and shared one Metal library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 5 tasks
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.
Proposed changes
Applies the upstream fix ml-explore/mlx@c594e6ec38 (ml-explore/mlx#3427) to the vendored MLX in
Source/Cmlx/mlx, ahead of the planned upstream sync. The change is identical to the upstream commit.Compiled::Compiledmovesinputsandconstant_idsinto its members, then builds the kernel name from the moved-from parameters, so the input dtypes are missing from the name. Two graphs that differ only in input dtype (for example bf16 and f16 inputs that are upcast to float32) get the same name and share one Metal library, so the second graph runs the first one's kernel. The fix builds the name from the members.In mlx-swift-lm this makes
Qwen3NextCompiledDecodeTests(f16) fail wheneverQwen35QLoRATests(bf16) runs first in the same process.Testing
testCompiledKernelsDifferByInputDtype: compiles one function and calls it with bf16, then f16 input. It fails without this change and passes with it.swift teston an M5 Pro: 508 tests pass with--skip WiredMemoryTests.WiredMemoryTestspasses on its own, but in a full run it crashes inresident.cpp(-[_MTLFunctionInternal allocatedSize]: unrecognized selector). The crash also happens on main (384de38) and is not related to this change.Qwen35QLoRATests+Qwen3NextCompiledDecodeTeststogether pass (7 tests, 0 failures); on main they give 4 failures.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesswift-format 6.2.3 with
.swift-format: the changed test file is clean.AI usage
accurately describes the code changes.
🤖 Generated with Claude Code