llama : meta split state for combined gate+up ffn_up (phi3)#24936
llama : meta split state for combined gate+up ffn_up (phi3)#24936krystophny wants to merge 2 commits into
Conversation
Architectures that pack gate and up into a single ffn_up tensor of width 2*n_ff (phi3) were split naively across devices, so the ffn_down source split state did not match and the meta backend aborted on GGML_ASSERT(split_states_equal(...)). Split such tensors into two n_ff groups, mirroring the fused ffn_gate_up handling. Fixes the test-llama-archs abort on phi3 with the meta (TP) backend.
The synchronize-on-teardown fix (src/llama-context.cpp) and the phi3 meta split-state fix (src/llama-model.cpp) entered this branch via an upstream merge and are unrelated to the Responses API work. They are now filed independently as ggml-org#24935 and ggml-org#24936. Remove them here so this PR is limited to the server Responses changes.
|
Hi @krystophny, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
JohannesGaessler
left a comment
There was a problem hiding this comment.
It's not clear to me why we have different values in n_ff_exp and n_ff_arr. But only one of those values should ever be defined. So I would suggest to fetch hparams.n_ff(il) first. If and only if that value is 0, fetch n_ff_exp and assert that that value is not 0. Assert that the tensor dimension size is exactly equal to twice the nonzero value. Return 2 segments with the nonzero value.
Keep the 2*n_ff dimension check as a guard so ordinary separate ffn_up/ffn_gate tensors fall through to the default even split. The combined gate|up ffn_up is dense-only (phi3, modern-bert), so n_ff(il) is the correct width; fetch it once.
|
Done in a0caeb1 —
test-llama-archs stays green. |
Overview
phi3 packs the FFN gate and up projections into one
ffn_uptensor ofwidth
2*n_ff. Inllama_meta_device_get_split_state(
get_split_segments) this tensor reaches the default branch, whichdivides the concatenated
gate|upevenly across devices. Each devicethen holds a slice that does not line up with its
ffn_downinput, andthe meta backend aborts on
GGML_ASSERT(split_states_equal(src_ss[0], src_ss[1])).Splitting the tensor into two
n_ffgroups gives every device amatching gate and up half, the layout the fused
ffn_gate_uppathalready produces. The guard
ne[axis] == 2*n_ff(il)leaves models withseparate gate and up tensors (each
n_ff) on the default branch.Additional information
Reproduced on clean
master(dec5ca557).Before:
After:
This sits in the tensor-parallel / meta-backend line (#22489, #22616,
#23525, #24180).
Requirements
earlier work; AI assisted with reproducing the phi3 abort, building,
and running test-llama-archs. I reviewed every line, own the change,
and can explain it.