Metal cache admission can exceed the configured cache limit
维护者通常 3 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- cpp
- 领域
- backend, performance
调研方向
Start by locating MetalAllocator::free() and the cache limit checks described in the issue. Reproduce the oversized and mixed allocation cases with the allocator tests, then inspect the linked pull request #4842 for the two-file fix and regression coverage. Done means freed buffers respect the configured limit, including zero, and the reported reuse cases are covered.
由索引模型根据 Issue 内容生成。
描述
MetalAllocator::free() checks the current cache size before admitting the incoming buffer, without including that buffer's length. This can exceed set_cache_limit() as soon as a live allocation is released.
On Apple M1 Max, using current main 9f806b3606eaa9f7c807238f6bd465185cd94d6d:
- Set the cache limit to 1 MiB and clear it.
- Allocate and release a 2 MiB buffer:
get_cache_memory()reports 2,097,152 bytes. - Clear it, hold a 512 KiB allocation while allocating/releasing a 768 KiB allocation, then release the 512 KiB allocation: the cache reaches 1,310,720 bytes with a 1,048,576-byte limit.
No later allocation is made before inspecting each overshoot. The checks use allocator::malloc directly, so shader execution and asynchronous command completion are not involved in the reproduction.
Expected: an incoming buffer larger than the allowance should not enter the cache. A smaller incoming buffer should be admitted only after enough older cached bytes are released. Zero should continue to disable reuse. This concerns the freed-buffer cache, not a limit on active allocations or total process memory.
I have a small two-file fix and regression test covering oversized admission, mixed shapes, recent-shape reuse and zero allowance.
- 主要语言
- C++
- 星标
- 29.1k
- 派生
- 2.4k
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 103
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ml-explore/mlx 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
ml-explore/mlx#4832 · 1 条评论 ·
维护者通常 3 天内回复
-
[BUG] `mx.expand_dims` docs: the Args section names `axes`, but the parameter is `axis`可能已有人在做 @Redempt1onzzZZ 于 3 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
ml-explore/mlx#4829 ·
维护者通常 3 天内回复
-
[BUG] `mx.qqmm` docs: the Args section names `global_scale`, but the parameter is `global_scale_x`可能已有人在做 @XXXXRT666 于 5 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
ml-explore/mlx#4815 ·
维护者通常 3 天内回复
-
[BUG] FP4 quantization on CPU rounds ties toward zero while Metal rounds to even可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 74/100
ml-explore/mlx#4753 ·
维护者通常 3 天内回复
-
难度 4/5 3-5 天 新手友好度 43/100
ml-explore/mlx#4843 ·
维护者通常 3 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
arvidn/libtorrent#9126 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
Sunrisepeak/mcpp-language-server#80 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 66/100
xiaoyifang/goldendict-ng#3148 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
triton-inference-server/server#9069 ·
维护者通常 1 天内回复