Skip to content

Conversation

@bghira
Copy link
Owner

@bghira bghira commented Jan 29, 2026

Closes #2510

This pull request refactors how conditioning datasets are handled and routed during training, especially for edit models and loss masking. The main improvements are a clearer separation of reference and mask/segmentation conditioning types, more robust validation for Qwen edit models, and consistent use of a new loss_mask_type field throughout the codebase. This enhances flexibility and correctness when working with multiple conditioning datasets.

Key changes include:

Conditioning Dataset Handling & Routing:

  • Refactored the collate logic in simpletuner/helpers/training/collate.py to distinguish between reference conditioning types (reference_strict, reference_loose) and mask/segmentation types (mask, segmentation). This allows separate routing for model input (reference) and loss masking (mask/segmentation), supporting more complex dataset setups. [1] [2] [3] [4] [5]
  • Added new fields conditioning_type and loss_mask_type to the prepared batch output, making the distinction explicit for downstream code. [1] [2]

Qwen Edit Model Validation:

  • Updated Qwen edit model validation to require at least one reference conditioning dataset, instead of enforcing that all conditioning datasets be of reference type. This allows additional mask/segmentation datasets for loss masking, improving flexibility and correctness. [1] [2]

Loss Masking Logic:

  • Standardized all model and loss functions to use loss_mask_type instead of conditioning_type when applying mask/segmentation-based loss masking, ensuring consistent behavior across models. [1] [2] [3] [4] [5] [6]

This comment was marked as resolved.

@bghira bghira merged commit 1a19e7d into main Jan 29, 2026
2 checks passed
@bghira bghira deleted the bugfix/mask-conditioning-on-edit-models branch January 29, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] image mask training with Edit models (e.g. Flux2 Klein)

2 participants