pytorch / pytorch/executorch

RFC: Jinja2cpp Support on ExecuTorch

Open
#15,147 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rfc
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🚀 The feature, motivation and pitch

Context

Many LLMs/VLMs today rely on structured prompting using chat_template.jinja file defined in HuggingFace. These templates are essential for formatting multi-turn conversations and aligning with model pretraining/fine tuning.

Currently, ExecuTorch does not support chat_template.jinja at runtime, which limits the ability to run chat-style LLMs out of the box i.e., without requiring host-side preprocessing or manual prompt formatting.

Motivation

  • Consistency: Ensures the same prompt formatting used during calibration/inference on HuggingFace is preserved in runtime.
  • Portability: Avoids duplicating chat template logic in runtime.
  • Usability: Enables developers to pass structured chat messages (e.g., role/content pairs or system/content) directly to the runtime without manual formatting.

Details

I’m exploring whether we could integrate Jinja2Cpp as a third-party dependency in ExecuTorch to support chat_template.jinja at runtime.

This would enable structured prompting for chat-style LLMs directly on-device, without requiring host-side preprocessing or manual prompt formatting.

References

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are identified in the issue. Start by reviewing the ExecuTorch runtime integration scope and the linked Jinja2Cpp and Hugging Face chat-template references; the work is complete only once a concrete implementation plan and runtime support criteria are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, huggingface
Domain
embedded-iot, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.