Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
generation_config = GenerationConfig.from_pretrained(MODEL_ID)
config = Qwen3MoeConfig(
vocab_size=len(tokenizer.vocab),
vocab_size=151936,
hidden_size=8,
num_attention_heads=4,
num_key_value_heads=2,
num_hidden_layers=2,
intermediate_size=32,
num_experts=4,
num_experts_per_tok=2,
max_position_embeddings=40960,
rope_theta=1000000.0,
norm_topk_prob=True,
bos_token_id=151643,
eos_token_id=151645,
# Forwarded via kwargs (not Qwen3MoeConfig fields, but PretrainedConfig accepts arbitrary kwargs):
head_dim=128,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that will be useful for MFU utils. We can land this and I'll rebase 👍🏼 @qgallouedec

max_window_layers=48,
)
model = Qwen3MoeForCausalLM(config).to(dtype=torch.bfloat16)
init_weights_tiny_model(model)
Expand Down
12 changes: 11 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ def apply_model_revisions(monkeypatch):
if not MODEL_REVISIONS:
return

from transformers import PreTrainedModel, PreTrainedTokenizerBase, ProcessorMixin
from transformers import (
AutoConfig,
AutoModelForCausalLM,
AutoModelForSequenceClassification,
PreTrainedModel,
PreTrainedTokenizerBase,
ProcessorMixin,
)

def create_classmethod_wrapper(original_classmethod):
# Extract the underlying function from the classmethod
Expand All @@ -83,6 +90,9 @@ def wrapper(cls, pretrained_model_name_or_path, *args, **kwargs):

# Patch all transformers Auto* classes
for cls in [
AutoConfig,
AutoModelForCausalLM,
AutoModelForSequenceClassification,
PreTrainedModel,
PreTrainedTokenizerBase,
ProcessorMixin,
Expand Down
Loading