Repository navigation
Host-weight prefetch in the scheduler, faster MoE cache prompt and decode, cache seeding under llama-server #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: base/upstream-cbe28bb3c
Are you sure you want to change the base?
Changes from all commits
a6b82a7
ae10ae3
40b5c8d
f2ee4b9
df4b95e
eb761c8
9773c1f
e345a2e
7fe4763
63ac2b9
26bdf01
ada4e66
521ca75
79d53ac
8a257ed
416cd2d
97af3d1
fc5c24c
7557cc5
2ffc775
c32f484
31beb5c
ff374cc
a6e53c7
e3982e4
90a34bc
3142161
316a0fa
1762594
95660d3
5f77918
e9e110a
fb2ebac
f51db4d
efe0d04
7a07db5
8af17ae
1b902e9
76c345e
67edd5a
6e7668f
dd2570d
0dbd5f3
ef8f414
3954908
d5199e7
6f86c50
b3185a8
60bbee5
0a1a7bf
d210f90
72bee9a
04f8cae
b0bc690
ff2a0f8
e1c1401
976424e
4d46477
22a25c5
14442c1
12a5f87
74ac7c6
1c1ba19
117ec9b
5ea57fe
686c345
4e834c2
a58a5df
119295b
4ffd9b8
f4ce181
87fa81f
e5e12c6
109d0d8
a97a224
87f5c3d
6e14ff8
807e747
ec08e0d
5206f10
95bebe6
28ac14d
c07406c
a5471af
aee25df
d6be8c6
faff888
fd7489e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -601,6 +601,8 @@ extern "C" { | |
|
|
||
| GGML_OP_GLU, | ||
|
|
||
| GGML_OP_MOE_CACHE_LOOKUP, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding AGENTS.md reference: AGENTS.md:L91-L91 Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 3954908. test-backend-ops has no MOE_CACHE_LOOKUP case, so I added the support rows to docs/ops/CUDA.csv (supported) and docs/ops/CPU.csv (not supported) by hand in the format test-backend-ops emits, and regenerated docs/ops.md with scripts/create_ops_docs.py. |
||
|
|
||
| GGML_OP_COUNT, | ||
| }; | ||
|
|
||
|
|
@@ -1503,6 +1505,24 @@ extern "C" { | |
| struct ggml_tensor * b, | ||
| struct ggml_tensor * ids); | ||
|
|
||
| // device-side lookup in a cache of MoE experts (see llama-moe-cache.cpp) | ||
| // ids: I32 [n_expert_used, n_tokens], the experts selected in layer il | ||
| // map: I32 [n_expert, n_layer], the slot of each expert of each layer, -1 if not cached (updated in place) | ||
| // state: I32 [8 + 3*n_slots], eviction state of the slots of the cache (updated in place) | ||
| // banks: the cached experts, [ne0, ne1, n_slots + 1] each (updated in place) | ||
| // host: device-accessible pointers to the experts of layer il in host memory, with the layout of the banks | ||
| // the missing experts get a slot (the least recently used one, approximated with a CLOCK) and are copied from host memory | ||
| // result: I32 [n_expert_used, n_tokens] slots of the selected experts, then the copied experts; ggml_view_2d(ctx, res, n_expert_used, n_tokens, res->nb[1], 0) gives the ids for ggml_mul_mat_id with a bank | ||
| GGML_API struct ggml_tensor * ggml_moe_cache_lookup( | ||
| struct ggml_context * ctx, | ||
| struct ggml_tensor * ids, | ||
| struct ggml_tensor * map, | ||
| struct ggml_tensor * state, | ||
| struct ggml_tensor ** banks, | ||
| const void ** host, | ||
| int n_banks, | ||
| int il); | ||
|
|
||
| // A: m columns, n rows, | ||
| // B: p columns, n rows, | ||
| // result is m columns, p rows | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a stateful GGML operator and a substantial CUDA kernel, but the commit adds no
test-backend-opscase or CPU reference implementation against which its slot assignment, eviction, and copied expert data can be checked. As a result, backend consistency testing cannot exercise this operator, leaving correctness regressions in the new cache path undetected; add the required backend-op test coverage and reference behavior.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The op has no CPU implementation (the CPU backend reports it as unsupported, it is a device-side cache over host-mapped expert memory), so test-backend-ops has no reference to compare against, and a CPU port of the CLOCK assignment plus the stateful harness would be a sizeable addition on its own. Correctness is covered end to end instead: the decode gate shows KLD 0, 100% same top-1 and identical generated text (same md5) against the master cache path on both Qwen3.6 and Gemma 4, and LLAMA_MOE_CACHE_SEED_CHECK verifies the cached expert bytes against the host weights. A CPU reference and a test-backend-ops case are listed as a follow-up.