Thanks to visit codestin.com
Credit goes to github.com

Skip to content

strip padding from text latent cache for Ernie#1520

Merged
dxqb merged 1 commit into
Nerogar:mergefrom
dxqb:ernie-prune-pad-tokens
Jun 17, 2026
Merged

strip padding from text latent cache for Ernie#1520
dxqb merged 1 commit into
Nerogar:mergefrom
dxqb:ernie-prune-pad-tokens

Conversation

@dxqb

@dxqb dxqb commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

implements #1345 by @BitcrushedHeart for Ernie
I probably missed it because the Ernie implementation was based on Flux2 - and pruning isn't possible for Flux2. It is possible for Ernie

Test plan

  • pre-commit run --all-files passes
  • Launched the affected UI or script and exercised the change
  • Tested with at least one real preset / config when relevant (note which: Ernie)

AI assistance

  • AI-assisted — I have read every line in this diff and can defend each change

Ernie's text encoder hidden state is truncated per-batch to the longest
prompt (variable length, not a fixed sequence length like Flux2), so it
benefits from the same PruneMaskedTokens/PadMaskedTokens pattern as
QwenBaseDataLoader to keep the disk cache compact.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@dxqb dxqb added the preview merged in the preview branch label Jun 14, 2026
dxqb added a commit that referenced this pull request Jun 14, 2026
@dxqb dxqb changed the base branch from master to merge June 17, 2026 20:09
@dxqb dxqb merged commit d9edbec into Nerogar:merge Jun 17, 2026
1 check passed
@dxqb dxqb deleted the ernie-prune-pad-tokens branch June 17, 2026 20:09
dxqb added a commit to dxqb/OneTrainer that referenced this pull request Jun 19, 2026
Mirrors Nerogar#1520 (Ernie): tokens_mask/text_encoder_hidden_state are fixed
at PROMPT_MAX_LENGTH after EncodeLensText's crop, so caching wastes
disk space on padding for shorter prompts. Prune before caching, pad
back to PROMPT_MAX_LENGTH on load.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview merged in the preview branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant