-
Notifications
You must be signed in to change notification settings - Fork 187
Added Qwen3.5 0.8B #657
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
Draft
FarmersWrap
wants to merge
3
commits into
UbiquitousLearning:main
Choose a base branch
from
FarmersWrap:feat/qwen3.5-qnn
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Added Qwen3.5 0.8B #657
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| add_executable(mllm-qwen3-5-runner main.cpp) | ||
| target_link_libraries(mllm-qwen3-5-runner PRIVATE MllmRT MllmCPUBackend) | ||
| target_include_directories(mllm-qwen3-5-runner PRIVATE ${MLLM_INCLUDE_DIR}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #include <iostream> | ||
| #include <fmt/core.h> | ||
| #include <mllm/mllm.hpp> | ||
| #include <mllm/models/qwen3_5/modeling_qwen3_5.hpp> | ||
| #include <mllm/models/qwen3_5/tokenization_qwen3_5.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; | ||
| } | ||
|
|
||
| if (help.isSet()) { | ||
| Argparse::printHelp(); | ||
| mllm::shutdownContext(); | ||
| return 0; | ||
| } | ||
|
|
||
| { | ||
| auto cfg = mllm::models::qwen3_5::Qwen3_5Config(config_path.get()); | ||
| auto tokenizer = mllm::models::qwen3_5::Qwen3_5Tokenizer(tokenizer_path.get()); | ||
| auto model = mllm::models::qwen3_5::Qwen3_5ForCausalLM(cfg); | ||
|
|
||
| fmt::print("Qwen3.5 0.8B: {} layers ({} full attention + {} GDN)\n", | ||
| cfg.num_hidden_layers, cfg.numFullAttentionLayers(), cfg.numGDNLayers()); | ||
|
|
||
| auto param = mllm::load(model_path.get(), file_version); | ||
| model.load(param); | ||
|
|
||
| fmt::print("\n{:*^60}\n", " Qwen3.5 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); | ||
|
|
||
| try { | ||
| fmt::print("Processing...\n"); | ||
| auto inputs = tokenizer.convertMessage({.prompt = prompt_text}); | ||
|
|
||
| fmt::print("\nResponse: "); | ||
|
|
||
| for (auto& step : model.chat(inputs)) { std::wcout << tokenizer.detokenize(step.cur_token_id) << std::flush; } | ||
|
|
||
| fmt::print("\n{}\n", std::string(60, '-')); | ||
| } catch (const std::exception& e) { fmt::print("\nError: {}\n{}\n", e.what(), std::string(60, '-')); } | ||
|
|
||
| model.perfSummary(); | ||
| } | ||
|
|
||
| #ifdef MLLM_PERFETTO_ENABLE | ||
| mllm::perf::stop(); | ||
| mllm::perf::saveReport("qwen3_5.perf"); | ||
| #endif | ||
|
|
||
| mllm::print("\n"); | ||
| mllm::memoryReport(); | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # AOT compile target runs on x86 (cross-compilation for Qualcomm HTP) | ||
| if(MLLM_QUALCOMM_QNN_AOT_ON_X86_ENABLE) | ||
| add_executable(mllm-qwen3_5-aot-c compile.cpp) | ||
| target_link_libraries(mllm-qwen3_5-aot-c PRIVATE MllmRT MllmCPUBackend MllmQNNBackend) | ||
| target_include_directories(mllm-qwen3_5-aot-c PRIVATE ${MLLM_INCLUDE_DIR}) | ||
| endif() | ||
|
|
||
| # Hybrid CPU+QNN runtime (runs on device: CPU for GDN, QNN for full attention) | ||
| add_executable(mllm-qwen3_5-aot-runner aot_run.cpp) | ||
| target_link_libraries(mllm-qwen3_5-aot-runner PRIVATE MllmRT MllmCPUBackend MllmQNNBackend) | ||
| target_include_directories(mllm-qwen3_5-aot-runner PRIVATE ${MLLM_INCLUDE_DIR}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Help flag check may fail due to required argument validation.
The help flag is checked after
Argparse::parse(argc, argv)(line 17), but arguments are marked asrequired(true). If the user runs with just-h, the parser may fail before reaching the help check.🛠️ Proposed fix
Consider checking for help before validating required arguments, or ensuring
Argparse::parsedoesn't error on missing required args when-his present. A common pattern is:🤖 Prompt for AI Agents