Skip to content
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

Support vpm and resampler module of minicpm-v on NPU #12375

Merged
merged 10 commits into from
Nov 12, 2024

Conversation

plusbang
Copy link
Contributor

@plusbang plusbang commented Nov 11, 2024

Description

Update minicpm-v usage on NPU.

2. User API changes

  • No need to specify torch_dtype=torch.float32 and modules_to_not_convert=['vpm', 'resampler']
  • lm_head of minicpm_v_2_6 could run on NPU by default

3. Summary of the change

  • replace conv2d and layernorm with MinicpmVPatchEmbedding and MinicpmVLayerNorm
  • pad mlp.fc2 and replace forward function to avoid compile error
  • pad lm_head and replace forward function to avoid compile error
  • port attention / multi-head-attention / resampler forward functions
  • update example script

4. How to test?

@plusbang plusbang requested review from rnwang04 and sgwhat November 11, 2024 05:41
Copy link
Contributor

@rnwang04 rnwang04 left a comment

Choose a reason for hiding this comment

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

others LGTM

@plusbang plusbang merged commit 7a97fbb into intel-analytics:main Nov 12, 2024
1 check passed
Comment on lines +235 to +236
padded_weight = F.pad(module.lm_head.weight,
(0, 0, 0, 152064-151666)) # 152064 is qwen2-7b vocab_size
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this impact accuracy for channel-wise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will this impact accuracy for channel-wise?

The original weight shape is [151666, 3584] and pad it to [152064, 3584], each row has no change. I think this don't influence CW : )

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