Skip to content

Export models for Ascend 910B4 - #2878

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:ascend-910b4
Dec 9, 2025
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
csukuangfj:ascend-910b4

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Dec 9, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Updated build and deployment infrastructure scripts to dynamically retrieve version configurations instead of using hardcoded values.
    • Updated GitHub workflow triggers to use a new branch for automated build processes.
    • Enhanced environment configuration for improved compatibility with additional library paths.

✏️ Tip: You can customize this high-level summary in your review settings.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 9, 2025
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @csukuangfj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the model export process by integrating support for the new Ascend 910B4 chip. It achieves this by refactoring how supported CANN and SOC versions are managed, centralizing these configurations into reusable functions. This update ensures that all relevant scripts consistently use the same version definitions, streamlining future maintenance and hardware compatibility updates.

Highlights

  • Ascend 910B4 Support: The model export scripts now explicitly include support for the Ascend 910B4 chip, expanding the range of supported hardware.
  • Centralized Version Management: The lists of supported CANN and SOC versions have been centralized into dedicated functions within generate_zipformer_ctc_20250703.py. This eliminates hardcoded lists in other scripts, improving maintainability and consistency.
  • Code Refactoring: The changes refactor the version retrieval logic, making the codebase cleaner and easier to update when new CANN or SOC versions are introduced.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/export-paraformer-to-ascend-npu.yaml
    • .github/workflows/export-sense-voice-to-ascend-npu.yaml
    • .github/workflows/export-zipformer-ctc-to-ascend-20250703.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@coderabbitai

coderabbitai Bot commented Dec 9, 2025 •

Copy link
Copy Markdown

Walkthrough

Refactors hardcoded CANN and SOC version lists into dynamic retrieval functions. Introduces get_cann_version() and get_soc_version() functions in the zipformer module, updates paraformer and sense_voice export scripts to use these functions, and updates workflow trigger branches from legacy branch names to ascend-910b4-2.

Changes

Cohort / File(s) Summary
Version Retrieval Functions
.github/scripts/export-ascend/generate_zipformer_ctc_20250703.py
Introduces get_soc_version() returning ["910B", "910B2", "910B3", "910B4", "310P3"] and get_cann_version() returning ["7.0", "8.0", "8.2"]; updates main() to call these functions instead of using hardcoded literals
Export Scripts Using Dynamic Versions
.github/scripts/export-ascend/generate_paraformer.py, .github/scripts/export-ascend/generate_sense_voice.py
Updates imports to include get_cann_version and get_soc_version from zipformer module; replaces hardcoded version lists with function calls in configuration building logic
Workflow Trigger and Configuration
.github/workflows/export-paraformer-to-ascend-npu.yaml, .github/workflows/export-sense-voice-to-ascend-npu.yaml, .github/workflows/export-zipformer-ctc-to-ascend-20250703.yaml
Changes workflow trigger branch from legacy names to ascend-910b4-2 across all three workflows; paraformer workflow additionally updates build matrix source from sense_voice to paraformer script and adds Cann 7.0.0 library path exports

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Imports and function calls: Verify that get_cann_version() and get_soc_version() are correctly imported and invoked in both paraformer and sense_voice scripts; confirm functions are exported from zipformer module
  • Workflow branch names: Ensure the new trigger branch ascend-910b4-2 is correct and active
  • LD_LIBRARY_PATH paths: Confirm the Cann 7.0.0 library paths added to the paraformer workflow are correctly formatted and necessary

Possibly related PRs

Poem

🐰 We hopped through hardcodes, found static pain,
Now dynamic versions dance like spring rain,
Functions spring forth, bright and free,
Export scripts sing in harmony! ✨🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main objective of the pull request to add support for exporting models for Ascend 910B4, which is reflected across all modified workflow files and version functions.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for Ascend 910B4 by updating the list of supported SoC versions. It also refactors the scripts to centralize the lists of supported CANN and SoC versions into functions, which improves maintainability by reducing code duplication. My review includes a suggestion to further improve this refactoring by using module-level constants instead of functions for these static lists, which is a more idiomatic approach in Python.

Comment on lines +35 to +42
def get_soc_version():
soc_version = ["910B", "910B2", "910B3", "910B4", "310P3"]
return soc_version


def get_cann_version():
cann_version = ["7.0", "8.0", "8.2"]
return cann_version

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For lists of values that are fixed and don't change at runtime, it's more idiomatic and clearer to define them as module-level constants rather than wrapping them in functions. This signals that these are static configuration values.

I suggest replacing these functions with constants. You would then need to update the call sites in this file, generate_paraformer.py, and generate_sense_voice.py to import and use these constants directly.

For example, in generate_paraformer.py:

from generate_zipformer_ctc_20250703 import get_image, SUPPORTED_CANN_VERSIONS, SUPPORTED_SOC_VERSIONS

def main():
    cann_version = SUPPORTED_CANN_VERSIONS
    soc_version = SUPPORTED_SOC_VERSIONS
    # ...
SUPPORTED_SOC_VERSIONS = ["910B", "910B2", "910B3", "910B4", "310P3"]
SUPPORTED_CANN_VERSIONS = ["7.0", "8.0", "8.2"]

@csukuangfj
csukuangfj merged commit d5b381c into k2-fsa:master Dec 9, 2025
1 check was pending
@csukuangfj
csukuangfj deleted the ascend-910b4 branch December 9, 2025 13:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
.github/scripts/export-ascend/generate_sense_voice.py (1)

