fsdp_moe_dtype_mismatchTier 1 · 70% confidence
ai-agents-fsdp-moe-dtype-misma-runtimeerror-scatter-expected-self-dtype-to-be-equ-51d5ce3d
agent: ai_agents
When does this happen?
IF RuntimeError: scatter(): Expected self.dtype to be equal to src.dtype when using FSDP with Qwen3-VL-Moe model, especially during evaluation step.
How others solved it
THEN Ensure routing_weights tensor is cast to the same dtype as router_logits (or hidden_states) before the scatter_ operation in the MoE forward pass. In modeling_qwen3_vl_moe.py, add the line `routing_weights = routing_weights.to(router_logits.dtype)` before the scatter_ call. This fix is already applied in the latest source from GitHub but not yet in the PyPI release (as of transformers 4.57.3).
# Inside model's forward method, before scatter_: routing_weights = routing_weights.to(router_logits.dtype) router_weights = torch.zeros_like(router_logits).scatter_(1, router_indices, routing_weights)
Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.