markury commited on
Commit
2803974
1 Parent(s): 3dc245f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +245 -0
README.md ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config.env
2
+ ```
3
+ # Configure these values.
4
+
5
+ # 'lora' or 'full'
6
+ # lora - train a small network for a character or style, or both. quite versatile.
7
+ # full - requires lots of vram, trains very slowly, needs a lot of data and concepts.
8
+ export MODEL_TYPE='lora'
9
+
10
+ # Set this to 'true' if you are training a Stable Diffusion 3 checkpoint.
11
+ # Use MODEL_NAME="stabilityai/stable-diffusion-3-medium-diffusers"
12
+ export STABLE_DIFFUSION_3=false
13
+ # Similarly, this is to train PixArt Sigma (1K or 2K) models.
14
+ # Use MODEL_NAME="PixArt-alpha/PixArt-Sigma-XL-2-1024-MS"
15
+ export PIXART_SIGMA=false
16
+ # For old Stable Diffusion 1.x/2.x models, you'll enable this.
17
+ # Use MODEL_NAME="stabilityai/stable-diffusion-2-1"
18
+ export STABLE_DIFFUSION_LEGACY=false
19
+ # For Kwai-Kolors, enable KOLORS.
20
+ # Use MODEL_NAME="kwai-kolors/kolors-diffusers"
21
+ export KOLORS=false
22
+ # For Flux, if you have 8 GPUs and DeepSpeed configured.
23
+ # Use MODEL_NAME="black-forest-labs/FLUX.1-dev"
24
+ export FLUX=true
25
+
26
+ # ControlNet model training is only supported when MODEL_TYPE='full'
27
+ # See this document for more information: https://github.com/bghira/SimpleTuner/blob/main/documentation/CONTROLNET.md
28
+ # DeepFloyd, PixArt, and SD3 do not currently support ControlNet model training.
29
+ export CONTROLNET=false
30
+
31
+ # DoRA enhances the training style of LoRA, but it will run more slowly at the same rank.
32
+ # See: https://arxiv.org/abs/2402.09353
33
+ # See: https://github.com/huggingface/peft/pull/1474
34
+ export USE_DORA=true
35
+
36
+ # BitFit freeze strategy for the u-net causes everything but the biases to be frozen.
37
+ # This may help retain the full model's underlying capabilities. LoRA is currently not tested/known to work.
38
+ #if [[ "$MODEL_TYPE" == "full" ]]; then
39
+ # # When training a full model, we will rely on BitFit to keep the u-net intact.
40
+ # export USE_BITFIT=true
41
+ #elif [[ "$MODEL_TYPE" == "lora" ]]; then
42
+ # # LoRA can not use BitFit.
43
+ # export USE_BITFIT=false
44
+ #elif [[ "$MODEL_TYPE" == "deepfloyd-full" ]]; then
45
+ # export USE_BITFIT=true
46
+ #fi
47
+
48
+ # Restart where we left off. Change this to "checkpoint-1234" to start from a specific checkpoint.
49
+ export RESUME_CHECKPOINT="latest"
50
+
51
+ # How often to checkpoint. Depending on your learning rate, you may wish to change this.
52
+ # For the default settings with 10 gradient accumulations, more frequent checkpoints might be preferable at first.
53
+ export CHECKPOINTING_STEPS=100
54
+ # This is how many checkpoints we will keep. Two is safe, but three is safer.
55
+ export CHECKPOINTING_LIMIT=3
56
+
57
+ # This is decided as a relatively conservative 'constant' learning rate.
58
+ # Adjust higher or lower depending on how burnt your model becomes.
59
+ # export LEARNING_RATE=8e-7 #@param {type:"number"}
60
+ export LEARNING_RATE=2e-5 #@param {type:"number"}
61
+ # For Prodigy
62
+ # export LEARNING_RATE=1.0 #@param {type:"number"}
63
+
64
+ # Using a Huggingface Hub model:
65
+ export MODEL_NAME="black-forest-labs/FLUX.1-dev"
66
+ # Using a local path to a huggingface hub model or saved checkpoint:
67
+ #export MODEL_NAME="/datasets/models/pipeline"
68
+
69
+ # Make DEBUG_EXTRA_ARGS empty to disable wandb.
70
+ export DEBUG_EXTRA_ARGS="--report_to=wandb"
71
+ export TRACKER_PROJECT_NAME="AndroFlux-v6-DoRA"
72
+ export TRACKER_RUN_NAME="simpletuner-androflux-v6"
73
+
74
+ # Max number of steps OR epochs can be used. Not both.
75
+ export MAX_NUM_STEPS=10000
76
+ # Will likely overtrain, but that's fine.
77
+ export NUM_EPOCHS=0
78
+
79
+ # A convenient prefix for all of your training paths.
80
+ # These may be absolute or relative paths. Here, we are using relative paths.
81
+ # The output will just be in a folder called "output/models" by default.
82
+ export DATALOADER_CONFIG="config/multidatabackend.json"
83
+ export OUTPUT_DIR="output/models"
84
+
85
+ # Set this to "true" to push your model to Hugging Face Hub.
86
+ export PUSH_TO_HUB="true"
87
+ # If PUSH_TO_HUB and PUSH_CHECKPOINTS are both enabled, every saved checkpoint will be pushed to Hugging Face Hub.
88
+ export PUSH_CHECKPOINTS="true"
89
+ # This will be the model name for your final hub upload, eg. "yourusername/yourmodelname"
90
+ # It defaults to the wandb project name, but you can override this here.
91
+ export HUB_MODEL_NAME=$TRACKER_PROJECT_NAME
92
+
93
+ # By default, images will be resized so their SMALLER EDGE is 1024 pixels, maintaining aspect ratio.
94
+ # Setting this value to 768px might result in more reasonable training data sizes for SDXL.
95
+ export RESOLUTION=1024
96
+ # If you want to have the training data resized by pixel area (Megapixels) rather than edge length,
97
+ # set this value to "area" instead of "pixel", and uncomment the next RESOLUTION declaration.
98
+ export RESOLUTION_TYPE="pixel"
99
+ #export RESOLUTION=1 # 1.0 Megapixel training sizes
100
+ # If RESOLUTION_TYPE="pixel", the minimum resolution specifies the smaller edge length, measured in pixels. Recommended: 1024.
101
+ # If RESOLUTION_TYPE="area", the minimum resolution specifies the total image area, measured in megapixels. Recommended: 1.
102
+ export MINIMUM_RESOLUTION=$RESOLUTION
103
+
104
+ # How many decimals to round aspect buckets to.
105
+ #export ASPECT_BUCKET_ROUNDING=2
106
+
107
+ # Use this to append an instance prompt to each caption, used for adding trigger words.
108
+ # This has not been tested in SDXL.
109
+ #export INSTANCE_PROMPT="lotr style "
110
+ # If you also supply a user prompt library or `--use_prompt_library`, this will be added to those lists.
111
+ export VALIDATION_PROMPT="a full-body photo of a man"
112
+ export VALIDATION_GUIDANCE=3.5
113
+ # You'll want to set this to 0.7 if you are training a terminal SNR model.
114
+ export VALIDATION_GUIDANCE_RESCALE=0.0
115
+ # How frequently we will save and run a pipeline for validations.
116
+ export VALIDATION_STEPS=100
117
+ export VALIDATION_NUM_INFERENCE_STEPS=30
118
+ export VALIDATION_NEGATIVE_PROMPT="blurry, cropped, ugly"
119
+ export VALIDATION_SEED=42
120
+ export VALIDATION_RESOLUTION=$RESOLUTION
121
+
122
+
123
+ # Adjust this for your GPU memory size. This, and resolution, are the biggest VRAM killers.
124
+ export TRAIN_BATCH_SIZE=1
125
+ # Accumulate your update gradient over many steps, to save VRAM while still having higher effective batch size:
126
+ # effective batch size = ($TRAIN_BATCH_SIZE * $GRADIENT_ACCUMULATION_STEPS).
127
+ export GRADIENT_ACCUMULATION_STEPS=1
128
+
129
+ # Use any standard scheduler type. constant, polynomial, constant_with_warmup
130
+ export LR_SCHEDULE="sine"
131
+ # A warmup period allows the model and the EMA weights more importantly to familiarise itself with the current quanta.
132
+ # For the cosine or sine type schedules, the warmup period defines the interval between peaks or valleys.
133
+ # Use a sine schedule to simulate a warmup period, or a Cosine period to simulate a polynomial start.
134
+ # export LR_WARMUP_STEPS=$((MAX_NUM_STEPS / 10))
135
+ # export LR_WARMUP_STEPS=2000
136
+
137
+ # Caption dropout probability. Set to 0.1 for 10% of captions dropped out. Set to 0 to disable.
138
+ # You may wish to disable dropout if you want to limit your changes strictly to the prompts you show the model.
139
+ # You may wish to increase the rate of dropout if you want to more broadly adopt your changes across the model.
140
+ export CAPTION_DROPOUT_PROBABILITY=0.1
141
+
142
+ export METADATA_UPDATE_INTERVAL=65
143
+
144
+ # How many workers to use for VAE caching.
145
+ export MAX_WORKERS=32
146
+ # Read and write batch sizes for VAE caching.
147
+ export READ_BATCH_SIZE=25
148
+ export WRITE_BATCH_SIZE=64
149
+ # How many images to encode at once with the VAE. Can increase VRAM use.
150
+ export VAE_BATCH_SIZE=12
151
+ # How many images to process at once (resize, crop, transform) during VAE caching.
152
+ export IMAGE_PROCESSING_BATCH_SIZE=32
153
+ # When using large batch sizes, you'll need to increase the pool connection limit.
154
+ export AWS_MAX_POOL_CONNECTIONS=128
155
+ # For very large systems, setting this can reduce CPU overhead of torch spawning an unnecessarily large number of threads.
156
+ export TORCH_NUM_THREADS=8
157
+
158
+ # If this is set, any images that fail to open will be DELETED to avoid re-checking them every time.
159
+ export DELETE_ERRORED_IMAGES=0
160
+ # If this is set, any images that are too small for the minimum resolution size will be DELETED.
161
+ export DELETE_SMALL_IMAGES=0
162
+
163
+ # Bytedance recommends these be set to "trailing" so that inference and training behave in a more congruent manner.
164
+ # To follow the original SDXL training strategy, use "leading" instead, though results are generally worse.
165
+ export TRAINING_SCHEDULER_TIMESTEP_SPACING="trailing"
166
+ export INFERENCE_SCHEDULER_TIMESTEP_SPACING="trailing"
167
+
168
+ # Removing this option or unsetting it uses vanilla training. Setting it reweights the loss by the position of the timestep in the noise schedule.
169
+ # A value "5" is recommended by the researchers. A value of "20" is the least impact, and "1" is the most impact.
170
+ export MIN_SNR_GAMMA=5
171
+
172
+ # Set this to an explicit value of "false" to disable Xformers. Probably required for AMD users.
173
+ export USE_XFORMERS=false
174
+
175
+ # There's basically no reason to unset this. However, to disable it, use an explicit value of "false".
176
+ # This will save a lot of memory consumption when enabled.
177
+ export USE_GRADIENT_CHECKPOINTING=true
178
+
179
+ ##
180
+ # Options below here may require a bit more complicated configuration, so they are not simple variables.
181
+ ##
182
+
183
+ # TF32 is great on Ampere or Ada, not sure about earlier generations.
184
+ export ALLOW_TF32=true
185
+ # AdamW 8Bit is a robust and lightweight choice. Adafactor might reduce memory consumption, and Dadaptation is slow and experimental.
186
+ # AdamW is the default optimizer, but it uses a lot of memory and is slower than AdamW8Bit or Adafactor.
187
+ # When training a quantised base model, you can't use adamw_bf16. Instead, try adafactor or adamw.
188
+ # Choices: adamw, adamw8bit, adafactor, dadaptation, adamw_bf16
189
+ # export OPTIMIZER="prodigy"
190
+ export OPTIMIZER="adamw_bf16"
191
+
192
+
193
+ # EMA is a strong regularisation method that uses a lot of extra VRAM to hold two copies of the weights.
194
+ # This is worthwhile on large training runs, but not so much for smaller training runs.
195
+ export USE_EMA=false
196
+ export EMA_DECAY=0.999
197
+
198
+ # export TRAINER_EXTRA_ARGS="--base_model_precision=int8-quanto --i_know_what_i_am_doing"
199
+ # export TRAINER_EXTRA_ARGS="--base_model_precision=int8-quanto --base_model_default_dtype=fp32"
200
+ # export TRAINER_EXTRA_ARGS=""
201
+ ## For offset noise training:
202
+ # Not recommended for terminal SNR models.
203
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --offset_noise --noise_offset=0.02"
204
+
205
+ ## For terminal SNR training:
206
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --prediction_type=v_prediction --rescale_betas_zero_snr"
207
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --training_scheduler_timestep_spacing=trailing --inference_scheduler_timestep_spacing=trailing"
208
+ ## You may benefit from directing training toward a specific weighted subset of timesteps.
209
+ # In this example, we train the final 25% of the timestep schedule with a 3x bias.
210
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --timestep_bias_strategy=later --timestep_bias_portion=0.25 --timestep_bias_multiplier=3"
211
+ # In this example, we train the earliest 25% of the timestep schedule with a 5x bias.
212
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --timestep_bias_strategy=earlier --timestep_bias_portion=0.25 --timestep_bias_multiplier=5"
213
+ # Here, we designate that specifically, timesteps 200 to 500 should be prioritised.
214
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --timestep_bias_strategy=range --timestep_bias_begin=200 --timestep_bias_end=500 --timestep_bias_multiplier=3"
215
+
216
+ ## For experimental min-SNR weighted loss training (5 is suggested value by the original researchers):
217
+ # Not recommended for terminal SNR models.
218
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --snr_gamma=5.0"
219
+
220
+ # For Wasabi S3 filesystem backend (experimental)
221
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --data_backend=aws --aws_bucket_name=test123"
222
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --aws_endpoint_url=https://s3.wasabisys.com"
223
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --aws_access_key=1234567890"
224
+ #export TRAINER_EXTRA_ARGS="${TRAINER_EXTRA_ARGS} --aws_secret_access_key=0987654321"
225
+
226
+
227
+ # Reproducible training. Set to -1 to disable.
228
+ export TRAINING_SEED=42
229
+
230
+ # Mixed precision is the best. You honestly might need to YOLO it in fp16 mode for Google Colab type setups.
231
+ export MIXED_PRECISION="bf16" # Might not be supported on all GPUs. fp32 will be needed for others.
232
+ export PURE_BF16=true
233
+
234
+ # This has to be changed if you're training with multiple GPUs.
235
+ export TRAINING_NUM_PROCESSES=1
236
+ export TRAINING_NUM_MACHINES=1
237
+ export ACCELERATE_EXTRA_ARGS="" # --multi_gpu or other similar flags for huggingface accelerate
238
+
239
+ # With Pytorch 2.1, you might have pretty good luck here.
240
+ # If you're using aspect bucketing however, each resolution change will recompile. Seriously, just don't do it.
241
+ # Well, then again... Pytorch 2.2 has support for dynamic shapes. Why not?
242
+ export TRAINING_DYNAMO_BACKEND='no' # or 'no' if you want to disable torch compile in case of performance issues or lack of support (eg. AMD)
243
+
244
+ export TOKENIZERS_PARALLELISM=false
245
+ ```