8-31: Good reuse of shared CANN/SOC helpers; consider updating the comment for 910B4

Importing get_image, get_soc_version, and get_cann_version from generate_zipformer_ctc_20250703 keeps the SenseVoice matrix generation in sync with zipformer/paraformer and avoids hard‑coding the version lists in multiple places. The import style will work when this script is invoked as done in the workflow (python3 .github/scripts/export-ascend/generate_sense_voice.py).

Minor nit: now that get_soc_version() includes "910B4", the Config.soc_version comment still listing 910B, 910B2, 910B3, 310P3 is slightly stale. You may want to extend the comment to include 910B4 for accuracy.

.github/workflows/export-paraformer-to-ascend-npu.yaml (1)

98-199: Optional: job id/name still mentions RKNN

The job id export-paraformer-to-rknn no longer matches the job name (export-paraformer-to-ascend-npu) or what the steps actually do. This is purely cosmetic, but renaming the job id (and fixing the small nput typo in the concurrency group) in a follow‑up would make the workflow easier to read.

.github/scripts/export-ascend/generate_zipformer_ctc_20250703.py (1)

35-43: Centralized CANN/SOC version helpers are straightforward and reusable

Defining get_soc_version() and get_cann_version() here is a clean way to keep the supported versions in one place for all export scripts. The values match the keys used in get_image, and adding "910B4" while still routing it through the "910" image mapping is consistent with the existing "910B*" handling.

Minor nit: the Config.soc_version comment below still lists 910B, 910B2, 910B3, 310P3. Consider updating it to mention 910B4 so the docs stay in sync with get_soc_version().

.github/scripts/export-ascend/generate_paraformer.py (1)

8-37: Paraformer generator correctly reuses shared version/image helpers

Importing get_cann_version, get_image, and get_soc_version from generate_zipformer_ctc_20250703 and using them in main() ensures the paraformer matrix stays aligned with the zipformer one. The generated configs (with framework, soc_version, cann, image) match what the workflow expects, and the framework names (FunASR, WSChuan-ASR) are consistent with the if: matrix.framework == ... checks.

As with the other scripts, get_soc_version() now includes "910B4", so you may want to update the Config.soc_version comment that currently lists only 910B, 910B2, 910B3, 310P3 to include 910B4 for clarity.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fac37f and 986d75e.

📒 Files selected for processing (6)
  • .github/scripts/export-ascend/generate_paraformer.py (2 hunks)
  • .github/scripts/export-ascend/generate_sense_voice.py (2 hunks)
  • .github/scripts/export-ascend/generate_zipformer_ctc_20250703.py (2 hunks)
  • .github/workflows/export-paraformer-to-ascend-npu.yaml (5 hunks)
  • .github/workflows/export-sense-voice-to-ascend-npu.yaml (1 hunks)
  • .github/workflows/export-zipformer-ctc-to-ascend-20250703.yaml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
.github/scripts/export-ascend/generate_sense_voice.py (1)
.github/scripts/export-ascend/generate_zipformer_ctc_20250703.py (3)
  • get_image (15-32)
  • get_soc_version (35-37)
  • get_cann_version (40-42)
🔇 Additional comments (6)
.github/workflows/export-sense-voice-to-ascend-npu.yaml (1)

3-7: Trigger branch update looks good; just confirm the target branch name

The push trigger now listens on ascend-910b4-2, matching the other updated workflows in this PR. Please double‑check that ascend-910b4-2 is the long‑lived branch you intend to use for these Ascend exports before merging.

.github/workflows/export-zipformer-ctc-to-ascend-20250703.yaml (1)

3-7: Zipformer export workflow trigger aligned with new branch

Switching the push trigger to ascend-910b4-2 keeps this workflow consistent with the other Ascend export workflows. As with the others, just ensure this branch is the canonical one you’ll be using for 910B4 exports.

.github/workflows/export-paraformer-to-ascend-npu.yaml (3)

3-7: Paraformer workflow now tied to the new Ascend branch

The push trigger now targets ascend-910b4-2, keeping this workflow consistent with the other Ascend export jobs. Confirm that this is the branch you intend to use for ongoing paraformer exports.


25-31: Switch to generate_paraformer.py for the build matrix is consistent with the new helpers

Using .github/scripts/export-ascend/generate_paraformer.py for the matrix keeps paraformer’s CANN/SOC/framework combinations in sync with the shared helpers in generate_zipformer_ctc_20250703.py. That will reduce drift versus the zipformer/sense‑voice matrices and looks correct given the matrix keys referenced in this workflow.


68-80: Extra LD_LIBRARY_PATH entry for CANN 7.0.0 is reasonable

Adding the second LD_LIBRARY_PATH entry for devlib/x86_64 (with the # for cann 7.0.0 comment) mirrors the pattern in your other Ascend workflows and should help with 7.0.0 layout differences while remaining harmless for other CANN versions. No functional issues here.

.github/scripts/export-ascend/generate_zipformer_ctc_20250703.py (1)

61-69: main() now reuses the helpers; matrix generation stays compatible

Using cann_version = get_cann_version() and soc_version = get_soc_version() keeps this script aligned with the other generators that import these helpers. The resulting config objects still provide the cann, soc_version, num_seconds, and image fields expected by the GitHub Actions matrix, so behavior remains the same except for the new 910B4 coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant