-
Notifications
You must be signed in to change notification settings - Fork 767
Add parakeet to examples/models #16349
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
Open
JacobSzwejbka
wants to merge
10
commits into
main
Choose a base branch
from
parakeet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,179
−0
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8361c9a
parakeet
JacobSzwejbka ec96225
close to getting cpp working only the first few tokens are wrong
JacobSzwejbka 47ae3e0
clean up and fixes
JacobSzwejbka a2a4687
block backend arg
JacobSzwejbka 7d39ed7
Merge branch 'main' into parakeet
JacobSzwejbka af801b1
lint and readme
JacobSzwejbka fa22b18
cuda graph preprocessor issue
JacobSzwejbka 1829505
fix torch cuda bug
JacobSzwejbka 54a6319
ptd support
JacobSzwejbka 09cb1be
ptd serialization
JacobSzwejbka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| cmake_minimum_required(VERSION 3.24) | ||
| project(parakeet_runner) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..) | ||
|
|
||
| include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) | ||
|
|
||
| if(CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") | ||
| set(CMAKE_TOOLCHAIN_IOS ON) | ||
| else() | ||
| set(CMAKE_TOOLCHAIN_IOS OFF) | ||
| endif() | ||
|
|
||
| # Let files say "include <executorch/path/to/header.h>" | ||
| set(_common_include_directories ${EXECUTORCH_ROOT}/..) | ||
|
|
||
| # Need this for gflags | ||
| set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags) | ||
| find_package(gflags REQUIRED) | ||
|
|
||
| # Find executorch libraries | ||
| list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..) | ||
| find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH) | ||
| executorch_target_link_options_shared_lib(executorch) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need this |
||
|
|
||
| set(link_libraries executorch gflags) | ||
|
|
||
| # Common ops for all builds | ||
| list(APPEND link_libraries optimized_native_cpu_ops_lib cpublas eigen_blas) | ||
| executorch_target_link_options_shared_lib(optimized_native_cpu_ops_lib) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not needed |
||
|
|
||
| # CPU-only builds need quantized and custom ops | ||
| if(NOT EXECUTORCH_BUILD_CUDA AND MSVC) | ||
| list(APPEND link_libraries quantized_ops_lib custom_ops) | ||
| executorch_target_link_options_shared_lib(quantized_ops_lib) | ||
| executorch_target_link_options_shared_lib(custom_ops) | ||
| endif() | ||
|
|
||
| # XNNPACK | ||
| if(TARGET xnnpack_backend) | ||
| set(xnnpack_backend_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod) | ||
| if(TARGET kleidiai) | ||
| list(APPEND xnnpack_backend_libs kleidiai) | ||
| endif() | ||
| list(APPEND link_libraries ${xnnpack_backend_libs}) | ||
| executorch_target_link_options_shared_lib(xnnpack_backend) | ||
| endif() | ||
|
|
||
| # Needed for cpuinfo where it uses android specific log lib | ||
| if(ANDROID) | ||
| list(APPEND link_libraries log) | ||
| endif() | ||
|
|
||
| # Add the required ExecuTorch extensions | ||
| list( | ||
| APPEND | ||
| link_libraries | ||
| extension_llm_runner | ||
| extension_module | ||
| extension_data_loader | ||
| extension_tensor | ||
| extension_flat_tensor | ||
| tokenizers::tokenizers | ||
| ) | ||
|
|
||
| # Link CUDA backend | ||
| if(EXECUTORCH_BUILD_CUDA) | ||
| find_package(CUDAToolkit REQUIRED) | ||
| list(APPEND link_libraries aoti_cuda_backend) | ||
| if(NOT MSVC) | ||
| executorch_target_link_options_shared_lib(aoti_cuda_backend) | ||
| endif() | ||
| endif() | ||
|
|
||
| if(EXECUTORCH_BUILD_METAL) | ||
| list(APPEND link_libraries metal_backend) | ||
| executorch_target_link_options_shared_lib(metal_backend) | ||
| endif() | ||
|
|
||
| add_executable(parakeet_runner main.cpp) | ||
| if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_link_options_gc_sections(parakeet_runner) | ||
| if(NOT APPLE AND NOT MSVC) | ||
| target_link_options(parakeet_runner PRIVATE "LINKER:-s") | ||
| endif() | ||
| endif() | ||
|
|
||
| target_include_directories( | ||
| parakeet_runner PUBLIC ${_common_include_directories} | ||
| ) | ||
| target_link_libraries(parakeet_runner PUBLIC ${link_libraries}) | ||
| target_compile_options(parakeet_runner PUBLIC ${_common_compile_options}) | ||
|
|
||
| # On Windows, copy required DLLs to the executable directory | ||
| if(MSVC AND EXECUTORCH_BUILD_CUDA) | ||
| add_custom_command( | ||
| TARGET parakeet_runner | ||
| POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:aoti_cuda_shims> | ||
| $<TARGET_FILE_DIR:parakeet_runner> | ||
| COMMENT "Copying aoti_cuda_shims.dll to parakeet_runner directory" | ||
| ) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| { | ||
| "version": 6, | ||
| "configurePresets": [ | ||
| { | ||
| "name": "parakeet-base", | ||
| "hidden": true, | ||
| "binaryDir": "${sourceDir}/../../../cmake-out/examples/models/parakeet", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "Release", | ||
| "CMAKE_FIND_ROOT_PATH": "${sourceDir}/../../../cmake-out", | ||
| "CMAKE_PREFIX_PATH": "${sourceDir}/../../../cmake-out" | ||
| } | ||
| }, | ||
| { | ||
| "name": "parakeet-cpu", | ||
| "displayName": "Parakeet runner (CPU)", | ||
| "inherits": ["parakeet-base"] | ||
| }, | ||
| { | ||
| "name": "parakeet-cuda", | ||
| "displayName": "Parakeet runner (CUDA)", | ||
| "inherits": ["parakeet-base"], | ||
| "cacheVariables": { | ||
| "EXECUTORCH_BUILD_CUDA": "ON" | ||
| }, | ||
| "condition": { | ||
| "type": "inList", | ||
| "string": "${hostSystemName}", | ||
| "list": ["Linux", "Windows"] | ||
| } | ||
| }, | ||
| { | ||
| "name": "parakeet-metal", | ||
| "displayName": "Parakeet runner (Metal)", | ||
| "inherits": ["parakeet-base"], | ||
| "cacheVariables": { | ||
| "EXECUTORCH_BUILD_METAL": "ON" | ||
| }, | ||
| "condition": { | ||
| "lhs": "${hostSystemName}", | ||
| "type": "equals", | ||
| "rhs": "Darwin" | ||
| } | ||
| } | ||
| ], | ||
| "buildPresets": [ | ||
| { | ||
| "name": "parakeet-cpu", | ||
| "displayName": "Build Parakeet runner (CPU)", | ||
| "configurePreset": "parakeet-cpu", | ||
| "targets": ["parakeet_runner"] | ||
| }, | ||
| { | ||
| "name": "parakeet-cuda", | ||
| "displayName": "Build Parakeet runner (CUDA)", | ||
| "configurePreset": "parakeet-cuda", | ||
| "targets": ["parakeet_runner"] | ||
| }, | ||
| { | ||
| "name": "parakeet-metal", | ||
| "displayName": "Build Parakeet runner (Metal)", | ||
| "configurePreset": "parakeet-metal", | ||
| "targets": ["parakeet_runner"] | ||
| } | ||
| ], | ||
| "workflowPresets": [ | ||
| { | ||
| "name": "parakeet-cpu", | ||
| "displayName": "Configure and build Parakeet runner (CPU)", | ||
| "steps": [ | ||
| { | ||
| "type": "configure", | ||
| "name": "parakeet-cpu" | ||
| }, | ||
| { | ||
| "type": "build", | ||
| "name": "parakeet-cpu" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "parakeet-cuda", | ||
| "displayName": "Configure and build Parakeet runner (CUDA)", | ||
| "steps": [ | ||
| { | ||
| "type": "configure", | ||
| "name": "parakeet-cuda" | ||
| }, | ||
| { | ||
| "type": "build", | ||
| "name": "parakeet-cuda" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "parakeet-metal", | ||
| "displayName": "Configure and build Parakeet runner (Metal)", | ||
| "steps": [ | ||
| { | ||
| "type": "configure", | ||
| "name": "parakeet-metal" | ||
| }, | ||
| { | ||
| "type": "build", | ||
| "name": "parakeet-metal" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Parakeet TDT Export for ExecuTorch | ||
|
|
||
| Export [nvidia/parakeet-tdt-0.6b-v3](https://huggingface.co/nvidia/parakeet-tdt-0.6b-v3) speech recognition model to ExecuTorch. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install nemo_toolkit[asr] torchaudio | ||
| ``` | ||
|
|
||
| ## Export | ||
|
|
||
| Export the model: | ||
| ```bash | ||
| python export_parakeet_tdt.py | ||
| ``` | ||
|
|
||
| Test transcription on an audio file and compare eager vs lowered results: | ||
| ```bash | ||
| python export_parakeet_tdt.py --audio /path/to/audio.wav | ||
| ``` | ||
|
|
||
| ### Export Arguments | ||
|
|
||
| | Argument | Description | | ||
| |----------|-------------| | ||
| | `--output-dir` | Output directory for exports (default: `./parakeet_tdt_exports`) | | ||
| | `--backend` | Backend for acceleration: `portable`, `xnnpack`, `cuda`, `cuda-windows` (default: `portable`) | | ||
| | `--audio` | Path to audio file for transcription test | | ||
|
|
||
| **Note:** The preprocessor is always lowered with the portable backend regardless of the `--backend` setting. | ||
|
|
||
| ## C++ Runner | ||
|
|
||
| ### Building | ||
|
|
||
| First, build ExecuTorch with the LLM preset from the executorch root directory: | ||
|
|
||
| ```bash | ||
| cmake --workflow --preset llm-release | ||
| ``` | ||
|
|
||
| Then build the parakeet runner: | ||
|
|
||
| ```bash | ||
| cd examples/models/parakeet | ||
| cmake --workflow --preset parakeet-cpu | ||
| ``` | ||
|
|
||
| Available presets: | ||
| - `parakeet-cpu` - CPU-only build | ||
| - `parakeet-cuda` - CUDA acceleration (Linux/Windows) | ||
| - `parakeet-metal` - Metal acceleration (macOS) | ||
|
|
||
| ### Running | ||
|
|
||
| From the executorch root directory: | ||
|
|
||
| ```bash | ||
| ./cmake-out/examples/models/parakeet/parakeet_runner \ | ||
| --model_path examples/models/parakeet/parakeet_tdt_exports/parakeet_tdt.pte \ | ||
| --audio_path /path/to/audio.wav \ | ||
| --tokenizer_path examples/models/parakeet/tokenizer.model | ||
| ``` | ||
|
|
||
| ### Runner Arguments | ||
|
|
||
| | Argument | Description | | ||
| |----------|-------------| | ||
| | `--model_path` | Path to Parakeet model (.pte) | | ||
| | `--audio_path` | Path to input audio file (.wav) | | ||
| | `--tokenizer_path` | Path to tokenizer file (default: `tokenizer.json`) | | ||
| | `--data_path` | Path to data file (.ptd) for delegate data (optional, required for CUDA) | |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?