feat: Add support for Safetensors format in caching strategies#2290
Draft
feat: Add support for Safetensors format in caching strategies#2290
Conversation
- Introduced Safetensors output format for various caching strategies including Hunyuan, Lumina, SD, SDXL, and SD3. - Updated methods to handle loading and saving of tensors in Safetensors format. - Enhanced output validation to check for required tensors in both NPZ and Safetensors formats. - Modified dataset argument parser to include `--cache_format` option for selecting between NPZ and Safetensors formats. - Updated caching logic to accommodate partial loading and merging of existing Safetensors files.
duongve13112002
added a commit
to duongve13112002/sd-scripts
that referenced
this pull request
Apr 15, 2026
… support Merges kohya-ss#2290 (safetensors cache format) and resolves conflicts with multi-caption caching feature. Both features now work together in all 6 model strategies: - load_outputs_npz(): safetensors/npz branch + ndim-based multi-caption random selection applied after loading from either format - cache_batch_outputs(): per-image loop (multi-caption) with safetensors/npz format branching for disk cache - _save_outputs_safetensors(): per-image safetensors save with stacked arrays support for multi-caption Affected strategies: Lumina, Flux, Anima, SDXL, SD3, HunyuanImage Also includes PR kohya-ss#2290 changes to strategy_base.py, strategy_sd.py, train_util.py, and tools/*. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
--cache_formatoption for selecting between NPZ and Safetensors formats.