Skip to content

feat: support video nsa#463

Merged
wooway777 merged 1 commit into
mainfrom
feat/support-video-nsa
Jul 1, 2026
Merged

feat: support video nsa#463
wooway777 merged 1 commit into
mainfrom
feat/support-video-nsa

Conversation

@wooway777

@wooway777 wooway777 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

CUDA_VISIBLE_DEVICES=4,5 python examples/test_infer.py --model=/data-aisoft/mechdancer/models/Enxin_VideoNSA/ --image=/data-aisoft/pepe/images/im_sh_landing.jpg --prompt="describe the image" --enable-paged-attn --attn=flash-attn
image
image
目前看起来开了nsa会有精度损失,进而在常规输出后会有重复。这个后续再看能不能修吧,目前感觉不是一口气能无痛做好的。

bench_videonsa.py主要是给指标用的,不太需要在意细节。
image

MiniCPM V 2.6
image

9g8b
image

@wooway777 wooway777 requested a review from a team June 29, 2026 09:53
@wooway777

Copy link
Copy Markdown
Collaborator Author

/test

Comment thread python/infinilm/infer_engine.py Outdated
Comment thread examples/test_infer.py Outdated
Comment thread csrc/global_state/forward_context.hpp
auto batched_grids = grid_tensors.size() == 1 ? grid_tensors.front() : infinicore::op::cat(grid_tensors, 0);
auto batched_vision_hidden = visual_->forward(batched_pixels, batched_grids);

std::vector<size_t> visual_token_ranges;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

再确认下visual_token_ranges变量是不是得在python/infinilm/processors/videonsa_processor.py中计算好,传递过来得,而不是在c++中to_cpu现算

@pengcheng888 pengcheng888 Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

如果是的话,得修改bind的Input结构体,最后的位置新增一个变量。

def normalize_hf_config_for_infinilm(config_dict, model_path):
model_type = config_dict.get("model_type")

if model_type == "qwen2_5_vl" and config_dict.get("architectures") == [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这是啥意思,为什么要吧"model_type"从qwen2_5_vl修改为videonsa。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

改成了“有nsa模块才改”

normalized["text_config"] = text_config
return normalized

return config_dict

@pengcheng888 pengcheng888 Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个模型适配了的话,是不是之后qwen2_5_vl模型的适配,能复用csrc/models/videonsa/文件夹中的绝大部分文件

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

是,到时候可以考虑再整合

@pengcheng888 pengcheng888 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

修改后的代码,(1)给出测试命令和测试截图;(2)已经有多模态模型也能跑

@wooway777 wooway777 force-pushed the feat/support-video-nsa branch from 443e44c to 92d2ee4 Compare June 30, 2026 03:13
@Vincent777

Copy link
Copy Markdown
Collaborator

/retest

@github-actions

Copy link
Copy Markdown

⛔ Only repository members can run retest.

@wooway777 wooway777 force-pushed the feat/support-video-nsa branch 2 times, most recently from 4121275 to 24c8323 Compare June 30, 2026 11:14
@wooway777

Copy link
Copy Markdown
Collaborator Author

/test

@github-actions

Copy link
Copy Markdown

✅ Started CI workflow run 28448940484 for commit 24c8323 on branch feat/support-video-nsa (triggered by /test).

Comment thread csrc/engine/rank_worker.hpp Outdated
Comment thread csrc/pybind11/engine/engine.hpp Outdated
@wooway777 wooway777 force-pushed the feat/support-video-nsa branch from 24c8323 to 04ba524 Compare July 1, 2026 03:08
@wooway777 wooway777 requested a review from pengcheng888 July 1, 2026 06:32
@wooway777

Copy link
Copy Markdown
Collaborator Author

/retest

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

✅ Started CI workflow run 28498414541 for commit 04ba524 on branch feat/support-video-nsa (triggered by /retest).

@wooway777 wooway777 force-pushed the feat/support-video-nsa branch from 04ba524 to 6a5ea37 Compare July 1, 2026 07:16
return cpu->to(device);
}

std::pair<infinicore::Tensor, infinicore::Tensor> build_mrope_cache(size_t max_seq_len,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

这一部分先临时这么搞,泽众会做一个通用的rope模块,等他那边确定了再替换这部分,从而避免在推理逻辑中创建sin cos表

Comment thread python/infinilm/llm/llm.py Outdated
@wooway777 wooway777 force-pushed the feat/support-video-nsa branch from 6a5ea37 to d9f14e6 Compare July 1, 2026 07:42
@wooway777 wooway777 merged commit 310c7fc into main Jul 1, 2026
@wooway777 wooway777 deleted the feat/support-video-nsa branch July 1, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants