Repository navigation
Conversation
…nizer uses them ERNIE 5.5's tokenizer.json splits digit runs into 510s and then threes from the right with `(?>...)`, `$`, `\A`, `\z` and `\G`, which the matcher refused, so the tokenizer did not load (UnsupportedRegex). Each is now a zero-width step as Oniguruma reads it in Ruby syntax: `\A` and `\z` are the piece's start and end, `$` is its end or a position before "\n", `\G` is where the search started (find_iter's last end), and `(?>...)` is the atomic step possessive quantifiers already use. A pattern that compiled before compiles to the same program. fixtures/onig_anchors.json holds what tokenizers 0.23.3 splits for each, and for the release's pre-tokenizer on digit texts and runs from 509 to 1,025 digits; tools/zig/onig_anchor_fixtures.py rebuilds it from the release's tokenizer.json.
Slice 1 of ashhart#4926, host only on the pattern of ashhart#3578: nothing is served and no kernel is added. - config.zig reads config.json through core/config_fields.zig and refuses, by key, a layout the engine does not run. Structural keys are held to the release's values in three groups, named in each refusal: keys the weight map follows, keys the vendor's plugin runs one way only, and keys whose meaning is not read yet. Sizes are read, not pinned; a small hand-written shape parses. Only the FP4 release (FP8 128x128 blocks with MXFP4 routed experts) is admitted. - names.zig expects every tensor of the 128 model shards, with dtype and shape, and checks them against safetensors headers: the folded table of the release's 140,457 tensors, edited copies (missing, retyped, reshaped and extra tensors by name) and, under TF_ERNIE55_HEADERS, the real shards. The optional FlashIndexer file is not in the map. - plan.zig derives each layer's attention (HCA or DSA), its feed-forward (dense or MoE), the HCA compress ratio and the draft head's layer count. - prompt.zig renders a user turn, an optional system turn, thinking on or off and the reasoning effort as the release's chat encoding does, with the request's byte spans, and encodes through the tokenizer core's encodeMasked, so request text never becomes a protocol token. It matches the release's text, spans and ids on 20 requests, with a cut tokenizer in CI and with the release's tokenizer under TF_ERNIE55_CKPT; it needs the anchors the previous commit adds. tools/zig/ernie5_5_fixtures.py rebuilds the five fixtures from the release's files, pinned by sha256, and its headers; --check compares them byte for byte.
Bizuayeu
force-pushed
the
pr/ernie55-slice1
branch
from
November 25, 2026 02:50
2eceb5a to
75628d6
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Host-only family package for ERNIE 5.5 Flash Preview (
baidu/ERNIE-5.5-Flash-Preview, Apache-2.0): config parsing that refuses layouts the engine does not run, the weight map checked against the release's safetensors headers (read withcore/safetensors.zig), the layer plan, and the text chat encoding and tokenizer checked against the release's own ids, with the fixtures and the script that rebuilds them. No kernels, no CUDA code, no host: nothing is served.It is slice 1 of #4926 ("Smallest first slice" there, on the pattern of #3578), which can open whenever ready per #4926 (comment). It needs the tokenizer anchors of #4984, on which it is stacked: without them the release's
tokenizer.jsondoes not load. Where it differs from the slice as proposed, so the review can weigh it:plan.zig) holds each layer's attention (HCA or DSA), its feed-forward (dense or MoE), the HCA compress ratio and the draft head's layer count. The DSpark block's size, rank, noise token and tapped layers are parsed and checked inconfig.zigbut not planned yet; the RoPE type and theta per layer are parsed, and the forward slice will plan them.low,mediumorhigh. Tools, media and earlier turns are not in itsRequest.names.check) is written in the family, as inkling2: host-only family package for Inkling 2 Small #3578's is (Inkling 2 and Ling have their own too). If you would rather have one checker in core, I will move it there first in a behaviour-neutral pull request.flashindexer.safetensors, 12 tensors) is not in the map.tools/zig/ernie5_5_fixtures.pyrebuilds all five fixture files from the release's files, so a reviewer can check them.If you would rather have any of these as a follow-up pull request, I will split it out.
mxfp4experts in core, the decode round at one rank, two ranks, the prompt path and KV pool, serving, and DSpark are not in this pull request.7c4f403911, on main3795e6054c). This pull request adds one commit,75628d66f4: 19 files, 1,982 insertions against7c4f403911. Main has since moved on to4c79cfe346;git merge-tree --write-treeof this head with it merges without a conflict.atc overlap --json: atc 0.9.4 withATC_READ_ONLY=1, run in this tree on 2026-11-25 at 02:46 UTC after the last rebase, with base main94e0f2dc27and again with--base 7c4f403911(tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984's head, so only this commit's files count), head2eceb5af37(the same tree as75628d66f4but for the number in this commit'sCHANGELOG.mdline):complete: false(otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit) both times, with the same 23 pull requests sharingbuild.zig,CHANGELOG.mdorTHIRD_PARTY_NOTICES.md: 4conflicts(Implement GLP control vectors with a fused Metal kernel for Qwen3.8-27B #1835, app: control vector picker and strength in Engine advanced #1951, ricursive: load Ripple's EXL3 packs through main's shared EXL3 code #2514, CUDA: an int4 W4A16 kernel for GPTQ group-128 routed experts and the LM head #4183), 6cleanand 13unknown. For each of the 17 that are notclean,git merge-tree --write-treeof the pull request's head with7c4f403911and with this head gives the same conflicting files and the same number of conflict hunks (14 conflict already, 3 merge cleanly with both), so this commit adds no conflict. Run once more on 2026-11-25 at 04:45 UTC with--base 7c4f403911and main at4c79cfe346: 23 pull requests, 3conflicts(Implement GLP control vectors with a fused Metal kernel for Qwen3.8-27B #1835, app: control vector picker and strength in Engine advanced #1951, CUDA: an int4 W4A16 kernel for GPTQ group-128 routed experts and the LM head #4183), 7cleanand 13unknown; the same check on the 16 that are notclean(each pull request's head checked against itsheadRefOid) finds the same conflicting files and hunks with7c4f403911and with this head.Parts of the core this slice uses, in the order of the host table in
docs/recipes/adding-a-zig-family.mdand then the others it reads:lanes/engine.zig,lanes/backend.zig,lanes/drafter.zig,lanes/drafted.zig,lanes/solo_chunk.zig,lane_host.zig,engine_api.zig,kv_pool.zig,kv_ledger.zig,prompt_cache.zig,prompt_radix.zig,prompt_tail.zig,recurrent_workspace.zig,checkpoint_direct.zig,direct_gather.zig: not used. There is no forward and no host yet.rope_yarn.zig: not used yet. The HCA layers scale RoPE with YaRN atcompress_rope_theta160,000; the DSA layers, the indexer and the draft head use plain RoPE atrope_theta8,000,000.affine4_host.zig,gguf.zig: not used; the release stores FP8 E4M3 blocks, MXFP4 routed experts, BF16 and F32, not MLX affine or GGUF.modelopt.zig: not used. Thequantization_configis FP8 E4M3 in 128×128 blocks withexpert_dtype: mxfp4, not a ModelOpt recipe, soconfig.zigchecks it itself. Reading the MXFP4 experts is the next slice's, in core's grouped experts as agreed on ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926.core/config_fields.zig: used.ReaderandProblemreadconfig.json, so each refusal names its key.core/safetensors.zig: used for the headers:parseHeader,Header,EntryandDType. The package has no parser or dtype enum of its own.core/tokenizer: used with tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984:parseandloadTokenizer,encodeMaskedwith the request's byte spans, so request text that spells a protocol tag stays text, anddecode.core/template: not used. The release has no Jinja chat template; its chat encoding is Python (encoding_ernie.py), andprompt.zigrenders the same text for the requests above (written after reading it; no source copied, seeTHIRD_PARTY_NOTICES.md).ernie5_5entry is added to the native hosts' family lists, because there is no host to open.Callers of
prompt.zigandplan.zig: nothing outside the tests calls them yet.What the package contains:
config.zigreads the release'sconfig.json(model typeernie5_5_moe) and refuses, by key, a layout the engine does not run. Sizes are read, not pinned (a small hand-written shape parses in the tests);compress_ratiostakes a positive ratio for an HCA layer or -2 for a DSA layer and nothing else; only the FP4 release's quantization is admitted. Structural keys are held to the release's values in three groups, and each refusal names its group: keys the weight map follows (enable_hyper_connections,use_vha_attention,use_gated_attn,n_shared_experts,multimaxand 11 more), keys the vendor's plugin runs one way only (moe_split_feature_routing,routed_scaling_factor_learnable,n_group,topk_group,scoring_funcand 4 more), and keys whose meaning is not read yet, held at the release's value (experimental_attention_variant,hybrid_mla_attention,csa_dense_modeand 10 more).names.zigexpects every tensor of the 128 model shards with its dtype and shape and checks them against safetensors headers: missing, wrong and unknown tensors are reported by name, andnames.mergejoins the headers of several files and refuses a name held twice.plan.zigderives the plan above.prompt.zigrenders a request with its byte spans and encodes it throughencodeMasked.Checks on this head
75628d66f4on tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984's7c4f403911on main3795e6054c. The runs below are on83d1fe7bdconc7f3c86ce9, which differ from these heads only in the pull request numbers in the twoCHANGELOG.mdlines and in tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984's commit title.python3 tools/zig/lean_check.py, on the base and on this head: 165 problems on tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984's head, 165 on main3795e6054cand 165 on this head, 0 new (tools/zig/lean_new.py). The 165 are inherited from main. The largest source file of the package isconfig.zigwith 296 lines.zig build test-ernie5_5-host --summary all, without the environment variables: 3 of 3 steps, 11 of 13 tests passed, 2 skipped (TF_ERNIE55_HEADERSandTF_ERNIE55_CKPTare unset).TF_ERNIE55_HEADERS=<the first bytes, the header, of the release's 128 model shards>andTF_ERNIE55_CKPT=<the release's tokenizer.json>: 3 of 3 steps, 13 of 13 tests passed. Release files at revisionace1100dcde7bf4eb06add6ae11ce4f43a11ddfe; the script below checks their sha256.regex.zigreplaced by main's: 2 tests fail (the cut tokenizer's ids, and protocol-tag text);names.checknot comparing the dtype: 1 fails; not comparing the shape: 1 fails; not reporting unknown tensors: 2 fail;config.zignot checking the pinned keys: 1 fails; the effort written outside the request spans: 1 fails.python3 tools/zig/ernie5_5_fixtures.py --release <release files> --headers <the 128 header copies> --out zig/src/families/ernie5_5/fixtures --check: 5 of 5 files the same, with transformers 5.20.0 and tokenizers 0.23.3 (the script exits if the versions differ, and checks the sha256 ofconfig.json,tokenizer.json,tokenizer_config.jsonand the three vendor files it loads the reference tokenizer from, offline).zig build -Dfixed-cpu test-tokenizer-hoston Linux: 64 of 64 tests passed, as on tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984.python3 -m unittest discover -s tools/zig -p host_tests_test.py -von Linux (this pull request adds a step tobuild.zig): 13 tests OK.zig build -Dfixed-cpu: exit 0.zig build -Dfixed-cpu test test-golden test-kernel-contract fuzz-cortheon --test-timeout 20m --summary failures(the new step is wired intotest): 915 of 918 steps succeeded, 13,844 of 13,942 tests passed, 97 skipped, 1 failed,start_cli_test("Ctrl-C during a deferred download has its normal process effect"), whose forked child raises SIGINT. My job runner had started the build as a background job of a non-interactive shell, so every child process ignored SIGINT and SIGQUIT; that step's test binary, built from this branch on an earlier base (1e5072adbd, wherestart_cli_test.zigis the same), passes 29 of 29 when run directly. With the runner restoring the default handling, the same command succeeded, 918 of 918 steps (the steps that had passed came from the cache).python -m pytest -q -rs -p no:cacheproviderfrom the root, on Linux with pytest 9.2.0 and PyYAML 6.0.4 (what CI's job installs), Zig 0.17.0 and aclang++onPATH: main3795e6054c, tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984's head and this head each 808 passed, 106 skipped, 825 subtests passed, with the same skip reasons. Two of the skips aretools/zig/test_nfkd_tables.py("this interpreter has Unicode 15.0.0").zig fmt --checkandzig ast-checkof the 11 Zig files this commit adds or changes, andgit diff --check 7c4f403911..HEAD: exit 0.python3 tools/pr_check.py --base origin/main --pr 4985: 0 errors, 0 warnings.75628d66f4:fmt,zig,zig-b,zig-windows,zig-macos-dev-tools,pytest(809 passed, 105 skipped, 826 subtests passed; the Linux run above has 808 and 106, and the CI log does not print skip reasons),release-paths (ubuntu-24.04),comfyui-moss-installerand bothbenchmark-clientsjobs passed;host-nightly-linuxandhost-nightly-macoswere skipped. The annotations are GitHub's Node.js 20 deprecation warnings and a macOS runner queue notice.Receipt
n/a: no inference, no kernel, no host. The package is not called by the server.
3795e6054c, tokenizer: \A, \z, $, \G and atomic groups, as the ERNIE 5.5 pre-tokenizer uses them #4984 and this head, Zig 0.17.0, x86-64 Linux (Ubuntu 24.04 under WSL 2) and x86-64 Windows 11, CPU only, no weights loaded. Releasebaidu/ERNIE-5.5-Flash-Previewatace1100dcde7bf4eb06add6ae11ce4f43a11ddfeforconfig.json,tokenizer.json,tokenizer_config.json, the chat encoding's Python files and the safetensors headers.release_header.txt(149 patterns, its own count and sha256 checked when unfolded) and against the real headers. Routed experts are I8 (two E2M1 codes a byte) with F8_E8M0 scales over 32 inputs in the 2,048-wide latent; the FP8 E4M3 tensors (the shared experts, the dense layer and attention projections) carry F32weight_scale_invover 128×128 blocks; the other tensors are BF16 or F32. A test edits a config to move a DSA layer and the release's headers catch it. Only the headers were read, no weights.ErnieChatTokenizerloaded from its files (render_chat(messages, add_generation_prompt=True, ...)for the text and spans,apply_chat_template(..., tokenize=True)for the ids). 20 chat requests (thinking on and off, each effort, a system turn, an empty system and user text, Unicode,\r\n, a 600-digit run, and protocol-tag text in the user and in the system turn) and 7 raw texts: text, spans and ids equal with the release'stokenizer.json, and the ids decode back to the text. The always-running test uses a cuttokenizer.json(the 21 protocol tokens, the byte alphabet and the first 1,500 merges, the same pre-tokenizer) against the same 20 requests and 7 texts from the reference library.config.json, the cuttokenizer.json, the case files and the header table are listed inTHIRD_PARTY_NOTICES.mdunder that licence.Checklist