diff --git a/.gitignore b/.gitignore index 7e6b9e44c..7061fae54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,16 @@ # defaults __pycache__ /params.txt +/cache.json -# all models +# all models and temp files *.ckpt *.safetensors *.pth *.pt *.bin *.optim +*.lock # all dynamic stuff /repositories/**/* diff --git a/README.md b/README.md index 864be07e0..752aa2cdf 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,9 @@ Fork adds extra functionality: Fork does differ in few things: -- Different start script +- Additional simplified start script > ./automatic.sh + Existing `webui.sh` still exists for fresh installs to auto-install dependencies, etc. - Drops compatibility with `python` **3.7** and requires **3.10** - Updated **Python** libraries to latest known compatible versions e.g. `accelerate`, `transformers`, `numpy`, etc. @@ -35,14 +36,10 @@ Fork does differ in few things: - Modified training templates Only Python library which is not auto-updated is `PyTorch` itself as that is very system specific -I'm currently using **PyTorch 2.0-nightly** compiled with **CUDA 11.8** and with **Triton** optimizations: +For some Torch optimizations notes, see Wiki -> pip3 install --pre torch torchvision torchaudio torchtriton --extra-index-url https://download.pytorch.org/whl/nightly/cu118 --force -> pip show torch -> 2.0.0.dev20230113+cu118 - -- Fork is compatible with regular **PyTorch 1.13**, - But if you're using **PyTorch 2.0** models will be auto-compiled and optimized on load using `max-tune` +Fork is compatible with regular **PyTorch 1.13** as well as pre-release of **PyTorch 2.0** +See [Wiki](https://github.com/vladmandic/automatic/wiki) for **Torch** optimization notes
diff --git a/TODO.md b/TODO.md index 0bffc5a3f..10a8e489b 100644 --- a/TODO.md +++ b/TODO.md @@ -32,9 +32,8 @@ Things I'm looking into... Stuff to be fixed... - Torch 2.0 model compile -- Add DeepSpeed support +- Add DeepSpeed support for training (`accelerate config`) - Reconnect WebUI -- Model reload performance Tech that can be integrated as part of the core workflow... diff --git a/automatic.sh b/automatic.sh index 8828fa55a..8e37f7b1a 100755 --- a/automatic.sh +++ b/automatic.sh @@ -4,5 +4,5 @@ export TF_CPP_MIN_LOG_LEVEL=2 export FORCE_CUDA="1" export ACCELERATE="True" export ATTN_PRECISION=fp16export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 -python launch.py --api --xformers --disable-console-progressbars +python launch.py --api --xformers --disable-console-progressbars # python launch.py --api --disable-console-progressbars --opt-channelslast diff --git a/cache.json.lock b/cache.json.lock deleted file mode 100755 index e69de29bb..000000000 diff --git a/config.json b/config.json deleted file mode 100644 index 2d7468bbd..000000000 --- a/config.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "samples_save": true, - "samples_format": "jpg", - "samples_filename_pattern": "", - "save_images_add_number": true, - "grid_save": true, - "grid_format": "jpg", - "grid_extended_filename": true, - "grid_only_if_multiple": true, - "grid_prevent_empty_spots": false, - "n_rows": -1, - "enable_pnginfo": true, - "save_txt": false, - "save_images_before_face_restoration": false, - "save_images_before_highres_fix": false, - "save_images_before_color_correction": false, - "jpeg_quality": 80, - "export_for_4chan": false, - "use_original_name_batch": true, - "use_upscaler_name_as_suffix": true, - "save_selected_only": true, - "do_not_add_watermark": true, - "temp_dir": "", - "clean_temp_dir_at_start": true, - "outdir_samples": "", - "outdir_txt2img_samples": "outputs/text", - "outdir_img2img_samples": "outputs/image", - "outdir_extras_samples": "outputs/extras", - "outdir_grids": "", - "outdir_txt2img_grids": "outputs/grids", - "outdir_img2img_grids": "outputs/grids", - "outdir_save": "outputs/save", - "save_to_dirs": false, - "grid_save_to_dirs": false, - "use_save_to_dirs_for_ui": false, - "directories_filename_pattern": "", - "directories_max_prompt_words": 16, - "ESRGAN_tile": 192, - "ESRGAN_tile_overlap": 8, - "realesrgan_enabled_models": [ - "R-ESRGAN 4x+" - ], - "upscaler_for_img2img": "SwinIR_4x", - "use_scale_latent_for_hires_fix": false, - "face_restoration_model": "CodeFormer", - "code_former_weight": 0.15, - "face_restoration_unload": false, - "memmon_poll_rate": 1, - "samples_log_stdout": false, - "multiple_tqdm": true, - "unload_models_when_training": false, - "pin_memory": true, - "save_optimizer_state": false, - "dataset_filename_word_regex": "", - "dataset_filename_join_string": " ", - "training_image_repeats_per_epoch": 1, - "training_write_csv_every": 10.0, - "training_xattention_optimizations": false, - "sd_model_checkpoint": "db-analog-diffusion-v10.ckpt", - "sd_checkpoint_cache": 0, - "sd_vae": "vae-ft-mse-840000-ema-pruned.ckpt", - "sd_vae_as_default": false, - "sd_hypernetwork": "None", - "sd_hypernetwork_strength": 1.0, - "inpainting_mask_weight": 1.0, - "initial_noise_multiplier": 1.0, - "img2img_color_correction": false, - "img2img_fix_steps": false, - "img2img_background_color": "#ffffff", - "enable_quantization": true, - "enable_emphasis": true, - "use_old_emphasis_implementation": false, - "enable_batch_seeds": true, - "comma_padding_backtrack": 20, - "CLIP_stop_at_last_layers": 1, - "random_artist_categories": [], - "interrogate_keep_models_in_memory": false, - "interrogate_use_builtin_artists": false, - "interrogate_return_ranks": true, - "interrogate_clip_num_beams": 1, - "interrogate_clip_min_length": 32, - "interrogate_clip_max_length": 1024, - "interrogate_clip_dict_limit": 0.0, - "interrogate_deepbooru_score_threshold": 0.7, - "deepbooru_sort_alpha": false, - "deepbooru_use_spaces": false, - "deepbooru_escape": true, - "deepbooru_filter_tags": "", - "show_progressbar": true, - "show_progress_every_n_steps": -1, - "show_progress_type": "Full", - "show_progress_grid": true, - "return_grid": true, - "do_not_show_images": false, - "add_model_hash_to_info": true, - "add_model_name_to_info": true, - "disable_weights_auto_swap": false, - "send_seed": true, - "send_size": true, - "font": "", - "js_modal_lightbox": true, - "js_modal_lightbox_initially_zoomed": true, - "show_progress_in_title": true, - "quicksettings": "sd_model_checkpoint", - "localization": "None", - "hide_samplers": [ - "Euler", - "LMS", - "Heun", - "DPM2", - "DPM2 a", - "DPM++ 2M", - "DPM fast", - "DPM adaptive", - "DPM++ 2S a Karras", - "DDIM", - "PLMS", - "DPM++ 2S a", - "DPM++ SDE Karras", - "DPM2 a Karras" - ], - "eta_ddim": 0.0, - "eta_ancestral": 1.0, - "ddim_discretize": "uniform", - "s_churn": 0.0, - "s_tmin": 0.0, - "s_noise": 1.0, - "eta_noise_seed_delta": 0, - "disabled_extensions": [ - "sdweb-merge-board", - "roll-artist" - ], - "ldsr_steps": 100, - "ldsr_cached": false, - "SWIN_tile": 192, - "SWIN_tile_overlap": 8, - "inspiration_max_samples": 20, - "inspiration_rows_num": 16, - "inspiration_cols_num": 6, - "images_history_preload": false, - "images_record_paths": true, - "images_delete_message": true, - "images_history_page_columns": 6.0, - "images_history_page_rows": 20.0, - "images_history_pages_perload": 20.0, - "sd_vae_checkpoint_cache": 0, - "use_old_karras_scheduler_sigmas": false, - "samplers_in_dropdown": true, - "aesthetic_scorer_enabled": false, - "aesthetic_scorer_clip_model": "ViT-L/14", - "dimensions_and_batch_together": true, - "ui_reorder": "sampler, dimensions, cfg, seed, checkboxes, hires_fix, batch, scripts", - "always_discard_next_to_last_sigma": false, - "clip_models_path": "models/CLIP", - "save_training_settings_to_txt": true, - "use_old_hires_fix_width_height": false, - "training_enable_tensorboard": true, - "training_tensorboard_save_images": true, - "training_tensorboard_flush_every": 60.0, - "sd_checkpoint_hash": "93715dbf32da7b9b97310a805118766eddd89f25464b453f501c06801816447a", - "print_hypernet_extra": false, - "live_previews_enable": true, - "live_preview_content": "Prompt" -} \ No newline at end of file diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 57fb8466f..9b664c735 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -103,14 +103,19 @@ class StableDiffusionModelHijack: m.cond_stage_model.model.token_embedding = EmbeddingsWithFixes(m.cond_stage_model.model.token_embedding, self) m.cond_stage_model = sd_hijack_open_clip.FrozenOpenCLIPEmbedderWithCustomWords(m.cond_stage_model, self) + """ try: import time t0 = time.time() - m = torch.compile(m, mode="max-autotune", fullgraph=True) + torch._dynamo.config.verbose = True + torch.backends.cudnn.benchmark = True + m.model = torch.compile(m.model, mode="max-autotune", fullgraph=False) + m = torch.compile(m, mode="max-autotune", fullgraph=False) t1 = time.time() print(f"Model compiled in {round(t1 - t0, 2)} sec") except Exception as err: print(f"Model compile not supported: {err}") + """ self.optimization_method = apply_optimizations() diff --git a/wiki b/wiki index eb3403bf6..cf916fd3a 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit eb3403bf6e4355ca597d0f6a17c2142974b39267 +Subproject commit cf916fd3ada302a18214b65c7992c7fa98901d67