Skip to content
Open
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
36 changes: 36 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"permissions": {
"allow": [
"Bash(g++ -std=c++20 -fsyntax-only -DUSEAVX2=1 -D__WINDOWS__ -DDISABLE_ABI_CHECK=1 -DDEV_BUILD -I include test/qwen3_5_omni_npu/test.cpp)",
"Read(//scratch/alfxu/FastFlowLM_IRON/FLM_DLL/**)",
"Read(//scratch/alfxu/FastFlowLM_IRON/**)",
"Bash(nm -DC /scratch/alfxu/FastFlowLM/src/lib/libqwen3_5_omni_npu.so)",
"Bash(cd /scratch/alfxu/FastFlowLM_IRON/FLM_DLL; echo \"=== qwen3_5_omni_npu.cpp \\(public wrapper\\) ===\"; wc -l detail/qwen3_5_omni/qwen3_5_omni_npu.cpp; echo; grep -n \"prefill\\\\|payload\\\\|image_soft\\\\|soft_token\\\\|forward\\\\|say\\\\|image_payload\\\\|audio_payload\\\\|num_soft\\\\|image_token\\\\|248\\\\|preprocess\" detail/qwen3_5_omni/qwen3_5_omni_npu.cpp | head -60)",
"Read(//scratch/alfxu/FastFlowLM_IRON/FLM_DLL/detail/qwen3_5_omni/**)",
"Bash(cd /scratch/alfxu/FastFlowLM_IRON/FLM_DLL; echo \"=== thinker hpp ===\"; sed -n '1,80p' detail/qwen3_5_omni/qwen3_5_omni_thinker/qwen3_5_omni_thinker.hpp 2>/dev/null; echo \"=== grep patch constants in omni thinker/image embed ===\"; grep -rn \"PATCH_SIZE\\\\|MERGE_SIZE\\\\|SHORTEST_EDGE\\\\|LONGEST_EDGE\\\\|TEMPORAL\\\\|RESCALE\\\\|IMAGE_MEAN\\\\|IMAGE_STD\\\\|soft_token\\\\|image_soft\\\\|248\" detail/qwen3_5_omni/ include/models/qwen3_5_omni/ 2>/dev/null | grep -iv \"//\" | head -40)",
"Bash(cd /scratch/alfxu/FastFlowLM_IRON/FLM_DLL; echo \"=== image embed hpp ===\"; cat detail/qwen3_5_omni/qwen3_5_omni_thinker/qwen3_5_omni_image_embed/qwen3_5_omni_image_embed.hpp 2>/dev/null | head -80; echo \"=== vision_config in LM_Config / omni ===\"; grep -rn \"vision_config\\\\|_vision_config\\\\|PATCH_SIZE\\\\|patch_size\\\\|merge_size\\\\|temporal\\\\|shortest\\\\|longest\\\\|image_mean\\\\|image_std\\\\|rescale\" detail/qwen3_5_omni/ 2>/dev/null | head -40)",
"Bash(cd /scratch/alfxu/FastFlowLM; echo \"=== LM_Config public members ===\"; grep -n \"_json_config\\\\|_vision_config\\\\|from_pretrained\\\\|vocab_size\\\\|struct\\\\|class LM_Config\\\\|public\\\\|nlohmann\" src/include/lm_config.hpp | head -40; echo \"=== omni model config.json vision/image processor ===\"; find /scratch/alfxu -maxdepth 4 -name \"config.json\" -path \"*mni*\" 2>/dev/null | head; find /scratch/alfxu -maxdepth 4 -iname \"*omni*\" -type d 2>/dev/null | head)",
"Read(//scratch/alfxu/**)",
"Bash(python3 -c ' *)",
"Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\(json.dumps\\({k:d[k] for k in d if k in ['image_mean','image_std','rescale_factor','patch_size','temporal_patch_size','merge_size','min_pixels','max_pixels','size','shortest_edge','longest_edge']},indent=1\\)\\)\")",
"Read(//scratch/alfxu/FastFlowLM_IRON/FLM_DLL/detail/qwen3_5_omni/qwen3_5_omni_talker/**)",
"Bash(cat /scratch/alfxu/models/Qwen3.5-omni-NPU2/config.json 2>/dev/null | grep -iE \"audio|vision|image|token_id\" | head -50)",
"Read(//scratch/alfxu/models/Qwen3.5-omni-NPU2/**)",
"Bash(grep -rniE \"write_wav|write.wav|\\\\.wav|save.*wav|pcm\" /scratch/alfxu/FastFlowLM/src /scratch/alfxu/FastFlowLM_IRON 2>/dev/null | grep -viE \"\\\\.o:|Binary\" | head -40)",
"Bash(grep -n \"audio_end_token_id\\\\|audio_start_token_id\\\\|audio_token_id\\\\|codec_bos\\\\|codec_eos\\\\|tts\" /scratch/alfxu/models/Qwen3.5-omni-NPU2/config.json)",
"Bash(grep -nE \"\\\\\"thinker_config\\\\\"|\\\\\"talker_config\\\\\"|\\\\\"text_config\\\\\"|\\\\\"vision_config\\\\\"|\\\\\"audio_config\\\\\"|audio_end_token_id|audio_start_token_id|audio_token_id\" /scratch/alfxu/models/Qwen3.5-omni-NPU2/config.json | head -40)",
"Bash(cd /scratch/alfxu/FastFlowLM/src; echo \"=== audio_reader.hpp API ===\"; grep -n \"load_audio\\\\|audio_data_t\\\\|MonoDownmix\\\\|sample_rate\\\\|num_frames\\\\|num_samples\\\\|struct\\\\|class AudioReader\" include/audio/audio_reader.hpp | head -30; echo \"=== omni engine resample rate / audio config ===\"; grep -rn \"resample\\\\|sample_rate\\\\|16000\\\\|Audio_resample\" /scratch/alfxu/FastFlowLM_IRON/FLM_DLL/detail/qwen3_5_omni/qwen3_5_omni_thinker/qwen3_5_omni_audio_embed/*.cpp 2>/dev/null | head)",
"Read(//scratch/alfxu/FastFlowLM_IRON/FLM_DLL/detail/qwen3_5_omni/qwen3_5_omni_thinker/qwen3_5_omni_audio_embed/**)",
"Bash(cd /scratch/alfxu/FastFlowLM_IRON/FLM_DLL/detail/qwen3_5_omni/qwen3_5_omni_thinker/qwen3_5_omni_audio_embed; ls; echo \"=== audio embed hpp ===\"; cat *.hpp 2>/dev/null | head -60)",
"Bash(grep -rn \"say\\\\|talker\\\\|codec\\\\|thinker_res\" /scratch/alfxu/FastFlowLM/src/include/models/qwen3_5_omni/qwen3_5_omni.hpp; echo \"===say impl===\"; grep -rn \"::say\\\\|buffer<bf16> say\\\\|say\\(\" /scratch/alfxu/FastFlowLM/src /scratch/alfxu/FastFlowLM_IRON 2>/dev/null | grep -v \"\\\\.o:\" | head)",
"Bash(make clean *)",
"Bash(cd /scratch/alfxu/FastFlowLM/src; grep -rn \"model.q4nx\\\\|\\\\.q4nx\\\\|safetensors\" common/tensor_utils/*.cpp 2>/dev/null | head; echo \"=== how other models' model dirs look \\(do they have model.q4nx?\\) ===\"; ls /scratch/alfxu/models/Qwen3.5-4B-NPU2/ 2>/dev/null | head)",
"Read(//scratch/alfxu/models/Qwen3.5-4B-NPU2/**)",
"Bash(g++ -std=c++20 -fsyntax-only -I include -I . common/qwen3_5_omni/modeling_qwen3_5_omni.cpp)",
"Bash(g++ -std=c++20 -fsyntax-only -I include -I . test/qwen3_5_omni_npu/test.cpp)",
"Bash(g++ -std=c++20 -fsyntax-only -I include -I . common/AutoModel/automodel.cpp)",
"Bash(g++ -std=c++20 -fsyntax-only -D__FLM_VERSION__='\"test\"' -I include -I . test/qwen3_5_omni_npu/test.cpp)",
"Bash(g++ -std=c++20 -fsyntax-only -I include -I . common/AutoModel/modeling_qwen3_5_omni.cpp)"
]
}
}
8 changes: 4 additions & 4 deletions src/common/AutoModel/automodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void AutoModel::set_sampler(sampler_config& sampler_config) {
if (this->sampler != nullptr) {
this->sampler.reset();
}
this->sampler = std::make_unique<Sampler>(this->lm_config->vocab_size, sampler_config);
this->sampler = std::make_unique<Sampler>(this->lm_config->get("vocab_size"), sampler_config);
}

