Skip to content

reject invalid float indices before conversion - #59

Merged
CanReader merged 1 commit into
CanReader:masterfrom
Boulea7:fix/float-index-validation-20261015
Oct 15, 2026
Merged

CanReader merged 1 commit into
CanReader:masterfrom
Boulea7:fix/float-index-validation-20261015

Conversation

@Boulea7

@Boulea7 Boulea7 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

What this changes

Embedding::forward and Batch::labels now reject negative, non-finite, fractional, and out-of-range float IDs before converting them to usize. Both use the same small helper, and the panic names the invalid value; valid IDs, including negative zero, keep their existing behavior.

Why

The previous cast silently turned -1 and NaN into index 0 and truncated fractional IDs. Fixes #46.

How it was verified

The six public-API regressions produced four passes and two failures on the unchanged base, then all six passed with the fix. They cover both consumers, the offending value in the panic, valid IDs, and the usize boundary.

  • cargo test --locked --offline passes
  • cargo clippy --locked --offline --all-targets -- -D warnings is clean
  • cargo fmt --check passes
  • No GPU here, CUDA side not runtime tested

Run on Linux with Rust 1.99. MSRV 1.87, release mode, and other operating systems were not run locally.

Checklist

  • Public items have /// docs
  • No backward rule, kernel, or public API was added.

@Boulea7
Boulea7 requested a review from CanReader as a code owner October 15, 2026 16:12
@CanReader
CanReader merged commit 2200cb0 into CanReader:master Oct 15, 2026
12 checks passed
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.

Embedding::forward and Batch::labels turn bad ids into index 0

2 participants