Repository navigation
fix(vm-ranker): keep non-finite scores from panicking ranking sorts - #258
Open
davidchung29 wants to merge 2 commits into
Open
davidchung29 wants to merge 2 commits into
davidchung29 wants to merge 2 commits into
Conversation
davidchung29
force-pushed
the
fix/vm-ranker-nan-score-ordering
branch
from
October 19, 2026 18:44
44fa5a5 to
9c7191f
Compare
davidchung29
marked this pull request as ready for review
October 20, 2026 14:06
mangeshraut712
left a comment
There was a problem hiding this comment.
Reviewed the total order implementation in score_order.rs and the integration across vm-ranker and xai-value-model.
compare_scores_desccorrectly defines a strict weak ordering: finite scores are compared viab.partial_cmp(&a)(descending), non-finite scores (NaN,±Inf) all evaluate as equal to each other, and finite scores strictly precede non-finite scores. This satisfies transitivity of both strict ordering and equivalence, eliminating the panic inslice::sort_by/sort_unstable_by.- In
dpp.rs, filteringinputs[i].score.is_finite()up front before slicingtop_indicesensures that non-finite scores cannot occupy a slot in the DPP candidate pool wheninputs.len() < max_selected_rank. - The comprehensive transitivity matrix test across
[f64::MIN, -1.0, -0.0, 0.0, 1.0, f64::MAX, f64::NAN, -f64::NAN, f64::INFINITY, f64::NEG_INFINITY]gives solid regression protection.
Looks solid and ready.
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.
Closes #253.
TL;DR: In
vm-ranker, the service that scores and diversifies For You candidates before home-mixer's selector, oneNaNscore can crash the request. This fixes its ranking sorts and the sharedauthor_pool_countssort inxai-value-modelso invalid scores are handled safely.Bug: vm-ranker's sorts treat
NaNas equal to every number, which isn't a consistent ordering, so Rust's sort can panic and fail the whole request before it reaches the selector fixed in #204.Fix: Add
compare_scores_desc, which sorts real scores high to low and putsNaN/±inflast, and use it inauthor_pool_counts, DPP, and the ranker-service debug sort. Normal scores sort the same as before. DPP also now leaves non-finite scores out of its candidate pool, so a+infscore can't take over selection when the pool has spare room. With the #253 repro harness, these sorts no longer panic onNaNinput, and new unit tests cover the crash case. Prepared with AI assistance.