/// \brief Set the max length
Expand Down Expand Up @@ -575,9 +575,9 @@ void AutoModel::set_topk(int topk) {
header_print("WARNING", "Top-k must be greater than 0");
return;
}
if (topk > this->lm_config->vocab_size) {
header_print("WARNING", "Top-k is greater than vocab size, set to vocab size: " << this->lm_config->vocab_size);
topk = this->lm_config->vocab_size;
if (topk > this->lm_config->get("vocab_size")) {
header_print("WARNING", "Top-k is greater than vocab size, set to vocab size: " << this->lm_config->get("vocab_size"));
topk = this->lm_config->get("vocab_size");
}

this->sampler->top_k = topk;
Expand Down
2 changes: 1 addition & 1 deletion src/common/AutoModel/modeling_qwen2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void Qwen2::load_model(std::string model_path, json model_info, int default_cont

this->q4nx = std::make_unique<Q4NX>(this->model_path);

// lm_config->model_type == qwen2
// lm_config->get<std::string>("model_type", "") == qwen2
this->lm_engine = std::make_unique<qwen2_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down
2 changes: 1 addition & 1 deletion src/common/AutoModel/modeling_qwen2vl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void Qwen2VL::load_model(std::string model_path, json model_info, int default_co
this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption);

this->q4nx = std::make_unique<Q4NX>(this->model_path);
// lm_config->model_type == qwen2
// lm_config->get<std::string>("model_type", "") == qwen2
this->lm_engine = std::make_unique<qwen2vl_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down
6 changes: 3 additions & 3 deletions src/common/AutoModel/modeling_qwen3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void Qwen3::load_model(std::string model_path, json model_info, int default_cont
this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption);

this->q4nx = std::make_unique<Q4NX>(this->model_path);
// lm_config->model_type == qwen3
// lm_config->get<std::string>("model_type", "") == qwen3
this->lm_engine = std::make_unique<qwen3_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down Expand Up @@ -314,7 +314,7 @@ void Qwen3_IT::load_model(std::string model_path, json model_info, int default_c

this->q4nx = std::make_unique<Q4NX>(this->model_path);

// lm_config->model_type == qwen3
// lm_config->get<std::string>("model_type", "") == qwen3
this->lm_engine = std::make_unique<qwen3_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down Expand Up @@ -465,7 +465,7 @@ void Qwen3_TK::load_model(std::string model_path, json model_info, int default_c

this->q4nx = std::make_unique<Q4NX>(this->model_path);

// lm_config->model_type == qwen3
// lm_config->get<std::string>("model_type", "") == qwen3
this->lm_engine = std::make_unique<qwen3_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down
12 changes: 6 additions & 6 deletions src/common/AutoModel/modeling_qwen3_5_omni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ void Qwen3_5_Omni::load_model(std::string model_path, json model_info, int defau
this->lm_config->from_pretrained(this->model_path);

// The omni thinker vocab lives in thinker_config.text_config, so the
// top-level "vocab_size" is 0. Resolve it here so every downstream reader
// (set_sampler, set_topk, ...) sees the real vocab instead of 0.
// top-level "vocab_size" is 0. Republish it at the top level so every
// downstream reader (set_sampler, set_topk, ...) sees the real vocab.
{
const auto& jc = this->lm_config->_json_config;
auto& jc = this->lm_config->_json_config;
if (jc.contains("thinker_config") && jc["thinker_config"].contains("text_config")) {
this->lm_config->vocab_size =
json_u32(jc["thinker_config"]["text_config"], "vocab_size", this->lm_config->vocab_size);
jc["vocab_size"] =
json_u32(jc["thinker_config"]["text_config"], "vocab_size", this->lm_config->get("vocab_size"));
}
}

Expand Down Expand Up @@ -694,7 +694,7 @@ buffer<bf16> Qwen3_5_Omni::say(std::string wav_out_path) {

void Qwen3_5_Omni::set_sampler(sampler_config& sampler_config) {
if (this->sampler != nullptr) this->sampler.reset();
this->sampler = std::make_unique<Sampler>((int)this->lm_config->vocab_size, sampler_config);
this->sampler = std::make_unique<Sampler>((int)this->lm_config->get("vocab_size"), sampler_config);
}

void Qwen3_5_Omni::clear_context() {
Expand Down
2 changes: 1 addition & 1 deletion src/common/AutoModel/modeling_qwen3_5vl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void Qwen3_5VL::load_model(std::string model_path, json model_info, int default_
this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption);

this->q4nx = std::make_unique<Q4NX>(this->model_path);
// lm_config->model_type == qwen3
// lm_config->get<std::string>("model_type", "") == qwen3
this->lm_engine = std::make_unique<qwen3_5vl_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down
2 changes: 1 addition & 1 deletion src/common/AutoModel/modeling_qwen3_6_moe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void Qwen3_6_MOE::load_model(std::string model_path, json model_info, int defaul
this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption);

this->q4nx = std::make_unique<Q4NX>(this->model_path);
// lm_config->model_type == qwen3
// lm_config->get<std::string>("model_type", "") == qwen3
this->lm_engine = std::make_unique<qwen3_6_moe_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down
2 changes: 1 addition & 1 deletion src/common/AutoModel/modeling_qwen3vl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void Qwen3VL::load_model(std::string model_path, json model_info, int default_co
this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption);

this->q4nx = std::make_unique<Q4NX>(this->model_path);
// lm_config->model_type == qwen3
// lm_config->get<std::string>("model_type", "") == qwen3
this->lm_engine = std::make_unique<qwen3vl_npu>(*this->lm_config, this->npu.get(), this->MAX_L);

this->lm_engine->load_weights(*this->q4nx);
Expand Down
2 changes: 1 addition & 1 deletion src/common/whisper/modeling_whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void Whisper::load_model(std::string model_path, nlohmann::ordered_json model_in
s_config.min_p = 0.1;
s_config.temperature = 0.4;

this->sampler = std::make_unique<Sampler>(this->lm_config->vocab_size, s_config);
this->sampler = std::make_unique<Sampler>(this->lm_config->get("vocab_size"), s_config);
}

void Whisper::setup_tokenizer(std::string model_path) {
Expand Down
Loading