Repository navigation
Conversation
…input dims, inputs bound by name) TractEmbedder could not run nomic-embed-text-v1.5, and any graph whose declared input order differs from input_ids, attention_mask, token_type_ids was fed the wrong tensors. Two causes, both in tract_backend.rs: - Inputs were pinned to a concrete [1, seq_len]. HF exports declare batch_size and sequence_length symbolically, and nomic's value_info at the first Gather uses them, so optimize failed with "Impossible to unify Sym(batch_size) with Val(1)". The inputs now use the graph's own symbols. - Inputs were bound by position as [ids, mask, types]. nomic declares input_ids, token_type_ids, attention_mask, so the mask went into token_type_ids. Inputs are now bound by name; unnamed graphs keep the old positional order. OrtEmbedder already binds by name. The tract floor for the wasm feature rises to 0.23.10 and Cargo.lock is updated: with the locked 0.23.8, nomic still fails at optimize on the rotary Range op. The lock bump also moves minijinja 2.24 -> 3.1.0, adds metrics and rapidhash and drops memo-map (tract 0.23.10 dependencies). Tests: new tests/tract_named_inputs.rs, #[ignore]d, real models only (hashes pinned; missing models skip). nomic vs stored onnxruntime vectors: min cosine 0.9999993 (failed to load before). bge-small and all-MiniLM-L6-v2 match vectors recorded from the unpatched backend at cosine >= 0.99999934, single and batched. Graphs with reordered inputs match the stock order at cosine >= 0.9999992 (before: 0.54, and a panic in tract's Gather). Existing crate tests 15/15.
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.
TractEmbedder could not run nomic-embed-text-v1.5, and any graph whose declared input order differs from input_ids, attention_mask, token_type_ids was fed the wrong tensors. Two causes, both in tract_backend.rs.
Inputs were pinned to a concrete [1, seq_len]. HF exports declare batch_size and sequence_length symbolically, and nomic's value_info at the first Gather uses them, so optimize failed with "Impossible to unify Sym(batch_size) with Val(1)". The inputs now use the graph's own symbols.
Inputs were bound by position as [ids, mask, types]. nomic declares input_ids, token_type_ids, attention_mask, so the mask went into token_type_ids (min cosine vs ort 0.42 with only the first fix). Inputs are now bound by name; unnamed graphs keep the old positional order. OrtEmbedder already binds by name (ort_backend.rs).
The tract floor for the wasm feature rises to 0.23.10 and Cargo.lock is updated. With the locked 0.23.8, nomic still fails at optimize on the rotary Range op ("Translating node /encoder/layers.0/attn/rotary_emb/Range"); with 0.23.10 it loads. 0.23.9 was not tried. The lock bump also moves minijinja 2.24 -> 3.1.0, adds metrics and rapidhash and drops memo-map (all tract 0.23.10 dependencies). Happy to split the lock bump into its own PR if you prefer.
Not changed: the plan cache is still keyed per padded length, although the plans are now symbolic and so identical (could collapse to one plan in a follow-up). examples/onnx-embeddings-wasm/src/model.rs has the same positional binding and a concrete batch dim; left alone. The symbol names batch_size and sequence_length are hardcoded, which matches the HF/Xenova exports tested here; a graph that names its dims differently would need the declared dims used instead.
Tests: new tests/tract_named_inputs.rs, #[ignore]d and real models only (hashes pinned and checked; missing models skip). nomic tract vs stored onnxruntime vectors: min cosine 0.9999993 (3 texts; before the change it fails to load). bge-small and all-MiniLM-L6-v2: cosine 0.99999934 or better against vectors recorded from the unpatched backend, single and batched, 5 texts of different lengths. Input binding: bge and MiniLM weights with graph.input rewritten to other orders (including nomic's) match the stock order at cosine >= 0.9999992; before the change one case returns cosine 0.54 and the reversed MiniLM case panics in tract's Gather. Existing crate tests 15/15 on both sides. Run with --features wasm -- --include-ignored; set RUVECTOR_EMBED_MODELS_DIR if the models are not under npm/packages/typesafe/models (nomic goes in nomic-embed-text-v1.5/{model.onnx,tokenizer.json}). Not run: the native/ort parity.rs and a wasm32 build.