Skip to content

[DeepSeek] Simplify token grouping before expert processing - #995

Merged
kwen2501 merged 1 commit into
mainfrom
reland_952
Mar 20, 2025
Merged

kwen2501 merged 1 commit into
mainfrom
reland_952

Conversation

@kwen2501

Copy link
Copy Markdown
Contributor

Reland of #952 since ghstack land <PR> does not work.

Previously the model code re-arranges the received tokens so that those for the same expert reside in a contiguous space. It leads to complex code and the need of argsort.

This PR uses the y[expert_idx == i] = expert(tokens[expert_idx == i]) style to perform expert processing.
It provides a simpler alternative (at least in coding style) as if the tokens are processed in place.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 20, 2025
@kwen2501
kwen2501 merged commit 8045789 into main Mar 20, 2025
MaxiBoether pushed a commit to eth-easl/torchtitan-mixtera that referenced this pull request Apr 17, 2025
)

Reland of pytorch#952 since `ghstack land <PR>` does not work.

Previously the model code re-arranges the received tokens so that those
for the same expert reside in a contiguous space. It leads to complex
code and the need of argsort.

This PR uses the y[expert_idx == i] = expert(tokens[expert_idx == i])
style to perform expert processing.
It provides a simpler alternative (at least in coding style) as if the
tokens are processed in place.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
)

Reland of pytorch#952 since `ghstack land <PR>` does not work.

Previously the model code re-arranges the received tokens so that those
for the same expert reside in a contiguous space. It leads to complex
code and the need of argsort.

This PR uses the y[expert_idx == i] = expert(tokens[expert_idx == i])
style to perform expert processing.
It provides a simpler alternative (at least in coding style) as if the
tokens are processed in place.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
)

Reland of pytorch#952 since `ghstack land <PR>` does not work.

Previously the model code re-arranges the received tokens so that those
for the same expert reside in a contiguous space. It leads to complex
code and the need of argsort.

This PR uses the y[expert_idx == i] = expert(tokens[expert_idx == i])
style to perform expert processing.
It provides a simpler alternative (at least in coding style) as if the
tokens are processed in place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants