Skip to content

Fix OLMoE support and silent model-init failures - #119

Open
danielesalpietro wants to merge 4 commits into
EfficientMoE:mainfrom
danielesalpietro:fix/olmoe-support-and-silent-init-errors
Open

Fix OLMoE support and silent model-init failures#119
danielesalpietro wants to merge 4 commits into
EfficientMoE:mainfrom
danielesalpietro:fix/olmoe-support-and-silent-init-errors

Conversation

@danielesalpietro

@danielesalpietro danielesalpietro commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

  1. moe_infinity/utils/hf_config.py: parse_moe_param()/parse_expert_id() were missing an "olmoe" branch, even though olmoe is registered in moe_infinity/common/constants.py's MODEL_MAPPING_NAMES/ MODEL_MAPPING_TYPES and has a working monkey-patch class (SyncOlmoeMoEBlock in moe_infinity/models/olmoe.py). Loading any OLMoE checkpoint raised RuntimeError("Unsupported architecture ...forcausallm"). OLMoE's config fields (num_experts, num_experts_per_tok) and expert parameter naming (layers.N.mlp.experts.M....) match the already-handled qwen3 branch, so "olmoe" was added there in both functions. The same registry/parser gap still exists for dbrx, jamba, and opt.

  2. moe_infinity/entrypoints/openai/api_server_v2.py: _initialize_model() had no except clause, and runs as a fire-and-forget asyncio.create_task that nothing ever awaits or inspects (startup_event()). Any exception raised while constructing the model (unsupported architecture, CUDA allocation failure, etc.) was silently dropped: the process kept running, /health stayed on "starting" forever, and every request got a 503 indistinguishable from a genuine hang -- this is what made the OLMoE bug above so hard to diagnose in the first place. The exception is now logged (logger.exception) and surfaced through /health as {"status": "unhealthy", "reason": ""}.

Verified: allenai/OLMoE-1B-7B-0924-Instruct now loads and serves correctly via /v1/chat/completions with these fixes.

Motivation

Loading any OLMoE checkpoint raised RuntimeError("Unsupported architecture ...forcausallm")

Type of Change

  • [ X ] Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read the CONTRIBUTION guide.
  • I have updated the tests (if applicable).
  • I have updated the documentation (if applicable).

- moe_infinity/utils/hf_config.py: parse_moe_param()/parse_expert_id()
  were missing an "olmoe" branch, even though olmoe is registered in
  moe_infinity/common/constants.py's MODEL_MAPPING_NAMES/
  MODEL_MAPPING_TYPES and has a working monkey-patch class
  (SyncOlmoeMoEBlock in moe_infinity/models/olmoe.py). Loading any
  OLMoE checkpoint raised RuntimeError("Unsupported architecture
  ...forcausallm"). OLMoE's config fields (num_experts,
  num_experts_per_tok) and expert parameter naming
  (layers.N.mlp.experts.M....) match the already-handled qwen3 branch,
  so "olmoe" was added there in both functions. The same
  registry/parser gap still exists for dbrx, jamba, and opt.

- moe_infinity/entrypoints/openai/api_server_v2.py: _initialize_model()
  had no except clause, and runs as a fire-and-forget
  asyncio.create_task that nothing ever awaits or inspects
  (startup_event()). Any exception raised while constructing the model
  (unsupported architecture, CUDA allocation failure, etc.) was
  silently dropped: the process kept running, /health stayed on
  "starting" forever, and every request got a 503 indistinguishable
  from a genuine hang -- this is what made the OLMoE bug above so hard
  to diagnose in the first place. The exception is now logged
  (logger.exception) and surfaced through /health as
  {"status": "unhealthy", "reason": "<exception>"}.

Verified: allenai/OLMoE-1B-7B-0924-Instruct now loads and serves
correctly via /v1/chat/completions with these fixes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
drunkcoding
drunkcoding previously approved these changes Jul 19, 2026
Same root cause as EfficientMoE#121: installing torch
pulls in setuptools>=77.0.3 as a transitive dependency, upgrading the
environment's setuptools past the exact pin. Under --no-isolation,
python -m build then fails its build-dependency check because the
installed version no longer matches ==75.3.2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…den dim mismatch

MODEL_MAPPING_TYPES["olmoe"] was set to 4 (MIXTRAL_MOE_DENSE_ACT_DENSE),
which makes MoEMLP::ForwardHelper read expert weight buffers in Mixtral's
gate/down/up order (matching w1/w2/w3). But OlmoeMLP registers weights as
gate_proj/up_proj/down_proj (same convention as qwen3, already mapped to
5/DEEPSEEK_MOE_DENSE_ACT_DENSE). This swapped up_proj and down_proj for
every OLMoE expert, crashing fused_moe_ffn_into's H == H_out check
whenever hidden_size != intermediate_size (e.g. allenai/OLMoE-1B-7B-0924-Instruct:
hidden_size=2048, intermediate_size=1024).

Fixes EfficientMoE#123

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@danielesalpietro danielesalpietro left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strongly suggests "olmoe": 4 was simply a copy/paste slip and should be 5.

@danielesalpietro danielesalpietro left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strongly suggests "olmoe": 4 was simply a copy/paste slip and should be 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants