Skip to content

[WIP]Add openpangu_dense model - #40637

Closed
yzy1996 wants to merge 8 commits into
huggingface:mainfrom
yzy1996:openpangu_dev
Closed

[WIP]Add openpangu_dense model#40637
yzy1996 wants to merge 8 commits into
huggingface:mainfrom
yzy1996:openpangu_dev

Conversation

@yzy1996

@yzy1996 yzy1996 commented Sep 3, 2025

Copy link
Copy Markdown

What does this PR do?

This PR introduces inference support for the openPangu-Embedded model. By integrating the inference implementation directly into the Transformers library, we aim to ensure seamless compatibility and enable continuous updates alongside future open-source releases.

This implementation requires torch_npu as a dependency. I'd like to confirm whether introducing this NPU-specific dependency aligns with the community's guidelines and acceptance criteria for the Transformers library. Any guidance on this matter would be greatly appreciated.

I welcome any feedback on potential improvements or additional changes that would enhance this implementation. Please feel free to share your suggestions!

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR. @ArthurZucker

@Rocketknight1

Copy link
Copy Markdown
Member

Hmm, it seems like this model has the same architecture as Llama, but just adds an NPU operation in attention. I'm not sure we need a whole architecture for that! cc @Cyrilvallez for attention, @ivarflakstad for NPU

@yzy1996

yzy1996 commented Sep 4, 2025

Copy link
Copy Markdown
Author

Thanks for the reply! Due to precision and performance gaps on NPU, we'll gradually add more NPU operators (beyond just attention ops). Although we have the same architecture as Llama, we'd like to add a separate model to keep it updated.

@Cyrilvallez

Cyrilvallez commented Sep 8, 2025

Copy link
Copy Markdown
Member

Hey @yzy1996! Indeed, as @Rocketknight1 mentioned, modeling code should be agnostic to the device used, so we don't really want special conditional branching based on accelerator type. You can however register custom attention function and masking to use with Llama if you follow what is shown here https://huggingface.co/docs/transformers/en/attention_interface, which will allow you to perform npu-specific optimizations!

@ArthurZucker

Copy link
Copy Markdown
Collaborator

Related to #39238 for NPU we'd love to just have proper kernels support!

@zheliuyu

zheliuyu commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

Related to #39238 for NPU we'd love to just have proper kernels support!

We are excited to announce NPU support for kernels!

Example of Usage:

@yzy1996 yzy1996 changed the title Add openPangu-Embedded model [WIP]Add openPangu-Embedded model Nov 3, 2025
@yzy1996 yzy1996 changed the title [WIP]Add openPangu-Embedded model [WIP]Add openPangu model Nov 3, 2025
@yzy1996
yzy1996 marked this pull request as draft November 3, 2025 16:05
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, openpangu_dense

@yzy1996 yzy1996 changed the title [WIP]Add openPangu model [WIP]Add openPangu_dense model Nov 16, 2025
@yzy1996 yzy1996 changed the title [WIP]Add openPangu_dense model [WIP]Add openpangu_dense model Nov 16, 2025
@yzy1996 yzy1996 closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants