Fix DBRX MoE hidden size and expert GLU transposes - #47671
Conversation
`DbrxRouter`/`DbrxExperts` are built from `config.ffn_config`, where `hidden_size` is the model hidden size and `ffn_hidden_size` the expert intermediate size, but the two were mixed up: the router linear used `ffn_hidden_size` inputs, `DbrxExperts.forward` reshaped hidden states with `ffn_hidden_size`, and the three matmuls in `DbrxExpertGLU.forward` had their transposes inverted. Any DBRX checkpoint fails in the MoE block on any device. `DbrxModelTester` also swapped the two sizes in `ffn_config`, which made the wrong lookups resolve to the right value and hid the bug; fixed as well. Signed-off-by: kaixuanliu <kaixuan.liu@intel.com>
|
Here is an example to reproduce the bug: It will crash w/ log: This PR can solve this bug. |
vasqu
left a comment
There was a problem hiding this comment.
Approving on the assumption that we clarify my last comments
That is some wild mixup, checking slow ci in a second
There was a problem hiding this comment.
Do you know which PR introduced that mixup? That would be really nice to document
There was a problem hiding this comment.
It should be introduced by #40132, and I updated the PR description.
| gate_proj = x.matmul(expert_w1) | ||
| up_proj = x.matmul(expert_v1) | ||
| gate_proj = x.matmul(expert_w1.t()) | ||
| up_proj = x.matmul(expert_v1.t()) |
There was a problem hiding this comment.
Not on you but personally prefer .T
|
run-slow: dbrx |
|
This comment contains models: ["models/dbrx"] |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Hmm |
Signed-off-by: kaixuanliu <kaixuan.liu@intel.com>
Well this case also fails before this PR. In config.json |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: dbrx |
Signed-off-by: kaixuanliu <kaixuan.liu@intel.com>
CI recapDashboard: View test results in Grafana |
|
run-slow: dbrx |
|
This comment contains models: ["models/dbrx"] |
DbrxRouter/DbrxExpertsare built fromconfig.ffn_config, wherehidden_sizeis the model hidden size andffn_hidden_sizethe expert intermediate size, but the two were mixed up: the router linear usedffn_hidden_sizeinputs,DbrxExperts.forwardreshaped hidden states withffn_hidden_size, and the three matmuls inDbrxExpertGLU.forwardhad their transposes inverted. Any DBRX checkpoint fails in the MoE block on any device. This should be a regression introduced in #40132 (commit 7938e91) when the DBRX MoE modules were rewritten to read dims from configDbrxModelTesteralso swapped the two sizes inffn_config, which made the wrong lookups resolve to the right value and hid the bug; fixed as well.@ArthurZucker @Cyrilvallez @vasqu pls help review, thx!