Skip to content

fix: harden edge cases across the ONNX and candle models, and repair CI - #355

Merged
anush008 merged 21 commits into
mainfrom
mis-fixes
Nov 16, 2026
Merged

anush008 merged 21 commits into
mainfrom
mis-fixes

Conversation

@anush008

@anush008 anush008 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

ONNX models

  • TextEmbedding::embed pools each batch before it runs the next one, so batch_size limits the memory in use.
  • TextEmbedding::embed and transform with no texts return an empty result for dynamically quantized models. A batch_size of 0 is still an error.
  • EmbeddingGemma300MQ is batched like the other EmbeddingGemma variants, because its output does not depend on the batch. TextEmbedding::get_quantization_mode returns QuantizationMode::Static for it, and embed splits its texts by batch_size.
  • TextEmbedding::list_supported_models returns the models in table order, instead of a different order in each process.
  • A lower-case form of a special token in a text, such as [sep] or [mask], is tokenized as ordinary text, as the model's tokenizer.json does.
  • A max_length below the tokenizer's special-token count returns an error, instead of a panic or no truncation. TextRerank checks the count for a pair.
  • CLS pooling returns an error for a model output with no tokens, instead of a panic.
  • TextRerank::rerank accepts [batch] logits, reads the first column of [batch, n] logits, and returns an error for other shapes, instead of a panic.
  • TextRerank::rerank and similarity::top_k rank a NaN score last. top_k keeps equal scores in corpus order, and 0.0 and -0.0 count as equal.
  • SparseTextEmbedding computes the SPLADE weights with ln_1p, so a small positive logit keeps a positive weight. Other weights move by 2e-7 at most.
  • SparseTextEmbedding::embed and Bgem3Embedding::embed return Error::InvalidShape for an output with no row for a text or token, instead of a panic.
  • ImageEmbedding returns an error for an image with no pixels. A pipeline that resizes aborted the process, and a pipeline that only pads returned the vector of an empty image.
  • The default resizer returns an error when one of its two buffers would be above 512 MiB, the limit of the image decoders. A 1 x 100,000 image is an example. A resizer set with with_resize has no limit.
  • ImageEmbedding::embed and embed_bytes hold one decoded image at a time, instead of the whole batch.
  • ImageEmbedding::embed decodes by the file extension first, and by the file content when that fails. A pipe is read once.
  • ImageEmbedding::embed_preprocessed and embed_images with an empty batch return an empty list, instead of an error.
  • The center crop puts the odd pixel of padding before an image that is smaller than the crop, as transformers does.
  • preprocessor_config.json accepts the processor names CLIPFeatureExtractor and ConvNextImageProcessor.
  • A user-defined preprocessor_config.json with resample 0, 1, or 2 resizes with the nearest, Lanczos, or bilinear filter that it names, instead of bicubic. The built-in models use bicubic, as before.
  • A session is built when the CPU core count cannot be read, and ONNX Runtime sizes the thread pool.
  • With ort-load-dynamic, a missing ONNX Runtime library returns an error, instead of a panic.
  • ExternalInitializerFile is exported from the crate root.
  • The descriptions of MxbaiEmbedLargeV1 and MxbaiEmbedLargeV1Q spell the vendor name Mixedbread.

Hugging Face Hub

  • A model load waits for a download of the same file that another thread or process has in progress, instead of a LockAcquisition error after five seconds (Bug(?) when running test suite #203). The load also waits through a pause of up to one minute in that download. With 16 loads at once on an empty cache, 7.7.0 returned the error to nine or ten of them.
  • A model loads in a process with no home directory, instead of a panic.
  • With HF_HOME set, the token that huggingface-cli login saved in HF_HOME is used.
  • An empty HF_ENDPOINT means the default endpoint, and a trailing slash is removed.
  • A failed model.safetensors download reports its own cause, next to the cause for the index file.
  • A shard name in model.safetensors.index.json that points outside the repository returns an error.
  • A tokenizer file that does not parse reports the parser's message.

candle models

  • BertTextEmbedding embeds RoBERTa, XLM-RoBERTa, and CamemBERT checkpoints with the position ids of that architecture. It used BERT position ids, which gave wrong vectors.
  • BertTextEmbedding loads checkpoints that name the LayerNorm tensors gamma and beta, such as google-bert/bert-base-uncased.
  • BertTextEmbedding reports a missing tensor under the name prefix that the file uses.
  • BertTextEmbedding caps max_length at the longest text that the position table holds, so long texts no longer fail.
  • NomicV2MoeTextEmbedding returns unit-length vectors with DType::F16 and DType::BF16 weights. The norms were up to 1.09.
  • NomicV2MoeTextEmbedding::new with a tokenizer that has no padding pads each batch, instead of rows that mix the tokens of two texts.
  • The Qwen3-VL patch merger uses exact GELU, as nn.GELU() in the reference model does.
  • Qwen3 configs written by transformers 5 load. They keep rope_theta and the MRoPE settings under rope_parameters.
  • Qwen/Qwen3-VL-Embedding-8B loads. Its text_config has no tie_word_embeddings.
  • A Qwen3 config that does not parse reports the missing field.
  • A Qwen3 model with equal head and key/value head counts runs a batch of more than one row, instead of an error.
  • On Metal, embed_padded runs one padded row, instead of an error. This path has a test that only the macOS CI job runs.
  • Qwen3TextEmbedding::new sets a tokenizer that pads to pad on the left. A tokenizer that padded on the right gave wrong vectors.
  • Qwen3TextEmbedding::embed_padded pads the rows itself for a tokenizer with no padding, and returns an error for rows of unequal length.
  • Qwen3VLEmbedding::embed_images runs with DType::BF16 weights on the CPU, instead of an error.
  • The Qwen3-VL image token limit counts the token that the tokenizer appends, so the prompt of an image at the limit is not cut.
  • Qwen3VLEmbedding accepts a max_length up to usize::MAX, instead of an overflow panic in a debug build.
  • Qwen3, Qwen3-VL, Nomic v2 MoE, and BERT return an error for a max_length below the special-token count.
  • Qwen3VLEmbedding::embed_images decodes by the file content when the extension fails.

Tests

  • The BGE-M3 test keeps the 7.7.0 tolerance for dense values, and uses wider ones for ColBERT values and sparse weights.
  • The Qwen3 GGUF test keeps the 7.7.0 bounds on x86 CPUs without VNNI, and uses wider ones for candle's VNNI kernels.
  • The text model test uses a wider tolerance for dynamically quantized models.
  • New reference tests compare BertTextEmbedding on a RoBERTa checkpoint with transformers, and the ClipVitB32 image vectors with fastembed for Python.
  • The BERT order test compares each vector of a batch with the vector of that text alone.
  • The user-defined model tests find the model files under HF_HOME when it is set.
  • test_rerank deletes its models only on CI, and waits while another test reads them.
  • New unit tests cover each change above that needs no model download.

Docs

  • The README examples embed plain texts. The query: and passage: prefixes belong to other models.
  • The README names the multilingual MiniLM model, says which Q variants are half precision, lists the candle-core and ort dependency lines, and uses the Qwen3 prompt format of the model card.
  • The README and the crate docs say that HF_HOME is the model cache directory itself.
  • The docs say that Qwen3TextEmbedding embeds a text as given, and that Qwen3VLEmbedding::embed_texts adds the prompt of the model card.
  • The crate docs name the image-models feature for ImageEmbedding, and docs.rs builds the bert-text feature.

CI

  • New lint rows compile bert-text and ort-load-dynamic on Linux, and a new test row runs the BERT tests.
  • The ONNX Runtime build is cached only when it finished.

@anush008 anush008 changed the title fix: Miscellaneous fix: harden edge cases across the ONNX and candle models, and repair CI Nov 16, 2026
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[High impact] The PR appears safe to merge.

Reviews (12) · Last reviewed commit: "fix: keep zero scores of either sign in ..." · Reviewed by Greptile

Comment thread src/common.rs Resolved
Comment thread src/reranking/impl.rs Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 10:01

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@greptile-apps

This comment has been minimized.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 12:30

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 12:37

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 13:02

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 15:48

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Comment thread src/image_embedding/utils.rs Resolved
Comment thread src/common.rs Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 16:45

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 17:01

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Comment thread src/similarity.rs Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 16, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 16, 2026 17:14

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@anush008
anush008 merged commit d76d093 into main Nov 16, 2026
24 of 26 checks passed
@anush008
anush008 deleted the mis-fixes branch November 16, 2026 17:33
github-actions Bot pushed a commit that referenced this pull request Nov 16, 2026
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 7.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant