Repository navigation
fix(cv): frame the SDXS prompt with CLIP's start and end tokens - #1635
Merged
barhanc merged 1 commit intoNov 12, 2026
Merged
Conversation
Tokenizer.encode adds no special tokens and the exported encode method feeds the ids straight into CLIP's token embedding, so the text encoder never saw <|startoftext|>, and prompts longer than 77 tokens lost <|endoftext|>. Build the ids like CLIPTokenizer: <|startoftext|>, at most 75 prompt ids, then <|endoftext|> padding up to 77.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
barhanc
self-requested a review
November 12, 2026 16:14
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
createSdxsTextToImagesends the prompt toencodewithout CLIP's<|startoftext|>(49406).Tokenizer.encodeadds no special tokens (see #1633), and the exportedencodemethod feeds the ids straight into the CLIP token embedding, so nothing adds it. Prompts longer than 77 tokens were also cut without<|endoftext|>.This PR builds the ids the way
CLIPTokenizerdoes:<|startoftext|>, at most 75 prompt ids, then<|endoftext|>padding up to 77. Two API tests pin the ids passed toencode.Introduces a breaking change?
Type of change
Tested on
Testing instructions
yarn workspace react-native-executorch test __tests__/tasks/remainingTasks.test.ts -t createSdxsTextToImageRelated issues
Checklist
Additional notes
I checked this against the published
sdxs_512_dreamshaper_xnnpack_int8.pte(v0.11.0) with the Python ExecuTorch runtime:encode, the token embedding reads the input ids directly (same memory as the method input, no concat), so the graph does not add the start token.IDKiro/sdxs-512-dreamshaper, theencodeoutput has cos 0.92–0.93 with the current ids and cos 1.000 with the fixed ids (4 prompts).CLIPTokenizer(padding="max_length", max_length=77, truncation=True), including a 120-token prompt.