Sesame CSM in Tensorrt-llm
@QiJune is already working on this.
Since Jul 18, 2025.
- Dominant language
- Python
- Stars
- 14.7k
- Forks
- 2.8k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 489
Description
Hello,
I am interested in implementing a tensorrt-llm precompiled engine to serve the sesame csm tts model, and would like some guidance on ideas for how to implement and serve it. This model consists of two llama 3 models: a 1B backbone, and a 100M decoder. To generate a frames of audio from text input, it does the following:
- Tokenizes text w Llama tokenizer, embeds the text tokens with a text token embedder
- Passes text embeds to backbone. Backbone produces 1 audio token.
- Backbone passes its audio token and its last hidden state to the decoder
- The decoder then autoregressively generates 31 audio tokens (each token uses a different LM head)
- These 32 tokens are then embedded (there is a separate embedding table for each token), the embeddings are summed into a single embedding, and this embedding is passed back into the backbone.
I want to be able to stream these blocks of 32 output tokens. I am confident in being able to build and compile the engine using the engine builder python api, but I am not positive what the best way to serve it is. I have the following two ideas:
The first is following the same style as the HF implementation. They do the following:
- Implement the backbone as a LlamaModel with a custom embedding layer to handle both text and audio tokens.
- Implement the decoder as a LlamaModelForCausalLM with a custom embedding layer and custom logic for the LM heads.
- Here is where it gets hairy and where my main question is. They add custom generation that first generates the backbone logits normally. Then, they override the sample method to sample the backbone token, and run the 31 forward passes on the decoder model.
Would something like this be possible with the PyExecutor in Tensorrt-llm? Would it be possible to define a custom sampler which does the same thing as the huggingface implementation? It would sample the backbone logits, then run the decoder as a DecoderModelForCausalLM in a GenerationSession session for 31 iterations, and finally return the 32 tokens. This is kind of similar to speculative to decoding, minus the verification part.
The other strategy would be to serve the two separate engines and connect them using BLS in Triton Inference Server. Is that reasonable?
Thanks for any guidance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.