Repository navigation
[executorch][native-ggml] Size the scheduler hash for graph leafs too - #24847
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24847
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (4 Unrelated Failures)As of commit 21d5db4 with merge base 4529a94 ( BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
digantdesai
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #24849 * #24848 * #24847 * #24846 * __->__ #24845 ## Ulterior Motive Running Muse Glimmer 30B through ExecuTorch Native's GGML engine. Its llama.cpp Q4_K_M checkpoint stores the LM head (`output.weight`) as q5_k. ## Rationale **What**: The GGML engine maps `gguf:q5_k` packed weights to `GGML_TYPE_Q5_K`. **Why**: The engine accepted only q4_k and q6_k, so the 30B package failed to load. The exporter already serializes any GGUF k-quant as `gguf:<type>`, and ggml implements Q5_K on every backend. ## Details - Codec lookup - **Before**: q4_k and q6_k checks with hard-coded block sizes, repeated for size computation and type selection. - **After**: one `kquant_type()` lookup serves both; block bytes come from `ggml_type_size`. - `test_gguf_q5_k_linear` checks a q5_k linear against eager, sharing the q6_k test's body. Authored with Claude Code. Differential Revision: D130721989 Pull Request resolved: #24845
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #24849 * #24848 * #24847 * __->__ #24846 * #24845 ## Ulterior Motive Running Gemma 4 31B through ExecuTorch Native's GGML engine on CUDA, to find why it decodes slower than llama.cpp on the same GGUF. ## Rationale **What**: A zero entry in a `native::rope` `inv_freq` table now leaves its pair of dims unrotated. **Why**: Gemma 4's partial RoPE writes the dims it does not rotate as zero inverse frequencies, and the engine rejected such tables at load with `ggml: rope inv_freq has a zero entry`. ## Details The engine passes `ggml_rope_ext` the factors `1 / inv_freq` with a frequency base of 1, so `theta = pos / factor`. - **Before**: a zero `inv_freq` threw at load. - **After**: its factor is infinite, so `theta = 0`: cos 1, sin 0, and the dims pass through unchanged, as in eager PyTorch. `test_rope_zero_frequency_leaves_dims_unrotated` zeroes the upper half of a Llama RoPE's `inv_freq`. Authored with Claude Code. Differential Revision: D130721990 Pull Request resolved: #24846
## Ulterior Motive Running Gemma 4 31B through ExecuTorch Native's GGML engine on CUDA, to find why it decodes slower than llama.cpp on the same GGUF. ## Rationale **What**: The backend scheduler is created for `2 * graph_size` tensors. **Why**: `ggml_backend_sched` hashes every node and every leaf of a graph it splits, and asserts that its hash set holds them all. It was sized for `graph_size`, which caps nodes and leafs separately, so a graph whose nodes and leafs together outgrew it failed that assertion, though either count alone fit. ## Details - **Before**: `ggml_backend_sched_new(..., graph_size, ...)`; ggml's own source notes the hash "needs to be size*2 to account for leafs". - **After**: `2 * graph_size`, room for a full graph of `graph_size` nodes and `graph_size` leafs. `test_graph_with_as_many_leafs_as_nodes` adds 2,100 separate constants to an input: 2,100 nodes and as many leafs, within the default graph size of 4,096. Authored with Claude Code. Differential Revision: [D130721991](https://our.internmc.facebook.com/intern/diff/D130721991/) ghstack-source-id: 469829014 Pull-Request: #24847
## Ulterior Motive Running Gemma 4 31B through ExecuTorch Native's GGML engine on CUDA, to find why it decodes slower than llama.cpp on the same GGUF. ## Rationale **What**: The backend scheduler is created for `2 * graph_size` tensors. **Why**: `ggml_backend_sched` hashes every node and every leaf of a graph it splits, and asserts that its hash set holds them all. It was sized for `graph_size`, which caps nodes and leafs separately, so a graph whose nodes and leafs together outgrew it failed that assertion, though either count alone fit. ## Details - **Before**: `ggml_backend_sched_new(..., graph_size, ...)`; ggml's own source notes the hash "needs to be size*2 to account for leafs". - **After**: `2 * graph_size`, room for a full graph of `graph_size` nodes and `graph_size` leafs. `test_graph_with_as_many_leafs_as_nodes` adds 2,100 separate constants to an input: 2,100 nodes and as many leafs, within the default graph size of 4,096. Authored with Claude Code. Differential Revision: [D130721991](https://our.internmc.facebook.com/intern/diff/D130721991/) ghstack-source-id: 469829014 Pull-Request: #24847
Stack from ghstack (oldest at bottom):
Ulterior Motive
Running Gemma 4 31B through ExecuTorch Native's GGML engine on CUDA, to find why it decodes slower than llama.cpp on the same GGUF.
Rationale
What: The backend scheduler is created for
2 * graph_sizetensors.Why:
ggml_backend_schedhashes every node and every leaf of a graph it splits, and asserts that its hash set holds them all. It was sized forgraph_size, which caps nodes and leafs separately, so a graph whose nodes and leafs together outgrew it failed that assertion, though either count alone fit.Details
ggml_backend_sched_new(..., graph_size, ...); ggml's own source notes the hash "needs to be size*2 to account for leafs".2 * graph_size, room for a full graph ofgraph_sizenodes andgraph_sizeleafs.test_graph_with_as_many_leafs_as_nodesadds 2,100 separate constants to an input: 2,100 nodes and as many leafs, within the default graph size of 4,096.Authored with Claude Code.
Differential Revision: D130721991