Repository navigation
Debug time graph verification - #4711
Merged
Merged
Conversation
zcbenz
force-pushed
the
graph-leak-check
branch
3 times, most recently
from
October 17, 2026 07:09
99b0958 to
0a31578
Compare
This was referenced Oct 20, 2026
zcbenz
force-pushed
the
graph-leak-check
branch
4 times, most recently
from
October 25, 2026 23:12
7fcf022 to
aed7967
Compare
andresy
approved these changes
Oct 26, 2026
zcbenz
force-pushed
the
graph-leak-check
branch
from
October 26, 2026 23:52
aed7967 to
137a3bb
Compare
1 task
jonathan308
added a commit
to Layr-Labs/mlx
that referenced
this pull request
Oct 30, 2026
try_gemma4_expert_qmm registered the descriptor and tile-count buffers as temporaries before the builder kernel. Without MLX_GATHER_QMM_EXPERT_SLICES=trust it then synchronizes to read the tile count back, which commits that command buffer and releases its temporaries, and encodes the tile kernel, which reads both buffers, into the next one. Only the function's own arrays then held the buffers, and they are freed when eval_gpu returns, before the tile kernel runs. The buffers are now registered with the command buffer that holds the tile kernel. Upstream's debug graph check (ml-explore#4711) found this in mlx-swift's sorted-gather tests on a GPU without neural accelerators. Serving uses trust, which does not synchronize. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonathan308
added a commit
to Layr-Labs/mlx
that referenced
this pull request
Oct 30, 2026
13ab090 kept the tile descriptors alive, but the readback taken without MLX_GATHER_QMM_EXPERT_SLICES=trust also commits the contiguous copies that GatherQMM and gather_qmm_rhs make of non-contiguous operands, such as broadcast weights. The tile kernel, the legacy route that runs when no tile kernel is available, and the unsorted routes that run when the build is retracted read those copies from the next command buffer, after the committed one has released them. gather_qmm_rhs now retains the operands, original and copied, in the next command buffer whenever the route ran without trust. Upstream's debug graph check (ml-explore#4711) found it in mlx-swift's testGemmaGateUpSortedAffineGatherQuantizedMMExpertSlices, whose weights are broadcasts, on a GPU without neural accelerators. Serving sets trust, which does not read back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
inureyes
added a commit
to lablup/mlxcel
that referenced
this pull request
Nov 6, 2026
…gnatures Upstream 4ca8d5d5a (ml-explore/mlx#4568) added a generated-source hash to fast::CustomKernel's constructor, and the fork's mlx/backend/rocm/custom_kernel.cpp still passed grid as the fourth argument. Pass std::hash<std::string>{}(kernel_source), as the CUDA backend does; the ROCm JIT module keeps keying on the source itself (LOCAL_FIXES item 33). Upstream 5ee1e8edf (ml-explore/mlx#4711) added add_out_to_temporary_on_allocation to reshape_gpu, which the shared gpu/primitives.cpp overlay now calls with four arguments. The fork's definition in mlx/backend/rocm/copy.hip takes the flag and registers the output as a temporary when it is set, matching CUDA. The first was a compile error on MSVC; the second would have been a link error on any ROCm build. Recorded as LOCAL_FIXES items 73 and 74.
inureyes
added a commit
to lablup/mlxcel
that referenced
this pull request
Nov 6, 2026
* update: advance MLX pin to 9f806b36 and refresh backend overlays Move the CMake pin from 7ca40033 (2026-10-26) to 9f806b36 (2026-11-05), a reproducible main snapshot 46 commits newer and 81 past stable v0.32.4, which the previous pin already postdated. Rebase the 14 drifted CPU, Metal and CUDA whole-file overlays with a three-way merge. Upstream #4803 now accumulates the CPU affine quantized matmul in float, so only fp_qmm and fp_qmm_t stay local. The new Metal affine qmv_mma (#4787) is placed behind the MLXCEL_QMV_WIDE off-switch so the speculative exactness retry still restores byte-equality between a verify block and the single-token chain. Metal device.cpp keeps the input-budget override across upstream's env rework, and quantized.metal re-appends mlxcel_affine_qmm_t_rows after the restructured instantiation macros. Two upstream API moves needed code changes: env::get_var is now config::get (#4647), used by the cxx bridge and the CUDA SDPA switches, and gpu_core_count() (#4781) needs IOKit on the macOS link line because upstream links it PRIVATE. Retarget the ROCm core files with the fork unchanged, resolve the fast.h and gpu/primitives.cpp conflicts, and regenerate CORE_RESIDUAL.diff. See docs/mlxcelverse/mlx-pin-2026-11-06.md. * fix(rocm): use upstream's template_arguments_hash instead of the fork copy Upstream 4ca8d5d5a (ml-explore/mlx#4568) declares fast::template_arguments_hash in mlx/backend/common/custom_kernel.h, which mlx/fast.h includes. The fork keeps a private copy in mlx/backend/rocm/custom_kernel.cpp, so the unqualified call there matches both declarations and MSVC rejects it as ambiguous (C2668) when the ROCm backend and the common library are built together. Remove the fork copy; the upstream one also maps '-' to '_' in integer arguments so a negative template argument cannot produce an invalid kernel name. Recorded as LOCAL_FIXES item 73. * fix(rocm): adapt the backend to upstream custom-kernel and reshape signatures Upstream 4ca8d5d5a (ml-explore/mlx#4568) added a generated-source hash to fast::CustomKernel's constructor, and the fork's mlx/backend/rocm/custom_kernel.cpp still passed grid as the fourth argument. Pass std::hash<std::string>{}(kernel_source), as the CUDA backend does; the ROCm JIT module keeps keying on the source itself (LOCAL_FIXES item 33). Upstream 5ee1e8edf (ml-explore/mlx#4711) added add_out_to_temporary_on_allocation to reshape_gpu, which the shared gpu/primitives.cpp overlay now calls with four arguments. The fork's definition in mlx/backend/rocm/copy.hip takes the flag and registers the output as a temporary when it is set, matching CUDA. The first was a compile error on MSVC; the second would have been a link error on any ROCm build. Recorded as LOCAL_FIXES items 73 and 74.
Brooooooklyn
added a commit
to mlx-node/mlx
that referenced
this pull request
Nov 29, 2026
…tive tracer
One env var, read once as a level; unset or 0 is off and costs one
member load per eval.
1 [metal-command] JSON per committed command buffer and [mlx-evaluation]
JSON per eval_impl
2 also [metal-op] <primitive name> per GPU primitive
3 also its input -> output dtypes
Adapted for upstream ml-explore#4647 (get_default_max_ops_mb_per_buffer + env::*),
ml-explore#4711 (verify_graph), ml-explore#4882 (Scheduler::wait_for_capacity overload), and
ml-explore#5004 (tracing_counter).
Brooooooklyn
added a commit
to mlx-node/mlx
that referenced
this pull request
Nov 29, 2026
…aph limits, and Win32 NVRTC/PTX fixes Adapted for upstream: - ml-explore#4885: use private cache_memory_locked() and memory_limit_locked() while holding mutex_ in malloc_async()/free() to avoid recursive mutex deadlock, preserving overflow asserts. - ml-explore#4868: preserve move_to_device_memory() / cuda_malloc_async() / cuda_free_async(). - ml-explore#4711: preserve debug track_allocation/untrack_allocation and registered_data_ptrs_. - ml-explore#4706: preserve BIN_DIR macro and try/catch in delayload.cpp alongside resolve_bin_dir(), std::error_code guards, and unconditional nvrtc-builtins preload. - ml-explore#4745: preserve force_single_root_/roots_/get_noop_kernel_ptr() in cuda/device.{h,cpp}.
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.
Add debug time check that would throws error when 2 common types of errors are found:
1. Temporary arrays are not registered by
add_temporaryThis is checked by iterating all pointers in the graph and checking whether they are valid allocations, which can capture mistakes like the ones fixed by #4660:
2. Input or outputs arrays are accidentally registered by
add_temporaryThis is checked by simply checking whether the temporaries contain inputs or outputs of a primitive, which can capture mistakes like the ones fixed by #4702: