Fix Metal model view overlap for q4#58
Open
Dango233 wants to merge 2 commits intoantirez:mainfrom
Open
Conversation
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
Fixes q4 startup on machines where the model crosses Metal's per-buffer
maxBufferLength, then documents q4 usage and benchmark results for a Mac Studio M2 Ultra with 192 GB RAM.The original implementation used a fixed 672 MiB model-view overlap. The q4 GGUF has 1152 MiB expert tensors, so on this machine one tensor can straddle two mapped Metal views and fail startup with:
ds4: Metal model range 106.89..108.01 GiB is not covered by mapped model viewsThis PR fixes that by deriving the Metal model-view overlap from the largest tensor described by the GGUF metadata, with a CLI/server override kept as a diagnostic lower-bound escape hatch.
192 GB q4 setup
On the tested Mac Studio M2 Ultra with 192 GB RAM, q4 runs at
--ctx 32768after raising the iGPU wired-memory limit:Benchmark
Single-run Metal CLI numbers using:
--ctx 32768--nothink-sys ""--temp 0-n 256The long benchmark uses
tests/test-vectors/prompts/long_code_audit.txt.Test plan
make ds4 ds4-server ds4_test./ds4 --inspect -m ds4flash.gguf./ds4_test --server