Skip to content

UPSTREAM PR #19495: jinja: add missing tojson filter for undefined type#1162

Open
loci-dev wants to merge 1 commit intomainfrom
loci/pr-19495-fix-jinja-tojson-undefined-type
Open

UPSTREAM PR #19495: jinja: add missing tojson filter for undefined type#1162
loci-dev wants to merge 1 commit intomainfrom
loci/pr-19495-fix-jinja-tojson-undefined-type

Conversation

@loci-dev
Copy link

Note

Source pull request: ggml-org/llama.cpp#19495

jinja: add missing tojson filter for undefined type

value_undefined_t::get_builtins() was the only type missing the
tojson filter, causing "unknown filter 'tojson' for type Undefined"
when templates reference undefined variables (e.g. tools | tojson
with no tools defined).

@loci-review
Copy link

loci-review bot commented Feb 11, 2026

Overview

Analysis of llama.cpp across 115,762 functions (33 modified, 0 new, 0 removed, 115,729 unchanged) reveals negligible performance impact. All changes occur in non-critical paths—template engine initialization, HTTP library utilities, and STL functions—with zero modifications to core inference operations (matrix multiplication, attention mechanisms, KV cache management).

Power Consumption Changes:

  • build.bin.llama-tts: 361,809.82 nJ → 361,580.66 nJ (-0.063%)
  • build.bin.llama-cvector-generator: 356,206.11 nJ → 356,127.02 nJ (-0.022%)
  • build.bin.libllama.so, build.bin.libmtmd.so, build.bin.llama-bench, build.bin.llama-tokenize, build.bin.llama-quantize, build.bin.llama-qwen2vl-cli, build.bin.libggml-base.so, build.bin.libggml-cpu.so, build.bin.libggml.so, build.bin.llama-gguf-split, build.bin.llama-llava-cli, build.bin.llama-minicpmv-cli, build.bin.llama-gemma3-cli: 0.000% change

Function Analysis

Jinja Template Engine (value_undefined_t::get_builtins): Response time increased 790-868ns (+2.8-3.1%) due to adding tojson filter (commit 488b598). This one-time startup cost enables JSON serialization of undefined values, improving template robustness. Throughput time increased 7.5-8.2ns (+1.2-1.3%).

HTTP Library (httplib::Client::Post, std::function::operator=): Response time changes of -86ns to +8ns with security improvements (overflow prevention, Expect: 100-continue support). Throughput time increased 26ns (+28.7%) in Post wrapper, offset by 86ns improvement (-52.4%) in operator=.

STL Functions: std::__adjacent_find improved 48ns (-8.6% response, -26.9% throughput), std::__detail::_Executor::_M_handle_subexpr_begin improved 37ns (-13.3% response, -27.8% throughput). Other analyzed functions saw negligible changes from compiler optimizations.

All changes represent correctness improvements (template filter support, HTTP security) with acceptable performance trade-offs in non-critical initialization paths.

🔎 Full breakdown: Loci Inspector.
💬 Questions? Tag @loci-dev.

@loci-dev loci-dev force-pushed the main branch 10 times, most recently from 823244c to bab7d39 Compare February 19, 2026 02:17
@loci-dev loci-dev force-pushed the main branch 10 times, most recently from a92fe2a to 6495042 Compare February 27, 2026 02:17
@loci-dev loci-dev force-pushed the main branch 7 times, most recently from 504cad7 to 9f4f332 Compare March 5, 2026 02:17
@loci-dev loci-dev force-pushed the main branch 4 times, most recently from 8019888 to 17452e3 Compare March 9, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants