Repository navigation
fix(llm): fall back to sampling defaults for options passed as undefined - #1611
Merged
msluszniak merged 1 commit intoNov 5, 2026
Merged
msluszniak merged 1 commit into
msluszniak merged 1 commit into
Conversation
msluszniak
approved these changes
Nov 5, 2026
msluszniak
left a comment
Member
There was a problem hiding this comment.
LGTM. @barhanc could you also check? I'm doing the analogical PR for other places that are affected by this problem.
5 of 12 tasks
msluszniak
added a commit
that referenced
this pull request
Nov 5, 2026
## Description Same bug as #1610 in three more places: an option passed as `undefined` replaced its default. - `normalize`: native throws `INVALID_ARGUMENT`. - VAD `detectVoice`: thresholds become `NaN`, silently returns no segments. - Chat session per-turn `genConfig`: drops the session default (e.g. `maxNewTokens` becomes unlimited). ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [x] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions - `yarn workspace react-native-executorch test __tests__/extensions/normalize.test.ts __tests__/tasks/remainingTasks.test.ts __tests__/tasks/llmChatSession.test.ts` - The three new tests fail without the `src/` changes. ### Screenshots ### Related issues #1610, sampler part fixed in #1611. ### Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [x] My changes generate no new warnings ### Additional notes
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.
Description
sample()merged the caller's config over the defaults with an object spread, so an option passed asundefined(for example{ temperature: settings.temperature }where the setting is unset) replaced its default withundefined. The native sampler reads these options as required numbers and throwsINVALID_ARGUMENT, which failsgenerateand chat sessions on every LLM.This change resolves each default with
??, for the top-level options and for thedryandxtcsub-configs, so anundefinedfield behaves like an omitted one. A fake-runtime test covers the case.Introduces a breaking change?
Type of change
Tested on
TypeScript-only change, verified with the fake-runtime API tests. Not run on a device.
Testing instructions
yarn workspace react-native-executorch test __tests__/extensions/sampler.test.tsfalls back to the defaults for options passed as undefinedpasses. Without the change tosampler.ts, it fails becausetemperature,topK,topP,minP,repetitionPenalty,penaltyLastN, and thedry/xtcdefaults reach the native call asundefined.Screenshots
Not applicable.
Related issues
Fixes #1610
Checklist
Additional notes
The native side reads these options with
getRequiredPropertyincpp/extensions/llm/sampler.cpp, which accepts a missing key only through the TypeScript defaults. Documentation needs no update, since the documented defaults are unchanged.