Skip to content

template: add the float filter - #3577

Merged
ashhart merged 2 commits into
ashhart:mainfrom
Nipale-ai:template-float-filter-3476
Nov 17, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
Nipale-ai:template-float-filter-3476

Conversation

@Nipale-ai

@Nipale-ai Nipale-ai commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The chat template compiler refused every template that uses Jinja's float filter ("template uses unsupported filter or test 'float'"). It now accepts it as Jinja defines it, float(value, default=0.0): numbers, booleans and ASCII numeric text convert, anything else gives default, an undefined value raises as it does in Jinja, and an argument Jinja does not have is an error. Text is read as ASCII only: a non-ASCII digit or a Unicode space gives default, where Python reads it. Inkling 2 Small's chat template reads its thinking effort through | float.

  • Issue: Refs Inkling 2 Small on four DGX Sparks: a native CUDA family #3476. First dependency of the Inkling 2 family package, which follows in its own pull request.
  • Stacked on: main.
  • atc overlap --json (atc 0.9.6, with ATC_READ_ONLY=1), run in this tree on 2026-11-16 at 13:21 CET, base main e86a0bed1 (main had moved on from e2375f36a, the base of this head; git merge-tree of this head with e86a0bed1 and with the later 9e00f2cb5 merges cleanly), this head 72a2707ed: complete: false (otherPullRequestsLimit, pullFilesUnavailable, pullRequestsLimit, timeLimit), no overlap with any other pull request listed, hence no conflict found, but the list is incomplete (the limits above). The same result on three runs. It also lists the other worktrees of this clone: 3 of the 8 listed conflict with this head. These are earlier drafts of this same change (the first float branch, the first host-package branch and the clone's Inkling 2 draft branch; matched by their file counts and checked with git merge-tree against this head), not other pull requests. They collide with this head in CHANGELOG.md, zig/src/core/template/filters.zig and zig/src/core/template/tests.zig (and in tools/zig/template_parity.py for two of them).

Checks on this head

  • Head commit: 72a2707 on main e2375f3.
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 221 and 221 problems, 0 new (CI's procedure with a base worktree and tools/zig/lean_new.py).
  • Tests run, with the command and pass, fail and skip counts; x86-64 Linux, Zig 0.17.0, unless a line says macOS:
    • zig test --dep sys -Mroot=zig/src/core/template/tests.zig -Msys=zig/src/platform/sys.zig -lc: All 40 tests passed.
    • zig test --dep sys -Mroot=zig/src/core/template/template.zig -Msys=zig/src/platform/sys.zig -lc (includes provenance_test.zig, whose filter count is now 31): All 40 tests passed.
    • Expectations for the new probes come from jinja2 3.1.6: every float row of tests.zig (6 rows) rendered with jinja2.Environment().from_string(...).render() gives the expected string in the file, or raises where the file expects an error (0 differ). The error probes raise TypeError for float(2, 3) and float(boolean=true) and UndefinedError for undefined_name|float.
    • Where Zig and Python differ on purpose: a scratch probe, not in the branch, renders ' + U+0663 + '|float and a text of U+00A0 and 7 to 0.0|0.0 here, and 3.0|7.0 in jinja2 3.1.6.
    • Planted controls on tests.zig, each turned red and back: filters.zig of main (no float): 38 passed, 2 failed; the boolean parameter accepted: 39 passed, 1 failed; the undefined-value check removed: 39 passed, 1 failed.
    • zig fmt --check build.zig zig: exit 0. git diff --check origin/main..HEAD: exit 0.
    • python3 tools/pr_check.py --base origin/main: 0 errors, 1 warning (--pr NUMBER was not given, so the Unreleased line is not checked). This change carries no CHANGELOG line; given a pull request number, pr_check reports that as a warning, as it did for qwen3_5 cuda: the dense family has a rank plan, host only; it moves no tokens #3383 (tools/pr_check.py lines 90 and 91).
    • python3 tools/zig/cuda_common_check.py && python3 tools/zig/cuda_fragment_check.py and cuda_common_check_test.py: 51 copies, 0 violations; 2 fragments, 0 misses; 9 tests OK.
    • python3 -m unittest discover -s tools/zig -p host_tests_test.py: 13 tests OK. -p build_options_test.py: 5 tests OK. -p flashnext_batch_serve_test.py: 8 tests OK.
    • zig build -Dfixed-cpu test-host --test-timeout 20m with a fresh local build cache directory, first run: 2099 of 2105 steps succeeded (1 failed), 19846 of 19978 tests passed, 131 skipped, 1 failed. The failed test is bringup_test ("two ranks settle on the real clock and agree on one plan and view; a goodbye ends the other's watch by name"; zig/src/cluster/bringup_test.zig:97, expectEqual(x.view, y.view): expected 5693255286640881692, found 3698603761711287178). This pull request changes no file under zig/src/cluster or zig/src/platform, and the same test-host run on main e2375f3 succeeded (below). After the failure, in this order: a repeat in the first directory: 2105 of 2105 steps succeeded (test steps whose inputs had not changed came from the cache and the others ran again, among them the one that had failed, which passed with 37 tests and 1 skipped; 1940 of 1981 tests counted, 41 skipped). A second repeat there: 2105 of 2105 steps succeeded. Then two attempts that are not counted: one failed with "No space left on device" errors in its cache directory, and one was started with umask 0002 by my mistake and failed in cli_config_test, which refuses a config file that other users can write (with umask 0002 the same test fails on main e2375f3 too, with umask 022 it passes on both). Then a test-host run in another fresh local cache directory: 2105 of 2105 steps succeeded, 19846 of 19978 tests passed, 132 skipped. The test program of the failed step (test-cluster-membership-host) alone passed 25 of 25 runs one at a time. Run 64 at a time, 300 runs each, it failed 21 times on main e2375f3 (14 at line 97, the same line, and 7 at line 133 of the same file) and 17 times on this head (14 and 3). So the test also fails on main when the box is loaded; it uses the real clock. I did not look further into its code. zig build test-cuda-host: 410 of 410 steps succeeded, 6885 of 6918 tests passed, 33 skipped. test-kernel-contract: 34 of 34 steps, 205 tests passed. test-golden: 5 of 5 steps. fuzz-cortheon: 3 of 3 steps. Plain zig build: 33 of 33 steps. zig build -Dfixed-cpu test --test-timeout 10m: 694 of 694 steps, 407 of 420 tests passed, 13 skipped. test-qwen-serving-host, test-server-security and test-pull-security run inside the test-host aggregate and were not run on their own as separate commands. test-gradient-serving is excluded from test-host on main (red on main, CI never reaches 246 of the 393 named test steps, and nine of them fail on main #2031) and was not run. On main e2375f3 the same runs (a fresh local cache directory, the same commands): test-host 2105 of 2105 steps succeeded, 19847 of 19978 tests passed, 131 skipped; test-cuda-host 410 of 410 steps succeeded, 6885 of 6918 tests passed, 33 skipped; test-kernel-contract 34 of 34 steps, 205 tests; test-golden 5 of 5 steps; fuzz-cortheon 3 of 3 steps; plain zig build 33 of 33 steps; zig build -Dfixed-cpu test 694 of 694 steps, 407 of 420 tests passed, 13 skipped.
    • python -m pytest -q -p no:cacheprovider from the root (run on the Inkling head, which contains this change): stops at collection with an ImportError, on main e2375f3 as well (zig/tests/qwen3_metal/test_reference.py imports F from reference and gets tools/lfm3/reference.py). With --ignore=zig/tests/qwen3_metal: 555 passed, 56 skipped; main e2375f3 with the same option: 555 passed, 56 skipped.
    • macOS, Zig 0.17.0, on an M5 Ultra with the Metal toolchain installed (xcrun metal --version: Apple metal version 32023.922), on this head (72a2707); every zig build below with --summary all and with one shared local build cache directory (--cache-dir). zig fmt --check build.zig zig: exit 0. zig build test test-golden -Dcpu=apple_m1: exit 0, 874 of 874 steps succeeded, 14376 of 14494 tests passed, 118 skipped; the test-golden step succeeded. zig build dev-tools -Doptimize=Debug: 268 of 268 steps succeeded. zig build -Dfixed-cpu dev-tools: 268 of 268 steps succeeded. zig build -Dfixed-cpu check-release-paths: 68 of 68 steps succeeded. zig build native -Dcpu=apple_m1 -Dversion=1.0.0: 66 of 66 steps succeeded. zig test of tests.zig and of template.zig (the two commands above plus -mcpu=apple_m1): All 40 tests passed each. tools/zig/nfkd_tables.py --check: exit 0; test_nfkd_tables.py with Python 3.14: 5 tests OK. In the dev-tools, check-release-paths and native runs, steps whose inputs had not changed show as cached in their logs and were not run again.
    • The other build steps above reused this box's build cache: a test step whose inputs had not changed since an earlier run shows as cached in its log and was not run again. The first test-host run and the later fresh one started from empty local cache directories (a new one each); the global cache is shared by all runs.
    • git range-diff 08f1de594..6760fa996 e2375f36a..72a2707ed (the earlier head against this one) marks the one commit changed (!); the only difference is that its change to CHANGELOG.md is gone, and the four other files have the same blobs (4 of 4). The zig test runs, the jinja2 probes, the scratch probe and the planted controls above ran on this head.
  • CI: green on 72a2707: fmt, zig, zig-b, zig-windows, zig-macos-dev-tools, pytest, release-paths and both benchmark-clients jobs passed; host-nightly-linux and host-nightly-macos were skipped.
  • Not run, and why: everything on CUDA or a GPU (no GPU code is in this pull request); test-gradient-serving, which main excludes from test-host (CI never reaches 246 of the 393 named test steps, and nine of them fail on main #2031); the check-release-paths build step on the Linux box, which main also excludes from test-host (the tool itself runs inside test-release-directory-host, which succeeded in test-host; the build step ran on the Mac and succeeded there, 68 of 68 steps); a model or checkpoint check on Metal (none was run; this pull request changes no Metal code); the Windows job.

Receipt

n/a for decode and prompt speed. The filter runs only when a chat template calls it, and git grep -E '\|[[:space:]]*float\b' over *.jinja, *.j2, *.json, *.txt and *.md finds no such template on this head, so no rendered prompt in the repository changes. A template that uses it was refused at load before and now renders as jinja2 3.1.6 does (the probes above). test-golden over the frozen server corpus passed: 5 of 5 steps (it records known differences separately).

  • Environment: TensorFold e2375f3 plus this head, Zig 0.17.0, x86-64 Linux, CPU only, no checkpoint.
  • Licence of any new weights or drafter: n/a

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

Nipale-ai and others added 2 commits November 17, 2026 02:56
Jinja's float(value, default=0.0) for numbers, booleans and numeric text.
Anything else gives the default, an undefined value raises, and an
argument Jinja does not have is an error, as in Jinja. Inkling 2's chat
template reads its thinking effort through it.
@ashhart
ashhart force-pushed the template-float-filter-3476 branch from 72a2707 to 3aa9a39 Compare November 17, 2026 02:56
@ashhart
ashhart merged commit ac54737 into ashhart:main Nov 17, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thank you @Nipale-ai. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @Nipale-ai! This is in TensorFold 1.2.10, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.10

  • Synthena

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