You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e73e0a5
Browse filesBrowse the repository at this point in the historyBrowse files
fix: L2 test failures - memory budget, XLM/XLNet activation (#224)
This pull request introduces several improvements and fixes for model
configuration extraction, focusing on more robust handling of activation
functions, RoPE (Rotary Position Embedding) detection, and
Mixture-of-Experts (MoE) parameters. It also improves support for models
with non-standard or missing config fields and adds targeted tests for
new fallback logic.
**Configuration Extraction Improvements:**
* Added a comprehensive `_resolve_hidden_act` function to robustly
extract the activation function from HuggingFace configs, supporting a
wide range of field names and fallback patterns (e.g., `ff_activation`,
`gelu_activation`, Qwen/CTRL defaults) (`src/mobius/_configs.py`,
[[1]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aR31-R61)
[[2]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aL967-R1042).
* Improved RoPE detection logic to recognize implicit RoPE usage in
models that don't expose `rope_scaling` or `rope_parameters`, using
model-type-specific defaults and non-default `rope_theta` as signals
(`src/mobius/_configs.py`,
[[1]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aR317-R334)
[[2]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aL316-R380)
[[3]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aR978-R986).
* Enhanced MoE parameter extraction with additional field fallbacks and
logic for shared expert size calculation, supporting more model variants
(ERNIE, GLM, Hunyuan) (`src/mobius/_configs.py`,
[[1]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aL1132-R1211)
[[2]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aR1542-R1559).
**Vision and Numeric Field Handling:**
* Improved handling of vision model configs where hidden sizes or image
sizes may be lists or dicts, ensuring correct scalar extraction for
multi-stage models (e.g., Florence2, PVT-v2) (`src/mobius/_configs.py`,
[[1]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aL424-R491)
[[2]](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aL1450-R1529).
**Testing and Validation:**
* Added targeted tests for activation function extraction fallbacks to
ensure correct behavior for various config patterns (e.g., XLNet, XLM)
(`src/mobius/_configs_test.py`,
[src/mobius/_configs_test.pyR977-R1036](diffhunk://#diff-731306b65028c2c328cb51b5b913709558032a78c6b87949e4d09240894c35c1R977-R1036)).
* Updated the architecture validation test suite with more explicit skip
reasons for models with missing or non-standard vision configs, and
improved config resolution for Qwen3-Omni
(`tests/arch_validation_test.py`,
[[1]](diffhunk://#diff-605a9a76abfdb6fe5972842956c1abbd489a12ece1c1b2d7d14ca64d29fe36cbL50-R55)
[[2]](diffhunk://#diff-605a9a76abfdb6fe5972842956c1abbd489a12ece1c1b2d7d14ca64d29fe36cbL104-R100).
**Other Fixes:**
* Mapped `"xielu"` activation to `silu` in the activation registry to
prevent crashes in base MLP construction for Apertus models
(`src/mobius/components/_activations.py`,
[src/mobius/components/_activations.pyR86-R91](diffhunk://#diff-e063741e948256ed0e92721271b783756e05a8d7ec6ead98745e7725aa16c4c5R86-R91)).
* For MLA models (MiniCPM3, DeepSeek-V2), ensured rotary embedding
applies to the correct head dimension
(`src/mobius/components/_rotary_embedding.py`,
[src/mobius/components/_rotary_embedding.pyL18-R21](diffhunk://#diff-c82f6b31190bef4f731dd6d05639a59fe4bcead50ef185208b6b8cb55febd62eL18-R21)).
* Set the correct config class for `LongcatFlashCausalLMModel`
(`src/mobius/models/longcat_flash.py`,
[[1]](diffhunk://#diff-ec4e78dd6ffd3e8372c228067e7f6307a410a5fed3ac963369d1d5f818df0028L21-R21)
[[2]](diffhunk://#diff-ec4e78dd6ffd3e8372c228067e7f6307a410a5fed3ac963369d1d5f818df0028R438).
* Ensured `Sam2Config` defaults to `"gelu"` activation if not explicitly
set (`src/mobius/_configs.py`,
[src/mobius/_configs.pyR1933-R1936](diffhunk://#diff-8d2bbd9d3e7313b834f95b7d3260a3a15173d37d9ee5dd344f863d666f172f7aR1933-R1936)).
These changes collectively improve the robustness and coverage of model
config parsing, especially for edge cases and recent model
architectures.
---------
Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot <[email protected]>
0 commit comments