Conversation
Signed-off-by: weedge <weege007@gmail.com>
There was a problem hiding this comment.
Hello @weedge, 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!
Summary of Changes
This pull request focuses on integrating SparkTTS with TensorRT-LLM and deploying it using Triton server on Modal. It includes adding SparkTTS as a submodule, setting up the necessary environment and dependencies for TensorRT-LLM and Triton server within a Modal image, and creating functions to compile and serve the SparkTTS model using Triton server. The changes also involve replacing container_idle_timeout with scaledown_window in several Modal function definitions.
Highlights
- Submodule Integration: SparkTTS is added as a submodule to the repository.
- TensorRT-LLM and Triton Server Setup: A Modal image is configured with the necessary dependencies (CUDA, TensorRT-LLM, Triton server) to run SparkTTS.
- Model Compilation and Serving: Functions are implemented to compile the SparkTTS model using TensorRT-LLM and serve it via Triton server on Modal.
- Modal Configuration Updates: The
container_idle_timeoutparameter is replaced withscaledown_windowin multiple Modal function definitions for better resource management.
Changelog
Click here to see the changelog
- .gitmodules
- Added SparkTTS as a submodule.
- deploy/modal/src/bench/run_flash_mla.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/download_assets.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/download_models.py
- Added
hf-transferto the pip installs for faster downloads. - Set environment variable
HF_HUB_ENABLE_HF_TRANSFERto enablehf-transfer. - Renamed
MODEL_DIRtoHF_MODEL_DIRandmodel_dirtohf_model_vol. - Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator. - Updated the model download path to use
HF_MODEL_DIR. - Added example commands for running the download function.
- Added
- deploy/modal/src/fastapi_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_webrtc_audio_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_webrtc_freeze_omni_voice_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_webrtc_glm_voice_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_webrtc_minicpmo_vision_voice_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_webrtc_step_voice_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_webrtc_vision_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/fastapi_ws_moshi_voice_bot_serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.clsdecorator.
- Replaced
- deploy/modal/src/llm/trtllm/bench/tritonserver.py
- Created a new file to define a Modal app for serving models with Triton server.
- Configured a Modal image with Triton server and TensorRT-LLM dependencies.
- Implemented a
servefunction to start the Triton server with a specified model repository.
- deploy/modal/src/llm/trtllm/bench/tts_spark/client_grpc.py
- Created a new file to define a Modal app for compiling and serving SparkTTS models using TensorRT-LLM and Triton.
- Configured a Modal image with the necessary dependencies, including PyTorch, audio libraries, and Triton client.
- Implemented a
compile_modelfunction to clone the SparkTTS repository and build the model. - Implemented a
servefunction to start the Triton server.
- deploy/modal/src/llm/trtllm/bench/tts_spark/client_http.py
- Created a new file to define a Modal app for compiling and serving SparkTTS models using TensorRT-LLM and Triton.
- Configured a Modal image with the necessary dependencies, including PyTorch, audio libraries, and Triton client.
- Implemented a
compile_modelfunction to clone the SparkTTS repository and build the model. - Implemented a
servefunction to start the Triton server.
- deploy/modal/src/llm/trtllm/bench/tts_spark/ready_model.py
- Created a new file to define a Modal app for preparing the SparkTTS model for Triton server.
- Configured a Modal image with git.
- Implemented a
ready_modelfunction to clone the SparkTTS repository, copy the model repository, and fill the template with pbtext file for api params.
- deploy/modal/src/llm/trtllm/compile_model.py
- Created a new file to define a Modal app for compiling models using TensorRT-LLM.
- Configured a Modal image with CUDA, TensorRT-LLM, and other dependencies.
- Implemented a
trtllm_buildfunction to convert and compile the model.
- deploy/modal/src/llm/vllm/bench/client.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/bench/download_dataset.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/bench/serve.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/examples/offline_inference/audio_language.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/examples/offline_inference/disaggregated_prefill.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/inference_test.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/intra_node_inference_test.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/llm/vllm/profile_test.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/run_step_tts_inference.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/cp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/ddp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/device_mesh_sp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/device_mesh_tp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/dp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/ep.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/fsdp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/pp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/sp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/demo/tp.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deploy/modal/src/train/fsdp_tp_llama2.py
- Replaced
container_idle_timeoutwithscaledown_windowin the@app.functiondecorator.
- Replaced
- deps/SparkTTS
- Added a file to track the SparkTTS submodule commit.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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.
From text to speech, a digital art,
With TensorRT's speed, a brand new start.
Triton serves fast,
While models are cast,
On Modal's cloud, playing a vital part.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces the deployment of Spark TTS using TensorRT-LLM and Triton server on Modal. It includes changes to submodule configurations, benchmarking scripts, download scripts, and server configurations. The changes aim to optimize and scale the TTS service. Overall, the changes seem well-structured, but there are a few areas that could benefit from closer examination and potential refinement.
Summary of Findings
- Missing error handling in
servefunctions: Theservefunctions intritonserver.pyandclient_grpc.py/client_http.pylack proper error handling for subprocess calls. If any of the commands fail, the function should catch the exception and log an error message, otherwise the process will continue without the user knowing that the command failed. - Hardcoded paths: Several files contain hardcoded paths, such as
/Spark-TTS/runtime/triton_trtllminclient_grpc.pyandclient_http.py, and/Spark-TTS/runtime/triton_trtllm/scripts/convert_checkpoint.pyincompile_model.py. These paths should be configurable via environment variables to improve flexibility and maintainability. - Inconsistent use of
scaledown_window: The pull request replacescontainer_idle_timeoutwithscaledown_windowin several files. While this change is consistent across most files, it's important to ensure that this replacement is the correct configuration parameter for all use cases and that the values are appropriate.
Merge Readiness
The pull request introduces significant new functionality and touches several core components. While the changes appear to be well-structured, the identified issues regarding error handling and hardcoded paths should be addressed before merging. I am unable to approve this pull request, and recommend that the author address the comments before merging. It's also important to have other reviewers examine the changes to ensure they align with the project's overall architecture and goals.
…le qwen2 0.5 LLM engine Signed-off-by: weedge <weege007@gmail.com>
|
tritonserver --help |
Signed-off-by: weedge <weege007@gmail.com>
Signed-off-by: weedge <weege007@gmail.com>
Signed-off-by: weedge <weege007@gmail.com>
Signed-off-by: weedge <weege007@gmail.com>
Signed-off-by: weedge <weege007@gmail.com>
… min(num_tasks,26) task to bench used by http client Signed-off-by: weedge <weege007@gmail.com>
|
trtllm-build
|
|
https://github.com/NVIDIA/TensorRT-LLM/blob/v0.17.0/examples/qwen/convert_checkpoint.py |
modal run src/download_models.py --repo-ids "SparkAudio/Spark-TTS-0.5B"
# covert to dtype bfloat16
modal run src/llm/trtllm/tts_spark/compile_model.py \
--app-name "tts-spark" \
--hf-repo-dir "SparkAudio/Spark-TTS-0.5B/LLM" \
--trt-dtype "bfloat16" \
--convert-other-args "" \
--compile-other-args "--max_batch_size 16 --max_num_tokens 32768"
# use convert from convert-script-url,
modal run src/llm/trtllm/tts_spark/compile_model.py \
--app-name "tts-spark" \
--hf-repo-dir "SparkAudio/Spark-TTS-0.5B/LLM" \
--trt-dtype "bfloat16" \
--convert-script-url "https://raw.githubusercontent.com/SparkAudio/Spark-TTS/refs/heads/main/runtime/triton_trtllm/scripts/convert_checkpoint.py" \
--convert-other-args "" \
--compile-other-args "--max_batch_size 16 --max_num_tokens 32768"see trtllm-build build TensorRT Engine config(include convert to TensorRT-LLM Checkpoint config) {
"version": "0.17.0.post1",
"pretrained_config": {
"mlp_bias": false,
"attn_bias": true,
"rotary_base": 1000000,
"rotary_scaling": null,
"disable_weight_only_quant_plugin": false,
"num_labels": 1,
"use_logn_attn": false,
"moe": {
"num_experts": 0,
"shared_expert_intermediate_size": 0,
"top_k": 0,
"normalization_mode": 0,
"sparse_mixer_epsilon": 0.01,
"tp_mode": 0,
"device_limited_n_group": 0,
"device_limited_topk_group": 0,
"device_limited_routed_scaling_factor": 1
},
"architecture": "Qwen2ForCausalLM",
"dtype": "bfloat16",
"vocab_size": 166000,
"hidden_size": 896,
"num_hidden_layers": 24,
"num_attention_heads": 14,
"hidden_act": "silu",
"logits_dtype": "float32",
"norm_epsilon": 0.000001,
"runtime_defaults": null,
"position_embedding_type": "rope_gpt_neox",
"num_key_value_heads": 2,
"intermediate_size": 4864,
"max_position_embeddings": 32768,
"mapping": {
"world_size": 1,
"gpus_per_node": 8,
"cp_size": 1,
"tp_size": 1,
"pp_size": 1,
"moe_tp_size": 1,
"moe_ep_size": 1,
"auto_parallel": false
},
"quantization": {
"quant_algo": null,
"kv_cache_quant_algo": null,
"group_size": 128,
"smoothquant_val": 0.5,
"clamp_val": null,
"use_meta_recipe": false,
"has_zero_point": false,
"pre_quant_scale": false,
"exclude_modules": null
},
"use_parallel_embedding": false,
"embedding_sharding_dim": 0,
"head_size": 64,
"qk_layernorm": false,
"rotary_embedding_dim": 64,
"seq_length": 8192,
"qwen_type": "qwen2",
"moe_intermediate_size": 0,
"moe_shared_expert_intermediate_size": 0,
"tie_word_embeddings": true
},
"build_config": {
"max_input_len": 1024,
"max_seq_len": 32768,
"opt_batch_size": 8,
"max_batch_size": 16,
"max_beam_width": 1,
"max_num_tokens": 32768,
"opt_num_tokens": 16,
"max_prompt_embedding_table_size": 0,
"kv_cache_type": "PAGED",
"gather_context_logits": false,
"gather_generation_logits": false,
"strongly_typed": true,
"force_num_profiles": null,
"profiling_verbosity": "layer_names_only",
"enable_debug_output": false,
"max_draft_len": 0,
"speculative_decoding_mode": 1,
"use_refit": false,
"input_timing_cache": null,
"output_timing_cache": "model.cache",
"lora_config": {
"lora_dir": [],
"lora_ckpt_source": "hf",
"max_lora_rank": 64,
"lora_target_modules": [],
"trtllm_modules_to_hf_modules": {}
},
"auto_parallel_config": {
"world_size": 1,
"gpus_per_node": 8,
"cluster_key": "L4",
"cluster_info": null,
"sharding_cost_model": "alpha_beta",
"comm_cost_model": "alpha_beta",
"enable_pipeline_parallelism": false,
"enable_shard_unbalanced_shape": false,
"enable_shard_dynamic_shape": false,
"enable_reduce_scatter": true,
"builder_flags": null,
"debug_mode": false,
"infer_shape": true,
"validation_mode": false,
"same_buffer_io": {
"past_key_value_(\\d+)": "present_key_value_\\1"
},
"same_spec_io": {},
"sharded_io_allowlist": [
"past_key_value_\\d+",
"present_key_value_\\d*"
],
"fill_weights": false,
"parallel_config_cache": null,
"profile_cache": null,
"dump_path": null,
"debug_outputs": []
},
"weight_sparsity": false,
"weight_streaming": false,
"plugin_config": {
"dtype": "bfloat16",
"bert_attention_plugin": "auto",
"gpt_attention_plugin": "auto",
"gemm_plugin": "bfloat16",
"explicitly_disable_gemm_plugin": false,
"gemm_swiglu_plugin": null,
"fp8_rowwise_gemm_plugin": null,
"qserve_gemm_plugin": null,
"identity_plugin": null,
"nccl_plugin": null,
"lora_plugin": null,
"weight_only_groupwise_quant_matmul_plugin": null,
"weight_only_quant_matmul_plugin": null,
"smooth_quant_plugins": true,
"smooth_quant_gemm_plugin": null,
"layernorm_quantization_plugin": null,
"rmsnorm_quantization_plugin": null,
"quantize_per_token_plugin": false,
"quantize_tensor_plugin": false,
"moe_plugin": "auto",
"mamba_conv1d_plugin": "auto",
"low_latency_gemm_plugin": null,
"low_latency_gemm_swiglu_plugin": null,
"context_fmha": true,
"bert_context_fmha_fp32_acc": false,
"paged_kv_cache": true,
"remove_input_padding": true,
"reduce_fusion": false,
"user_buffer": false,
"tokens_per_block": 64,
"use_paged_context_fmha": false,
"use_fp8_context_fmha": false,
"multiple_profiles": false,
"paged_state": false,
"streamingllm": false,
"manage_weights": false,
"use_fused_mlp": true,
"pp_reduce_scatter": false
},
"use_strip_plan": false,
"max_encoder_input_len": 1024,
"monitor_memory": false,
"use_mrope": false
}
}
there are use developed python backend (spark_tts, audio_tokenizer, vocoder) in https://github.com/SparkAudio/Spark-TTS/tree/main/runtime/triton_trtllm/model_repo and just fill grpc pb stub params like this: # fill template with pbtext file for api params
modal run src/llm/trtllm/tts_spark/ready_model.py \
--tag-or-hash "main" \
--trt-dtype "bfloat16" \
--spark-tts-params "bls_instance_num:4,triton_max_batch_size:16,max_queue_delay_microseconds:0" \
--audio-tokenizer-params "triton_max_batch_size:16,max_queue_delay_microseconds:0" \
--tensorrt-llm-params "triton_backend:tensorrtllm,triton_max_batch_size:16,decoupled_mode:False,max_beam_width:1,max_tokens_in_paged_kv_cache:2560,max_attention_window_size:2560,kv_cache_free_gpu_mem_fraction:0.5,exclude_input_in_output:True,enable_kv_cache_reuse:False,batching_strategy:inflight_fused_batching,max_queue_delay_microseconds:0,encoder_input_features_data_type:TYPE_FP16,logits_datatype:TYPE_FP32" \
--vocoder-params "triton_max_batch_size:16,max_queue_delay_microseconds:0"
Note nvcr.io/nvidia/tritonserver:25.02-trtllm-python-py3 use python3.12.3, # run tritonserver
APP_NAME=tts-spark modal serve src/llm/trtllm/tts_spark/tritonserver.py
# curl health to startup tritonserver (as cold-starting)
curl -vv -X GET "https://weedge--tritonserver-serve-dev.modal.run/v2/health/ready" -H "accept: application/json"
modal run src/llm/trtllm/tts_spark/client_http.py \
--action health_meta_statics \
--server-url "weedge--tritonserver-serve-dev.modal.run"
modal run src/llm/trtllm/tts_spark/client_http.py \
--action cli_sdk_health_meta_statics \
--server-url "weedge--tritonserver-serve-dev.modal.run"
modal run src/llm/trtllm/tts_spark/client_http.py \
--action tts \
--server-url "weedge--tritonserver-serve-dev.modal.run"
modal run src/llm/trtllm/tts_spark/client_http.py \
--action cli_sdk_tts \
--output-audio cli_sdk_tts_output.wav \
--server-url "weedge--tritonserver-serve-dev.modal.run"
modal run src/llm/trtllm/tts_spark/client_http.py \
--action cli_sdk_tts \
--output-audio cli_sdk_tts_output.wav \
--target-text "你好,请将一个儿童故事,文字不少于200字,故事充满童趣和奇妙幻想。" \
--output-audio "child_story.wav" \
--server-url "weedge--tritonserver-serve-dev.modal.run"
# single test
CLI_MODE=http modal run src/llm/trtllm/tts_spark/bench.py \
--server-url "weedge--tritonserver-serve-dev.modal.run" \
--reference-audio "/prompt_audio.wav" \
--huggingface-dataset ""
# hf dataset with (wenetspeech4tts 26 rows) with concurrency 1 task to bench
CLI_MODE=http modal run src/llm/trtllm/tts_spark/bench.py \
--server-url "weedge--tritonserver-serve-dev.modal.run" \
--reference-audio "" \
--huggingface-dataset "yuekai/seed_tts" \
--split-name wenetspeech4tts \
--num-tasks 1
# single test used by http client sdk
CLI_MODE=cli_sdk_http modal run src/llm/trtllm/tts_spark/bench.py \
--server-url "weedge--tritonserver-serve-dev.modal.run" \
--reference-audio "/prompt_audio.wav" \
--huggingface-dataset ""
# hf dataset with (wenetspeech4tts 26 rows) with concurrency 1 task to bench used by http client sdk
CLI_MODE=cli_sdk_http modal run src/llm/trtllm/tts_spark/bench.py \
--server-url "weedge--tritonserver-serve-dev.modal.run" \
--reference-audio "" \
--huggingface-dataset "yuekai/seed_tts" \
--split-name wenetspeech4tts \
--num-tasks 1
# hf dataset with (wenetspeech4tts 26 rows) concurrency min(num_tasks,26) task to bench used by http client sdk
# num-tasks: 2->4->8->16->26
CLI_MODE=cli_sdk_http modal run src/llm/trtllm/tts_spark/bench.py \
--server-url "weedge--tritonserver-serve-dev.modal.run" \
--reference-audio "" \
--huggingface-dataset "yuekai/seed_tts" \
--split-name wenetspeech4tts \
--num-tasks 2todo:
reference
|
|
⭐️ python backend BLS(business-logic-scripting) decoupled(stream): |
feat:
fix:
Note
infer test:
model_warmupin the model configuration file to achieve this. )| container setup to run cost: 44.1 s | first infer cost: 8.52 s | second infer cost: 3.04 s | (generate duration 5s audio)
the first inference cost statics:
the second inference cost statics:
ps: other such as Perf Analyzer etc.. be continued
todo: streaming infer
bench data:
infer bench (tritornserver deploy on the L4 GPU , use first Inference to warmup):
2 concurrency task do 26 tts | scaling to 2 containers


4 concurrency task do 26 tts | scaling to 4 containers
8 concurrency task do 26 tts | scaling to 8 containers
16 concurrency task do 26 tts | scaling to 10 containers


TTS result audio (wav):

模型结构见:#130
tritonserver (triton-inference-server) arch:

from https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/index.html
reference: