Instructions to use Motif-Technologies/optimizer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use Motif-Technologies/optimizer with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("Motif-Technologies/optimizer", version=1) - Notebooks
- Google Colab
- Kaggle
Support multi-component expert_keys (e.g. "experts.w1")
Browse filesSingle-component keys match any single FQN component as before.
Multi-component keys (containing dots) now match as a contiguous
subsequence, so "experts.w1" matches "moe.experts.w1.weight" but
not "moe.shared_experts.w1.weight".
[skip-build]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Files changed (2)
123456776 unmodified lines848586"""Unit tests for FQN normalization (no GPU / distributed required)."""import pytestfrom optimizer.core import default_is_muon, normalize_fqnfrom optimizer.qk_clip import parse_qk_layer76 unmodified linesassert default_is_muon(name,self.FakeParam(2),expert_keys=["experts"])123456776 unmodified lines84858687888990919293949596979899"""Unit tests for FQN normalization (no GPU / distributed required)."""import pytestfrom optimizer.core import default_is_muon, is_expert_param, normalize_fqnfrom optimizer.qk_clip import parse_qk_layer76 unmodified linesassert default_is_muon(name,self.FakeParam(2),expert_keys=["experts"])def test_multi_component_key_matches(self):name = "model.layers.0.moe.experts.w1.weight"assert is_expert_param(name, expert_keys=["experts.w1"])def test_multi_component_key_no_false_positive(self):# "experts.w2" should not match "experts.w1"name = "model.layers.0.moe.experts.w1.weight"assert not is_expert_param(name, expert_keys=["experts.w2"])def test_multi_component_key_shared_experts(self):name = "model.layers.0.moe.shared_experts.w1.weight"assert not is_expert_param(name, expert_keys=["experts.w1"])
90 unmodified lines91929394959697989910010110290 unmodified linesreturn adjusted_lrdef is_expert_param(name, expert_keys):"""Check if a parameter name matches any expert key (component-level)."""if not expert_keys:return Falseparts = normalize_fqn(name).split(".")return any(key in parts for key in expert_keys)def default_is_muon(name, x, expert_keys=None):90 unmodified lines91929394959697989910010110210310410510610710810911011111211311411511690 unmodified linesreturn adjusted_lrdef _match_key(parts, key):"""Check if key matches as contiguous components in parts.Single-component keys (e.g. "experts") match any single component.Multi-component keys (e.g. "experts.w1") match as a contiguous subsequence."""key_parts = key.split(".")key_len = len(key_parts)if key_len == 1:return key in partsreturn any(parts[i:i + key_len] == key_partsfor i in range(len(parts) - key_len + 1))def is_expert_param(name, expert_keys):"""Check if a parameter name matches any expert key (component-level)."""if not expert_keys:return Falseparts = normalize_fqn(name).split(".")return any(_match_key(parts, key) for key in expert_keys)def default_is_muon(name, x, expert_keys=None):
test/test_normalize_fqn.py+14-1
torch-ext/optimizer/core.py+15-1