-
Notifications
You must be signed in to change notification settings - Fork 175
feat(x86,cpu) add support for Qwen3 MoE model on x86 #619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5c5c0b0
ad3cb3c
18774e2
8adc4cb
3b5c088
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| add_executable(mllm-qwen3-moe-runner main.cpp) | ||
| target_link_libraries(mllm-qwen3-moe-runner PRIVATE MllmRT MllmCPUBackend) | ||
| target_include_directories(mllm-qwen3-moe-runner PRIVATE ${MLLM_INCLUDE_DIR}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "architectures": [ | ||
| "Qwen3MoeForCausalLM" | ||
| ], | ||
| "attention_bias": false, | ||
| "bos_token_id": 151643, | ||
| "decoder_sparse_step": 1, | ||
| "eos_token_id": 151645, | ||
| "head_dim": 128, | ||
| "hidden_act": "silu", | ||
| "hidden_size": 2048, | ||
| "initializer_range": 0.02, | ||
| "intermediate_size": 6144, | ||
| "max_position_embeddings": 262144, | ||
| "max_window_layers": 48, | ||
| "mlp_only_layers": [], | ||
| "model_type": "qwen3_moe", | ||
| "moe_intermediate_size": 768, | ||
| "norm_topk_prob": true, | ||
| "num_attention_heads": 32, | ||
| "num_experts": 128, | ||
| "num_experts_per_tok": 8, | ||
| "num_hidden_layers": 48, | ||
| "num_key_value_heads": 4, | ||
| "output_router_logits": false, | ||
| "rms_norm_eps": 1e-06, | ||
| "rope_scaling": 1.0, | ||
| "rope_theta": 10000000, | ||
| "router_aux_loss_coef": 0.001, | ||
| "tie_word_embeddings": true, | ||
| "transformers_version": "4.51.0", | ||
| "use_cache": true, | ||
| "use_sliding_window": false, | ||
| "vocab_size": 151936, | ||
| "max_cache_length": 16384, | ||
| "linear_impl_type": "Default" | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <iostream> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <fmt/core.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/mllm.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/models/qwen3_moe/modeling_qwen3_moe_fa2.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/models/qwen3_moe/tokenization_qwen3_moe.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <mllm/utils/AnyValue.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using mllm::Argparse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MLLM_MAIN({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto& help = Argparse::add<bool>("-h|--help").help("Show help message"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto& model_path = Argparse::add<std::string>("-m|--model_path").help("Model path").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto& model_version = Argparse::add<std::string>("-mv|--model_version").help("Model version").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto& tokenizer_path = Argparse::add<std::string>("-t|--tokenizer_path").help("Tokenizer directory").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto& config_path = Argparse::add<std::string>("-c|--config_path").help("Config path").required(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Argparse::parse(argc, argv); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef MLLM_PERFETTO_ENABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::perf::start(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::ModelFileVersion file_version = mllm::ModelFileVersion::kV1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (model_version.get() == "v1") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_version = mllm::ModelFileVersion::kV1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (model_version.get() == "v2") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file_version = mllm::ModelFileVersion::kV2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("❌ Unsupported model_version: {} (expected v1 or v2)\n", model_version.get()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::shutdownContext(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (help.isSet()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Argparse::printHelp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::shutdownContext(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate Argparse.hpp
find . -name "Argparse.hpp" -type fRepository: UbiquitousLearning/mllm Length of output: 92 🏁 Script executed: # Once located, check the implementation of required arguments and get() method
rg -n "required" mllm/utils/Argparse.hpp -A 3 -B 1Repository: UbiquitousLearning/mllm Length of output: 605 🏁 Script executed: # Also check the get() method implementation
rg -n "\.get\(\)" mllm/utils/Argparse.hpp -A 2 -B 1Repository: UbiquitousLearning/mllm Length of output: 484 🏁 Script executed: # Look at the full context of main.cpp around the lines in question
head -50 examples/qwen3_moe/main.cpp | tail -40Repository: UbiquitousLearning/mllm Length of output: 1651 🏁 Script executed: # Get the full parse() method implementation
rg -n "void parse" mllm/utils/Argparse.hpp -A 30Repository: UbiquitousLearning/mllm Length of output: 3232 🏁 Script executed: # Also check if help flag has any special behavior
rg -n "help.*isSet\|--help" mllm/utils/Argparse.hpp -B 2 -A 2Repository: UbiquitousLearning/mllm Length of output: 49 🏁 Script executed: # Get more of the parse method to see required arg validation
rg -n "static void parse" mllm/utils/Argparse.hpp -A 50 | head -80Repository: UbiquitousLearning/mllm Length of output: 1821 🏁 Script executed: # Check if there's special handling for help before validation
rg -n "MLLM_ERROR_EXIT.*required" mllm/utils/Argparse.hpp -B 5 -A 2Repository: UbiquitousLearning/mllm Length of output: 344 🏁 Script executed: # Get the complete parse method to see if there's early exit handling for help
rg -n "static void parse" mllm/utils/Argparse.hpp -A 70Repository: UbiquitousLearning/mllm Length of output: 2631
Proposed fix Argparse::parse(argc, argv);
+ if (help.isSet()) {
+ Argparse::printHelp();
+ mllm::shutdownContext();
+ return 0;
+ }
+
mllm::ModelFileVersion file_version = mllm::ModelFileVersion::kV1;
if (model_version.get() == "v1") {
file_version = mllm::ModelFileVersion::kV1;
} else if (model_version.get() == "v2") {
file_version = mllm::ModelFileVersion::kV2;
} else {
fmt::print("❌ Unsupported model_version: {} (expected v1 or v2)\n", model_version.get());
mllm::shutdownContext();
return 1;
}
- if (help.isSet()) {
- Argparse::printHelp();
- mllm::shutdownContext();
- return 0;
- }🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto qwen3_moe_cfg = mllm::models::qwen3_moe::Qwen3MoeConfig(config_path.get()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto qwen3_moe_tokenizer = mllm::models::qwen3_moe::Qwen3Tokenizer(tokenizer_path.get()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto qwen3_moe = mllm::models::qwen3_moe::Qwen3MoeForCausalLM(qwen3_moe_cfg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto param = mllm::load(model_path.get(), file_version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qwen3_moe.load(param); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("\n{:*^60}\n", " Qwen3 MoE Interactive CLI "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("Enter 'exit' or 'quit' to end the session\n\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string prompt_text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("💬 Prompt text (or 'exit/quit'): "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::getline(std::cin, prompt_text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(prompt_text == "exit" || prompt_text == "quit") { return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UI says "interactive" but implementation is single-prompt only. Lines 48-49 suggest an interactive session ("Enter 'exit' or 'quit' to end the session"), but there is no loop — only one prompt is accepted. Either wrap lines 53-68 in a 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("🔄 Processing...\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto inputs = qwen3_moe_tokenizer.convertMessage({.prompt = prompt_text}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("\n🤖 Response: "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Use for loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (auto& step : qwen3_moe.chat(inputs)) { std::wcout << qwen3_moe_tokenizer.detokenize(step.cur_token_id) << std::flush; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fmt::print("\n{}\n", std::string(60, '-')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (const std::exception& e) { fmt::print("\n❌ Error: {}\n{}\n", e.what(), std::string(60, '-')); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+69
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honor the advertised 🛠️ Proposed fix fmt::print("💬 Prompt text (or 'exit/quit'): ");
std::getline(std::cin, prompt_text);
- try {
- fmt::print("🔄 Processing...\n");
- auto inputs = qwen3_moe_tokenizer.convertMessage({.prompt = prompt_text});
-
- fmt::print("\n🤖 Response: ");
-
- // Use for loop
- for (auto& step : qwen3_moe.chat(inputs)) { std::wcout << qwen3_moe_tokenizer.detokenize(step.cur_token_id) << std::flush; }
-
- fmt::print("\n{}\n", std::string(60, '-'));
- } catch (const std::exception& e) { fmt::print("\n❌ Error: {}\n{}\n", e.what(), std::string(60, '-')); }
+ if (prompt_text == "exit" || prompt_text == "quit") {
+ fmt::print("👋 Bye!\n");
+ } else {
+ try {
+ fmt::print("🔄 Processing...\n");
+ auto inputs = qwen3_moe_tokenizer.convertMessage({.prompt = prompt_text});
+
+ fmt::print("\n🤖 Response: ");
+
+ // Use for loop
+ for (auto& step : qwen3_moe.chat(inputs)) { std::wcout << qwen3_moe_tokenizer.detokenize(step.cur_token_id) << std::flush; }
+
+ fmt::print("\n{}\n", std::string(60, '-'));
+ } catch (const std::exception& e) { fmt::print("\n❌ Error: {}\n{}\n", e.what(), std::string(60, '-')); }
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qwen3_moe.perfSummary(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef MLLM_PERFETTO_ENABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::perf::stop(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::perf::saveReport("qwen3_moe.perf"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::print("\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mllm::memoryReport(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||||
| { | ||||||
| "^model\\.layers\\.\\d+\\.self_attn\\.q_proj.(bias|weight)": { | ||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q4_K", | ||||||
| "shape": [ | ||||||
| 4096, | ||||||
| 2048 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| }, | ||||||
| "^model\\.layers\\.\\d+\\.self_attn\\.k_proj.(bias|weight)": { | ||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q4_K", | ||||||
| "shape": [ | ||||||
| 512, | ||||||
| 2048 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| }, | ||||||
| "^model\\.layers\\.\\d+\\.self_attn\\.v_proj.(bias|weight)": { | ||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q6_K", | ||||||
| "shape": [ | ||||||
| 512, | ||||||
| 2048 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| }, | ||||||
| "^model\\.layers\\.\\d+\\.self_attn\\.o_proj.(bias|weight)": { | ||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q4_K", | ||||||
| "shape": [ | ||||||
| 2048, | ||||||
| 4096 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| }, | ||||||
| "^model\\.layers\\.\\d+\\.mlp\\.experts\\.\\d+\\.up_proj.(bias|weight)": { | ||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q4_K", | ||||||
| "shape": [ | ||||||
| 768, | ||||||
| 2048 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| }, | ||||||
| "^model\\.layers\\.\\d+\\.mlp\\.experts\\.\\d+\\.down_proj.(bias|weight)": { | ||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q6_K", | ||||||
| "shape": [ | ||||||
| 2048, | ||||||
| 768 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| }, | ||||||
|
Comment on lines
+46
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check if gate_proj exists in quantization configs and model definitions
rg -n "gate_proj" --type=jsonRepository: UbiquitousLearning/mllm Length of output: 1218 🏁 Script executed: # Also search in Python files for model definitions
rg -n "gate_proj" --type=pyRepository: UbiquitousLearning/mllm Length of output: 1146 🏁 Script executed: # List all quantization config files for comparison
fd -e json -p "quant_cfg"Repository: UbiquitousLearning/mllm Length of output: 477 🏁 Script executed: # Search for qwen3_moe model definitions
fd -p "qwen3_moe" --type=py | head -20Repository: UbiquitousLearning/mllm Length of output: 236 🏁 Script executed: # Check the qwen3_moe model file for MoE expert structure and gate_proj
fd -p "modeling_qwen3" --type=py | grep -i moeRepository: UbiquitousLearning/mllm Length of output: 236 🏁 Script executed: # Search for Qwen3MoeMLP or similar MoE expert definitions
rg -n "Qwen3.*Moe|MoeMLP" --type=py -A 10Repository: UbiquitousLearning/mllm Length of output: 49 🏁 Script executed: # Search for Qwen3MoeMLP or MoE expert definitions
rg -n "Qwen3.*Moe|MoeMLP" --type-add "py:*.py"Repository: UbiquitousLearning/mllm Length of output: 3702 🏁 Script executed: # Search for qwen3_moe references in Python files
rg -n "qwen3_moe"Repository: UbiquitousLearning/mllm Length of output: 1964 🏁 Script executed: # Search for expert projection definitions with gate_proj
rg -n "experts.*gate_proj|gate_proj.*experts"Repository: UbiquitousLearning/mllm Length of output: 50379 🏁 Script executed: cat mllm/models/qwen3_moe/modeling_qwen3_moe_fa2.hpp | sed -n '71,112p'Repository: UbiquitousLearning/mllm Length of output: 1468 🏁 Script executed: # Check if gate_proj is mentioned anywhere in the qwen3_moe model file
rg -n "gate_proj" mllm/models/qwen3_moe/Repository: UbiquitousLearning/mllm Length of output: 436 🏁 Script executed: # Also check the current quant_cfg_30B_q4_k.json file directly for context
cat examples/qwen3_moe/quant_cfg_30B_q4_k.jsonRepository: UbiquitousLearning/mllm Length of output: 1612 Add The model defines three projections per MoE expert ( "^model\\.layers\\.\\d+\\.mlp\\.experts\\.\\d+\\.gate_proj.(bias|weight)": {
"hints": {
"quant_method": "gguf",
"gguf_type": "Q4_K",
"shape": [2048, 2048],
"replace": true
}
}🤖 Prompt for AI Agents |
||||||
| "^lm_head.weight": { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unescaped dot in All other patterns escape dots as Proposed fix- "^lm_head.weight": {
+ "^lm_head\\.weight": {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| "hints": { | ||||||
| "quant_method": "gguf", | ||||||
| "gguf_type": "Q4_K", | ||||||
| "shape": [ | ||||||
| 151936, | ||||||
| 2048 | ||||||
| ], | ||||||
| "replace": true | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rope_thetavalue here (10000000) differs from the default inconfiguration_qwen3_moe.hpp(1000000.0).The JSON provides
10000000(10⁷) while the C++ default atconfiguration_qwen3_moe.hpp:60is1000000.0(10⁶). When loading from JSON this is fine, but anyone using the default constructor gets the wrong value. Please align the C++ default with the model's actualrope_theta.🤖 Prompt for AI Agents