fusion-bench 0.2.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fusion_bench/__init__.py +20 -0
- fusion_bench/__main__.py +4 -0
- fusion_bench/compat/__init__.py +0 -0
- fusion_bench/compat/method/__init__.py +109 -0
- fusion_bench/compat/method/base_algorithm.py +58 -0
- fusion_bench/compat/modelpool/AutoModelForSeq2SeqLM.py +34 -0
- fusion_bench/compat/modelpool/__init__.py +116 -0
- fusion_bench/compat/modelpool/base_pool.py +328 -0
- fusion_bench/compat/modelpool/huggingface_clip_vision.py +178 -0
- fusion_bench/compat/taskpool/__init__.py +95 -0
- fusion_bench/compat/taskpool/base_pool.py +111 -0
- fusion_bench/compat/taskpool/clip_image_classification.py +210 -0
- fusion_bench/compat/taskpool/flan_t5_glue_text_generation.py +175 -0
- fusion_bench/constants/__init__.py +2 -0
- fusion_bench/constants/paths.py +18 -0
- fusion_bench/dataset/__init__.py +29 -0
- fusion_bench/dataset/arc_agi/__init__.py +6 -0
- fusion_bench/dataset/arc_agi/arc.py +308 -0
- fusion_bench/dataset/arc_agi/arc_agi.py +365 -0
- fusion_bench/dataset/arc_agi/augmenters.py +1036 -0
- fusion_bench/dataset/arc_agi/messagers.py +1355 -0
- fusion_bench/dataset/arc_agi/np_cache.py +168 -0
- fusion_bench/dataset/arc_agi/preprocess.py +298 -0
- fusion_bench/dataset/arc_agi/representers.py +1019 -0
- fusion_bench/dataset/clip_dataset.py +71 -0
- fusion_bench/dataset/fer2013.py +12 -0
- fusion_bench/dataset/gpt2_glue.py +300 -0
- fusion_bench/dataset/gsm8k.py +60 -0
- fusion_bench/dataset/image_dataset.py +55 -0
- fusion_bench/dataset/imdb.py +11 -0
- fusion_bench/dataset/llama/__init__.py +1 -0
- fusion_bench/dataset/llama/alpaca.py +232 -0
- fusion_bench/dataset/llama/collate.py +120 -0
- fusion_bench/dataset/llama/metamathqa.py +50 -0
- fusion_bench/dataset/llama/openai.py +160 -0
- fusion_bench/dataset/llama/preference_700k.py +70 -0
- fusion_bench/dataset/llama/sharegpt.py +141 -0
- fusion_bench/dataset/llama/squad.py +125 -0
- fusion_bench/dataset/llama/stanford_shp.py +90 -0
- fusion_bench/dataset/llama/ultrachat.py +58 -0
- fusion_bench/dataset/llama/utils/__init__.py +0 -0
- fusion_bench/dataset/llama/wikitext.py +89 -0
- fusion_bench/dataset/nyuv2.py +119 -0
- fusion_bench/method/__init__.py +177 -0
- fusion_bench/method/ada_svd/__init__.py +2 -0
- fusion_bench/method/ada_svd/clip_vision.py +319 -0
- fusion_bench/method/adamerging/__init__.py +6 -0
- fusion_bench/method/adamerging/clip_layer_wise_adamerging.py +46 -0
- fusion_bench/method/adamerging/clip_task_wise_adamerging.py +187 -0
- fusion_bench/method/adamerging/entropy_loss.py +25 -0
- fusion_bench/method/adamerging/flan_t5_layer_wise_adamerging.py +332 -0
- fusion_bench/method/adamerging/gpt2_layer_wise_adamerging.py +351 -0
- fusion_bench/method/adamerging/layer_wise_adamerging.py +252 -0
- fusion_bench/method/adamerging/llama_adamerging.py +335 -0
- fusion_bench/method/adamerging/min_norm_solvers.py +227 -0
- fusion_bench/method/adamerging/task_wise_adamerging.py +174 -0
- fusion_bench/method/adamerging/utils.py +15 -0
- fusion_bench/method/analysis/__init__.py +2 -0
- fusion_bench/method/analysis/task_vector_cos_similarity.py +172 -0
- fusion_bench/method/analysis/task_vector_violin_plot.py +205 -0
- fusion_bench/method/base_algorithm.py +44 -0
- fusion_bench/method/classification/__init__.py +3 -0
- fusion_bench/method/classification/clip_finetune.py +444 -0
- fusion_bench/method/classification/continual_clip_finetune.py +297 -0
- fusion_bench/method/concrete_subspace/__init__.py +6 -0
- fusion_bench/method/concrete_subspace/clip_concrete_adamerging.py +595 -0
- fusion_bench/method/concrete_subspace/clip_concrete_task_arithmetic.py +263 -0
- fusion_bench/method/dare/__init__.py +4 -0
- fusion_bench/method/dare/simple_average.py +31 -0
- fusion_bench/method/dare/task_arithmetic.py +82 -0
- fusion_bench/method/dare/ties_merging.py +100 -0
- fusion_bench/method/dare/utils.py +87 -0
- fusion_bench/method/dawe/__init__.py +2 -0
- fusion_bench/method/dawe/dawe_for_clip.py +274 -0
- fusion_bench/method/dawe/warppers/__init__.py +13 -0
- fusion_bench/method/dawe/warppers/dawe_model.py +256 -0
- fusion_bench/method/depth_upscaling/__init__.py +3 -0
- fusion_bench/method/depth_upscaling/depth_upscaling.py +89 -0
- fusion_bench/method/depth_upscaling/depth_upscaling_for_llama.py +57 -0
- fusion_bench/method/dummy.py +35 -0
- fusion_bench/method/ensemble.py +98 -0
- fusion_bench/method/fisher_merging/__init__.py +4 -0
- fusion_bench/method/fisher_merging/clip_fisher_merging.py +191 -0
- fusion_bench/method/fisher_merging/fisher_merging.py +484 -0
- fusion_bench/method/fisher_merging/gpt2_fisher_merging.py +193 -0
- fusion_bench/method/linear/__init__.py +6 -0
- fusion_bench/method/linear/expo.py +118 -0
- fusion_bench/method/linear/linear_interpolation.py +60 -0
- fusion_bench/method/linear/llama_expo.py +229 -0
- fusion_bench/method/linear/simple_average_for_llama.py +54 -0
- fusion_bench/method/linear/task_arithmetic_for_llama.py +57 -0
- fusion_bench/method/lm_finetune/__init__.py +3 -0
- fusion_bench/method/lm_finetune/bradley_terry_rm.py +432 -0
- fusion_bench/method/lm_finetune/causal_lm_pretrain.py +7 -0
- fusion_bench/method/lm_finetune/fullfinetune_sft.py +375 -0
- fusion_bench/method/lm_finetune/peftfinetune_sft.py +370 -0
- fusion_bench/method/mixture_of_experts/__init__.py +7 -0
- fusion_bench/method/mixture_of_experts/mixtral_merging.py +112 -0
- fusion_bench/method/mixture_of_experts/mixtral_upcycling.py +329 -0
- fusion_bench/method/model_recombination.py +121 -0
- fusion_bench/method/opcm/__init__.py +4 -0
- fusion_bench/method/opcm/opcm.py +277 -0
- fusion_bench/method/opcm/task_arithmetic.py +115 -0
- fusion_bench/method/opcm/ties_merging.py +156 -0
- fusion_bench/method/opcm/utils.py +73 -0
- fusion_bench/method/opcm/weight_average.py +120 -0
- fusion_bench/method/pruning/__init__.py +5 -0
- fusion_bench/method/pruning/llama_magnitude_prune.py +202 -0
- fusion_bench/method/pruning/llama_random_prune.py +143 -0
- fusion_bench/method/pruning/llama_wanda_prune.py +359 -0
- fusion_bench/method/pruning/magnitude_diff_pruning.py +180 -0
- fusion_bench/method/pruning/prune_utils.py +165 -0
- fusion_bench/method/pruning/wanda_utils/__init__.py +7 -0
- fusion_bench/method/pruning/wanda_utils/ablate.py +188 -0
- fusion_bench/method/pruning/wanda_utils/data.py +135 -0
- fusion_bench/method/pruning/wanda_utils/eval.py +245 -0
- fusion_bench/method/pruning/wanda_utils/layerwrapper.py +61 -0
- fusion_bench/method/pruning/wanda_utils/prune.py +581 -0
- fusion_bench/method/pruning/wanda_utils/prune_opt.py +539 -0
- fusion_bench/method/pruning/wanda_utils/sparsegpt.py +165 -0
- fusion_bench/method/pwe_moe/__init__.py +5 -0
- fusion_bench/method/pwe_moe/clip_pwe_moe.py +315 -0
- fusion_bench/method/pwe_moe/module.py +316 -0
- fusion_bench/method/pwe_moe/phn/__init__.py +2 -0
- fusion_bench/method/pwe_moe/phn/solvers.py +195 -0
- fusion_bench/method/pwe_moe/utils.py +43 -0
- fusion_bench/method/rankone_moe/__init__.py +3 -0
- fusion_bench/method/rankone_moe/clip_rankone_moe.py +160 -0
- fusion_bench/method/rankone_moe/rankone_moe.py +249 -0
- fusion_bench/method/regmean/__init__.py +4 -0
- fusion_bench/method/regmean/clip_regmean.py +131 -0
- fusion_bench/method/regmean/gpt2_regmean.py +147 -0
- fusion_bench/method/regmean/regmean.py +375 -0
- fusion_bench/method/simple_average.py +112 -0
- fusion_bench/method/slerp/__init__.py +2 -0
- fusion_bench/method/slerp/slerp.py +101 -0
- fusion_bench/method/slerp/slerp_utils.py +107 -0
- fusion_bench/method/smile_upscaling/__init__.py +3 -0
- fusion_bench/method/smile_upscaling/singular_projection_merging.py +198 -0
- fusion_bench/method/smile_upscaling/smile_mistral_upscaling.py +331 -0
- fusion_bench/method/smile_upscaling/smile_upscaling.py +573 -0
- fusion_bench/method/sparse_we_moe/__init__.py +2 -0
- fusion_bench/method/sparse_we_moe/sparse_clip_we_moe.py +248 -0
- fusion_bench/method/sparse_we_moe/sparse_we_moe.py +301 -0
- fusion_bench/method/sparselo/__init__.py +2 -0
- fusion_bench/method/sparselo/sparselo.py +955 -0
- fusion_bench/method/surgery/__init__.py +1 -0
- fusion_bench/method/surgery/clip_layer_wise_adamerging_surgery.py +157 -0
- fusion_bench/method/tall_mask/__init__.py +0 -0
- fusion_bench/method/tall_mask/utils.py +234 -0
- fusion_bench/method/task_arithmetic/__init__.py +2 -0
- fusion_bench/method/task_arithmetic/task_arithmetic.py +151 -0
- fusion_bench/method/task_singular_vector/TSVC.py +16 -0
- fusion_bench/method/task_singular_vector/TSVM.py +63 -0
- fusion_bench/method/task_singular_vector/__init__.py +9 -0
- fusion_bench/method/task_singular_vector/utils/TSVC_utils.py +50 -0
- fusion_bench/method/task_singular_vector/utils/TSVM_utils.py +640 -0
- fusion_bench/method/task_singular_vector/utils/__init__.py +7 -0
- fusion_bench/method/ties_merging/__init__.py +2 -0
- fusion_bench/method/ties_merging/ties_merging.py +117 -0
- fusion_bench/method/ties_merging/ties_merging_utils.py +331 -0
- fusion_bench/method/trust_region/__init__.py +2 -0
- fusion_bench/method/trust_region/clip_task_arithmetic.py +205 -0
- fusion_bench/method/trust_region/utils.py +58 -0
- fusion_bench/method/we_moe/__init__.py +2 -0
- fusion_bench/method/we_moe/clip_we_moe.py +161 -0
- fusion_bench/method/we_moe/we_moe.py +247 -0
- fusion_bench/method/weighted_average/__init__.py +3 -0
- fusion_bench/method/weighted_average/llama.py +113 -0
- fusion_bench/method/weighted_average/weighted_average.py +102 -0
- fusion_bench/metrics/__init__.py +0 -0
- fusion_bench/metrics/continual_learning/backward_transfer.py +22 -0
- fusion_bench/metrics/nyuv2/__init__.py +11 -0
- fusion_bench/metrics/nyuv2/depth.py +45 -0
- fusion_bench/metrics/nyuv2/loss.py +31 -0
- fusion_bench/metrics/nyuv2/noise.py +16 -0
- fusion_bench/metrics/nyuv2/normal.py +48 -0
- fusion_bench/metrics/nyuv2/segmentation.py +43 -0
- fusion_bench/metrics/text_to_image_generation/__init__.py +9 -0
- fusion_bench/metrics/text_to_image_generation/aesthetic_scorer.py +123 -0
- fusion_bench/metrics/text_to_image_generation/compressibility.py +49 -0
- fusion_bench/metrics/text_to_image_generation/pickscore_scorer.py +95 -0
- fusion_bench/mixins/__init__.py +28 -0
- fusion_bench/mixins/clip_classification.py +252 -0
- fusion_bench/mixins/fabric_training.py +320 -0
- fusion_bench/mixins/lightning_fabric.py +174 -0
- fusion_bench/mixins/optim/__init__.py +0 -0
- fusion_bench/mixins/optim/adamw_with_warmup.py +42 -0
- fusion_bench/mixins/rich_live.py +21 -0
- fusion_bench/mixins/serialization.py +132 -0
- fusion_bench/mixins/simple_profiler.py +79 -0
- fusion_bench/modelpool/PeftModelForSeq2SeqLM.py +49 -0
- fusion_bench/modelpool/__init__.py +42 -0
- fusion_bench/modelpool/base_pool.py +268 -0
- fusion_bench/modelpool/causal_lm/__init__.py +2 -0
- fusion_bench/modelpool/causal_lm/causal_lm.py +139 -0
- fusion_bench/modelpool/clip_vision/__init__.py +1 -0
- fusion_bench/modelpool/clip_vision/modelpool.py +145 -0
- fusion_bench/modelpool/huggingface_automodel.py +20 -0
- fusion_bench/modelpool/huggingface_gpt2_classification.py +63 -0
- fusion_bench/modelpool/nyuv2_modelpool.py +40 -0
- fusion_bench/modelpool/seq2seq_lm/__init__.py +2 -0
- fusion_bench/modelpool/seq2seq_lm/modelpool.py +65 -0
- fusion_bench/modelpool/seq_classification_lm/__init__.py +2 -0
- fusion_bench/modelpool/seq_classification_lm/reward_model.py +15 -0
- fusion_bench/modelpool/seq_classification_lm/seq_classification_lm.py +98 -0
- fusion_bench/models/__init__.py +3 -0
- fusion_bench/models/chat_templates/__init__.py +1 -0
- fusion_bench/models/chat_templates/llama_3_Instruct.py +1 -0
- fusion_bench/models/chat_templates/load_tokenizer.py +43 -0
- fusion_bench/models/hf_clip.py +199 -0
- fusion_bench/models/linearized/__init__.py +0 -0
- fusion_bench/models/linearized/linearized_model_utils.py +91 -0
- fusion_bench/models/linearized/vision_model.py +122 -0
- fusion_bench/models/llama/__init__.py +16 -0
- fusion_bench/models/llama/model_utils/__init__.py +0 -0
- fusion_bench/models/llama/model_utils/embedding.py +87 -0
- fusion_bench/models/llama/model_utils/liger_kernel.py +86 -0
- fusion_bench/models/llama/model_utils/misc.py +112 -0
- fusion_bench/models/llama/model_utils/mod.py +52 -0
- fusion_bench/models/llama/model_utils/visual.py +241 -0
- fusion_bench/models/llama/patcher.py +78 -0
- fusion_bench/models/llama/tokenizer_loader.py +153 -0
- fusion_bench/models/masks/__init__.py +2 -0
- fusion_bench/models/masks/mask_model.py +160 -0
- fusion_bench/models/modeling_losparse_llama/__init__.py +4 -0
- fusion_bench/models/modeling_losparse_llama/configuration_losparse_llama.py +205 -0
- fusion_bench/models/modeling_losparse_llama/losparse_linear.py +67 -0
- fusion_bench/models/modeling_losparse_llama/modeling_losparse_llama.py +1825 -0
- fusion_bench/models/modeling_losparse_llama/register.py +8 -0
- fusion_bench/models/modeling_losparse_llama/utils.py +60 -0
- fusion_bench/models/modeling_smile_mistral/__init__.py +48 -0
- fusion_bench/models/modeling_smile_mistral/configuration_smile_mistral.py +21 -0
- fusion_bench/models/modeling_smile_mistral/modeling_smile_mistral.py +1034 -0
- fusion_bench/models/modeling_smile_mistral/register.py +8 -0
- fusion_bench/models/nyuv2/__init__.py +0 -0
- fusion_bench/models/nyuv2/aspp.py +82 -0
- fusion_bench/models/nyuv2/lightning_module.py +176 -0
- fusion_bench/models/nyuv2/resnet.py +405 -0
- fusion_bench/models/nyuv2/resnet_dilated.py +99 -0
- fusion_bench/models/parameter_dict.py +75 -0
- fusion_bench/models/rankone_moe.py +410 -0
- fusion_bench/models/separate_io.py +105 -0
- fusion_bench/models/smile_moe/__init__.py +0 -0
- fusion_bench/models/smile_moe/linear.py +256 -0
- fusion_bench/models/sparse_we_moe.py +459 -0
- fusion_bench/models/surgery/__init__.py +1 -0
- fusion_bench/models/surgery/surgerymodelwrapper.py +158 -0
- fusion_bench/models/utils.py +80 -0
- fusion_bench/models/we_moe.py +247 -0
- fusion_bench/models/wrappers/__init__.py +0 -0
- fusion_bench/models/wrappers/ensemble.py +183 -0
- fusion_bench/models/wrappers/layer_wise_fusion.py +336 -0
- fusion_bench/models/wrappers/task_wise_fusion.py +249 -0
- fusion_bench/optim/__init__.py +2 -0
- fusion_bench/optim/exception.py +47 -0
- fusion_bench/optim/lr_scheduler/__init__.py +1 -0
- fusion_bench/optim/lr_scheduler/linear_warmup.py +222 -0
- fusion_bench/optim/lr_scheduler/utils/__init__.py +1 -0
- fusion_bench/optim/lr_scheduler/utils/visualization.py +119 -0
- fusion_bench/optim/mezo.py +118 -0
- fusion_bench/programs/__init__.py +20 -0
- fusion_bench/programs/base_program.py +9 -0
- fusion_bench/programs/fabric_fusion_program.py +299 -0
- fusion_bench/scripts/__init__.py +0 -0
- fusion_bench/scripts/cli.py +43 -0
- fusion_bench/scripts/clip/__init__.py +0 -0
- fusion_bench/scripts/clip/convert_checkpoint.py +39 -0
- fusion_bench/scripts/imgui.py +218 -0
- fusion_bench/scripts/nyuv2_mtl_train.py +137 -0
- fusion_bench/scripts/webui.py +405 -0
- fusion_bench/taskpool/__init__.py +39 -0
- fusion_bench/taskpool/base_pool.py +35 -0
- fusion_bench/taskpool/clip_vision/__init__.py +4 -0
- fusion_bench/taskpool/clip_vision/clip_rankone_moe_taskpool.py +112 -0
- fusion_bench/taskpool/clip_vision/clip_sparse_wemoe_taskpool.py +120 -0
- fusion_bench/taskpool/clip_vision/taskpool.py +392 -0
- fusion_bench/taskpool/dummy.py +58 -0
- fusion_bench/taskpool/gpt2_text_classification.py +149 -0
- fusion_bench/taskpool/llama/__init__.py +1 -0
- fusion_bench/taskpool/llama/reward_model.py +157 -0
- fusion_bench/taskpool/llama/test_generation.py +185 -0
- fusion_bench/taskpool/nyuv2_taskpool.py +65 -0
- fusion_bench/tasks/__init__.py +2 -0
- fusion_bench/tasks/base_task.py +18 -0
- fusion_bench/tasks/classification.py +75 -0
- fusion_bench/tasks/clip_classification/__init__.py +183 -0
- fusion_bench/tasks/clip_classification/cifar10.py +33 -0
- fusion_bench/tasks/clip_classification/cifar100.py +146 -0
- fusion_bench/tasks/clip_classification/clip_dataset.py +1 -0
- fusion_bench/tasks/clip_classification/cub_200_2011.py +208 -0
- fusion_bench/tasks/clip_classification/dtd.py +60 -0
- fusion_bench/tasks/clip_classification/emnist_letters.py +31 -0
- fusion_bench/tasks/clip_classification/emnist_mnist.py +5 -0
- fusion_bench/tasks/clip_classification/eurosat.py +18 -0
- fusion_bench/tasks/clip_classification/fashion_mnist.py +18 -0
- fusion_bench/tasks/clip_classification/fer2013.py +18 -0
- fusion_bench/tasks/clip_classification/flower102.py +106 -0
- fusion_bench/tasks/clip_classification/food101.py +105 -0
- fusion_bench/tasks/clip_classification/gtsrb.py +51 -0
- fusion_bench/tasks/clip_classification/imagenet.py +2103 -0
- fusion_bench/tasks/clip_classification/kmnist.py +17 -0
- fusion_bench/tasks/clip_classification/mnist.py +5 -0
- fusion_bench/tasks/clip_classification/mongo_leaf_disease.py +19 -0
- fusion_bench/tasks/clip_classification/oxford_iiit_pet.py +41 -0
- fusion_bench/tasks/clip_classification/pcam.py +5 -0
- fusion_bench/tasks/clip_classification/rendered_sst2.py +3 -0
- fusion_bench/tasks/clip_classification/resisc45.py +68 -0
- fusion_bench/tasks/clip_classification/stanford_cars.py +209 -0
- fusion_bench/tasks/clip_classification/stl10.py +17 -0
- fusion_bench/tasks/clip_classification/sun397.py +404 -0
- fusion_bench/tasks/clip_classification/svhn.py +5 -0
- fusion_bench/tasks/clip_classification/tiny_imagenet.py +208 -0
- fusion_bench/tasks/flan_t5_text_generation/__init__.py +0 -0
- fusion_bench/tasks/flan_t5_text_generation/datasets_preprocess.py +71 -0
- fusion_bench/tasks/flan_t5_text_generation/glue_evaluation.py +132 -0
- fusion_bench/tasks/flan_t5_text_generation/glue_load_dataset.py +64 -0
- fusion_bench/tasks/flan_t5_text_generation/glue_preprocessors.py +379 -0
- fusion_bench/tasks/flan_t5_text_generation/glue_prompt_templates.py +52 -0
- fusion_bench/utils/__init__.py +14 -0
- fusion_bench/utils/auto.py +31 -0
- fusion_bench/utils/cache_utils.py +58 -0
- fusion_bench/utils/data.py +165 -0
- fusion_bench/utils/devices.py +231 -0
- fusion_bench/utils/dict.py +43 -0
- fusion_bench/utils/dtype.py +146 -0
- fusion_bench/utils/expr.py +90 -0
- fusion_bench/utils/fabric.py +17 -0
- fusion_bench/utils/functools.py +37 -0
- fusion_bench/utils/hydra_utils.py +28 -0
- fusion_bench/utils/instantiate.py +450 -0
- fusion_bench/utils/json.py +93 -0
- fusion_bench/utils/lazy_imports.py +74 -0
- fusion_bench/utils/misc.py +18 -0
- fusion_bench/utils/packages.py +84 -0
- fusion_bench/utils/parameters.py +323 -0
- fusion_bench/utils/path.py +22 -0
- fusion_bench/utils/plot/__init__.py +0 -0
- fusion_bench/utils/plot/color_data.py +1726 -0
- fusion_bench/utils/plot/token.py +52 -0
- fusion_bench/utils/plot/token_notebook.py +127 -0
- fusion_bench/utils/pylogger.py +55 -0
- fusion_bench/utils/rich_utils.py +201 -0
- fusion_bench/utils/set.py +8 -0
- fusion_bench/utils/state_dict_arithmetic.py +297 -0
- fusion_bench/utils/strenum/__init__.py +326 -0
- fusion_bench/utils/strenum/_name_mangler.py +127 -0
- fusion_bench/utils/strenum/_version.py +556 -0
- fusion_bench/utils/tensorboard.py +51 -0
- fusion_bench/utils/timer.py +49 -0
- fusion_bench/utils/type.py +34 -0
- fusion_bench-0.2.9.dist-info/LICENSE +21 -0
- fusion_bench-0.2.9.dist-info/METADATA +258 -0
- fusion_bench-0.2.9.dist-info/RECORD +727 -0
- fusion_bench-0.2.9.dist-info/WHEEL +5 -0
- fusion_bench-0.2.9.dist-info/entry_points.txt +3 -0
- fusion_bench-0.2.9.dist-info/top_level.txt +1 -0
- fusion_bench_config/README.md +12 -0
- fusion_bench_config/clip-vit-base-patch32_robustness_corrupted.yaml +23 -0
- fusion_bench_config/dataset/image_classification/README.md +6 -0
- fusion_bench_config/dataset/image_classification/test/TALL14.yaml +20 -0
- fusion_bench_config/dataset/image_classification/test/TALL20.yaml +28 -0
- fusion_bench_config/dataset/image_classification/test/cifar10.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/cifar100.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/cub-200-2011.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/dtd.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/emnist_letters.yaml +5 -0
- fusion_bench_config/dataset/image_classification/test/emnist_mnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/eurosat.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/fashion_mnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/fer2013.yaml +3 -0
- fusion_bench_config/dataset/image_classification/test/food101.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/gtsrb.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/kmnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/mango-leaf-disease.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/mnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/oxford-iiit-pet.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/oxford_flowers102.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/pcam.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/rendered-sst2.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/resisc45.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/stanford-cars.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/stl10.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/sun397.yaml +4 -0
- fusion_bench_config/dataset/image_classification/test/svhn.yaml +6 -0
- fusion_bench_config/dataset/image_classification/test/the_eight_tasks.yaml +9 -0
- fusion_bench_config/dataset/image_classification/test/tiny-imagenet.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/TALL14.yaml +20 -0
- fusion_bench_config/dataset/image_classification/train/TALL20.yaml +28 -0
- fusion_bench_config/dataset/image_classification/train/cifar10.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/cifar100.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/cub-200-2011.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/dtd.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/emnist_letters.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/emnist_mnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/eurosat.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/fashion_mnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/fer2013.yaml +3 -0
- fusion_bench_config/dataset/image_classification/train/food101.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/gtsrb.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/kmnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/mango-leaf-disease.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/mnist.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/oxford-iiit-pet.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/oxford_flowers102.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/pcam.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/rendered-sst2.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/resisc45.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/stanford-cars.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/stl10.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/sun397.yaml +4 -0
- fusion_bench_config/dataset/image_classification/train/svhn.yaml +6 -0
- fusion_bench_config/dataset/image_classification/train/the_eight_tasks.yaml +9 -0
- fusion_bench_config/dataset/image_classification/train/tiny-imagenet.yaml +4 -0
- fusion_bench_config/dataset/image_classification/val/dtd.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/eurosat.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/gtsrb.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/mnist.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/resisc45.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/stanford-cars.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/sun397.yaml +10 -0
- fusion_bench_config/dataset/image_classification/val/svhn.yaml +12 -0
- fusion_bench_config/dataset/image_classification/val/the_eight_tasks.yaml +9 -0
- fusion_bench_config/dataset/llm_sft/alpaca_cleaned.yaml +6 -0
- fusion_bench_config/dataset/llm_sft/ultrachat_200k.yaml +3 -0
- fusion_bench_config/dataset/question_answering/search_qa.yaml +6 -0
- fusion_bench_config/dataset/question_answering/test/search_qa.yaml +7 -0
- fusion_bench_config/dataset/question_answering/train/MetaMathQA.yaml +4 -0
- fusion_bench_config/dataset/question_answering/train/search_qa.yaml +7 -0
- fusion_bench_config/dataset/question_answering/val/search_qa.yaml +7 -0
- fusion_bench_config/dataset/summarization/test/xsum.yaml +4 -0
- fusion_bench_config/dataset/summarization/train/xsum.yaml +4 -0
- fusion_bench_config/dataset/summarization/val/xsum.yaml +4 -0
- fusion_bench_config/dataset/summarization/xsum.yaml +3 -0
- fusion_bench_config/dataset/text_generation/test/gsm-hard.yaml +4 -0
- fusion_bench_config/dataset/text_generation/test/gsm8k.yaml +5 -0
- fusion_bench_config/dataset/text_generation/test/gsm8k_question_label.yaml +3 -0
- fusion_bench_config/dataset/text_generation/train/CodeAlpaca-20k.yaml +4 -0
- fusion_bench_config/dataset/text_generation/train/gsm8k.yaml +5 -0
- fusion_bench_config/dataset/text_generation/train/gsm8k_question_label.yaml +3 -0
- fusion_bench_config/fabric/auto.yaml +16 -0
- fusion_bench_config/fabric/llama_ddp.yaml +18 -0
- fusion_bench_config/fabric/llama_fsdp.yaml +16 -0
- fusion_bench_config/fabric/llama_peft_fsdp.yaml +16 -0
- fusion_bench_config/fabric/loggers/csv_logger.yaml +11 -0
- fusion_bench_config/fabric/loggers/tensorboard_logger.yaml +11 -0
- fusion_bench_config/fabric/loggers/wandb_logger.yaml +2 -0
- fusion_bench_config/fabric/strategy/deepspeed.yaml +10 -0
- fusion_bench_config/fabric/strategy/llama_fsdp.yaml +8 -0
- fusion_bench_config/fabric/strategy/llama_peft_fsdp.yaml +9 -0
- fusion_bench_config/fabric_model_fusion.yaml +20 -0
- fusion_bench_config/hydra/default.yaml +8 -0
- fusion_bench_config/hydra/help/fusion_bench_help.yaml +47 -0
- fusion_bench_config/hydra/job_logging/rich_logging.yaml +20 -0
- fusion_bench_config/llama_full_finetune.yaml +19 -0
- fusion_bench_config/llama_magnitude_pruning.yaml +16 -0
- fusion_bench_config/llama_model_fusion.yaml +17 -0
- fusion_bench_config/method/ada_svd/clip_vision.yaml +9 -0
- fusion_bench_config/method/adamerging/clip.yaml +23 -0
- fusion_bench_config/method/adamerging/layer_wise_flan_t5.yaml +23 -0
- fusion_bench_config/method/adamerging/layer_wise_gpt2.yaml +23 -0
- fusion_bench_config/method/adamerging/llama_sft.yaml +33 -0
- fusion_bench_config/method/adamerging.yaml +23 -0
- fusion_bench_config/method/analysis/task_vector_cos_similarity.yaml +6 -0
- fusion_bench_config/method/analysis/task_vector_violin_plot.yaml +6 -0
- fusion_bench_config/method/classification/clip_continual_finetune.yaml +28 -0
- fusion_bench_config/method/classification/clip_finetune.yaml +26 -0
- fusion_bench_config/method/clip_finetune.yaml +26 -0
- fusion_bench_config/method/concrete_subspace/clip_concrete_layer_wise_adamerging.yaml +27 -0
- fusion_bench_config/method/concrete_subspace/clip_concrete_task_arithmetic.yaml +25 -0
- fusion_bench_config/method/concrete_subspace/clip_concrete_task_wise_adamerging.yaml +27 -0
- fusion_bench_config/method/dare/simple_average.yaml +5 -0
- fusion_bench_config/method/dare/task_arithmetic.yaml +6 -0
- fusion_bench_config/method/dare/ties_merging.yaml +15 -0
- fusion_bench_config/method/dawe/dawe_for_clip.yaml +32 -0
- fusion_bench_config/method/depth_upscaling.yaml +5 -0
- fusion_bench_config/method/dummy.yaml +1 -0
- fusion_bench_config/method/ensemble/max_model_predictor.yaml +1 -0
- fusion_bench_config/method/ensemble/simple_ensemble.yaml +2 -0
- fusion_bench_config/method/ensemble/weighted_ensemble.yaml +6 -0
- fusion_bench_config/method/fisher_merging/clip_fisher_merging.yaml +13 -0
- fusion_bench_config/method/fisher_merging/fisher_merging.yaml +9 -0
- fusion_bench_config/method/fisher_merging/gpt2_fisher_merging.yaml +12 -0
- fusion_bench_config/method/linear/expo.yaml +8 -0
- fusion_bench_config/method/linear/linear_interpolation.yaml +3 -0
- fusion_bench_config/method/linear/llama_expo.yaml +19 -0
- fusion_bench_config/method/linear/llama_expo_with_dare.yaml +19 -0
- fusion_bench_config/method/linear/simple_average_for_llama.yaml +5 -0
- fusion_bench_config/method/linear/task_arithmetic_for_llama.yaml +4 -0
- fusion_bench_config/method/linear/weighted_average.yaml +6 -0
- fusion_bench_config/method/linear/weighted_average_for_llama.yaml +12 -0
- fusion_bench_config/method/lm_finetune/bradley_terry_rm.yaml +47 -0
- fusion_bench_config/method/lm_finetune/fullfinetune_sft.yaml +47 -0
- fusion_bench_config/method/lm_finetune/peftfinetune_sft.yaml +63 -0
- fusion_bench_config/method/mixtral_moe_merging.yaml +4 -0
- fusion_bench_config/method/mixtral_moe_upscaling.yaml +7 -0
- fusion_bench_config/method/model_recombination.yaml +4 -0
- fusion_bench_config/method/opcm/opcm.yaml +12 -0
- fusion_bench_config/method/opcm/task_arithmetic.yaml +12 -0
- fusion_bench_config/method/opcm/ties_merging.yaml +18 -0
- fusion_bench_config/method/opcm/weight_average.yaml +10 -0
- fusion_bench_config/method/pruning/llama_magnitude_pruning.yaml +14 -0
- fusion_bench_config/method/pruning/llama_random_pruning.yaml +9 -0
- fusion_bench_config/method/pruning/llama_wanda_pruning.yaml +16 -0
- fusion_bench_config/method/pruning/magnitude_diff_pruning.yaml +5 -0
- fusion_bench_config/method/pwe_moe_ls_for_clip.yaml +22 -0
- fusion_bench_config/method/rankone_moe/rankone_moe.yaml +26 -0
- fusion_bench_config/method/regmean/clip_regmean.yaml +11 -0
- fusion_bench_config/method/regmean/gpt2_regmean.yaml +12 -0
- fusion_bench_config/method/regmean/regmean.yaml +4 -0
- fusion_bench_config/method/simple_average.yaml +1 -0
- fusion_bench_config/method/slerp/slerp.yaml +6 -0
- fusion_bench_config/method/smile_upscaling/singular_projection_merging.yaml +8 -0
- fusion_bench_config/method/smile_upscaling/smile_mistral_upscaling.yaml +10 -0
- fusion_bench_config/method/smile_upscaling/smile_upscaling.yaml +14 -0
- fusion_bench_config/method/sparselo_pruning/llama_iterative_sparselo.yaml +20 -0
- fusion_bench_config/method/sparselo_pruning/llama_pcp_sparselo.yaml +20 -0
- fusion_bench_config/method/sparselo_pruning/llama_sparselo.yaml +19 -0
- fusion_bench_config/method/surgery/adamerging_surgery.yaml +27 -0
- fusion_bench_config/method/task_arithmetic.yaml +2 -0
- fusion_bench_config/method/task_singular_vector/TaskSingularVectorMerging.yaml +2 -0
- fusion_bench_config/method/ties_merging.yaml +8 -0
- fusion_bench_config/method/trust_region/clip_task_arithmetic.yaml +7 -0
- fusion_bench_config/method/wemoe/sparse_weight_ensembling_moe.yaml +39 -0
- fusion_bench_config/method/wemoe/weight_ensembling_moe.yaml +20 -0
- fusion_bench_config/model/clip-vit/README.md +38 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_TALL14.yaml +22 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_TALL20.yaml +29 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_cifar10.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_cifar100.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_dtd.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_eight_tasks.yaml +10 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_emnist_letters.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_eurosat.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_fashion_mnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_fer2013.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_food101.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_gtsrb.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_kmnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_mnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_oxford-iiit-pet.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_oxford_flowers102.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_pcam.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_rendered-sst2.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_resisc45.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_stanford-cars.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_stl10.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_sun397.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch16_svhn.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_TALL14.yaml +22 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_TALL20.yaml +29 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_cifar10.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_cifar100.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_dtd.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_eight_tasks.yaml +11 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_emnist_letters.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_eurosat.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_fashion_mnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_fer2013.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_food101.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_gtsrb.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_kmnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_mnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_oxford-iiit-pet.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_oxford_flowers102.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_pcam.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_rendered-sst2.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_resisc45.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_stanford-cars.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_stl10.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_sun397.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-base-patch32_svhn.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_TALL14.yaml +22 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_TALL20.yaml +29 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_cifar10.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_cifar100.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_dtd.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_eight_tasks.yaml +10 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_emnist_letters.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_eurosat.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_fashion_mnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_fer2013.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_food101.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_gtsrb.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_kmnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_mnist.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_oxford-iiit-pet.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_oxford_flowers102.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_pcam.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_rendered-sst2.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_resisc45.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_stanford-cars.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_stl10.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_sun397.yaml +1 -0
- fusion_bench_config/model/clip-vit/clip-vit-large-patch14_svhn.yaml +1 -0
- fusion_bench_config/model/clip-vit/download_TALL20_models.sh +6 -0
- fusion_bench_config/model/clip-vit/generate_vit_model_config.sh +23 -0
- fusion_bench_config/model/flan-t5/flan-t5-base.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-cola.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-cola_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-mnli.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-mnli_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-mrpc.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-mrpc_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-qnli.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-qnli_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-qqp.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-qqp_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-rte.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-rte_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-sst2.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-sst2_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-stsb.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-base_glue-stsb_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large.yaml +3 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-cola_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-mnli_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-mrpc_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-qnli_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-qqp_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-rte_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-sst2_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/flan-t5-large_glue-stsb_lora-16.yaml +4 -0
- fusion_bench_config/model/flan-t5/generate_flan-t5.sh +38 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/_template.yaml +12 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TA8.yaml +8 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TA8_lora.yaml +53 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TA8_model_only.yaml +6 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TALL14.yaml +11 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TALL14_model_only.yaml +9 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TALL20.yaml +11 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_TALL20_model_only.yaml +9 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_individual.yaml +19 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch16_individual_lora.yaml +14 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TA8.yaml +5 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TA8_control_task.yaml +24 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TA8_model_only.yaml +3 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TALL14.yaml +8 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TALL14_model_only.yaml +6 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TALL20.yaml +8 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_TALL20_model_only.yaml +6 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_generalization_exp1.yaml +24 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_generalization_exp2.yaml +24 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_individual.yaml +13 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_mtl.yaml +5 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_robustness_clean.yaml +18 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_robustness_corrupted.yaml +29 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_single_finetuned.yaml +5 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_single_task_projection.yaml +15 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_svhn_and_mnist.yaml +6 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-base-patch32_two_tasks_control_task.yaml +18 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_TA8.yaml +8 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_TA8_model_only.yaml +6 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_TALL14.yaml +11 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_TALL14_model_only.yaml +9 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_TALL20.yaml +11 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_TALL20_model_only.yaml +9 -0
- fusion_bench_config/modelpool/CLIPVisionModelPool/clip-vit-large-patch14_individual.yaml +19 -0
- fusion_bench_config/modelpool/CausalLMPool/llama_alpaca_cleaned.yaml +21 -0
- fusion_bench_config/modelpool/CausalLMPool/llama_codealpaca.yaml +21 -0
- fusion_bench_config/modelpool/CausalLMPool/llama_for_causallm.yaml +20 -0
- fusion_bench_config/modelpool/CausalLMPool/llama_metamathqa.yaml +19 -0
- fusion_bench_config/modelpool/CausalLMPool/llama_ultrachat.yaml +18 -0
- fusion_bench_config/modelpool/CausalLMPool/simle_mixtral_exp_v4.yaml +21 -0
- fusion_bench_config/modelpool/CausalLMPool/single_llama_model.yaml +17 -0
- fusion_bench_config/modelpool/Seq2SeqLMPool/_template.yaml +8 -0
- fusion_bench_config/modelpool/Seq2SeqLMPool/flan-t5-base_glue.yaml +13 -0
- fusion_bench_config/modelpool/Seq2SeqLMPool/flan-t5-base_glue_lora16.yaml +41 -0
- fusion_bench_config/modelpool/Seq2SeqLMPool/flan-t5-base_glue_lora16_tta.yaml +68 -0
- fusion_bench_config/modelpool/Seq2SeqLMPool/flan-t5-base_individual.yaml +7 -0
- fusion_bench_config/modelpool/Seq2SeqLMPool/flan-t5-large_glue_lora16.yaml +45 -0
- fusion_bench_config/modelpool/SeqenceClassificationModelPool/llama_preference700k.yaml +23 -0
- fusion_bench_config/modelpool/SeqenceClassificationModelPool/single_reward_model.yaml +14 -0
- fusion_bench_config/modelpool/automodelpool.yaml +12 -0
- fusion_bench_config/modelpool/gpt-2_glue.yaml +64 -0
- fusion_bench_config/modelpool/mixtral_moe_merging.yaml +14 -0
- fusion_bench_config/modelpool/mixtral_moe_upscaling.yaml +6 -0
- fusion_bench_config/modelpool/nyuv2_modelpool.yaml +26 -0
- fusion_bench_config/modelpool/smile_mistral_exp_v1.yaml +9 -0
- fusion_bench_config/modelpool/smile_mistral_exp_v2.yaml +9 -0
- fusion_bench_config/modelpool/smile_mistral_exp_v3.yaml +9 -0
- fusion_bench_config/modelpool/smile_mistral_exp_v4.yaml +13 -0
- fusion_bench_config/nyuv2_config.yaml +17 -0
- fusion_bench_config/nyuv2_mtl_train.yaml +32 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/_template.yaml +31 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-base-patch32_robustness_corrupted.yaml +27 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TA8.yaml +11 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TA8_B16.yaml +31 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TA8_L14.yaml +12 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TA8_val.yaml +12 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TA8_with_control_task.yaml +12 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TALL14.yaml +19 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-classification_TALL20.yaml +26 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_cifar10.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_cifar100.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_dtd.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_emnist_letters.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_eurosat.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_fashion_mnist.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_fer2013.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_food101.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_gtsrb.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_kmnist.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_mnist.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_oxford-iiit-pet.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_oxford_flowers102.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_oxford_flowers102_val.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_pcam.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_rendered-sst2.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_resisc45.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_stanford-cars.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_stl10.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_sun397.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip-vit-single-task_svhn.yaml +3 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip_rankone_wemoe_clip-vit-classification_TA8.yaml +18 -0
- fusion_bench_config/taskpool/CLIPVisionModelTaskPool/clip_sparse_wemoe_clip-vit-classification_TA8.yaml +18 -0
- fusion_bench_config/taskpool/clip-vit-base-patch32_robustness_clean.yaml +24 -0
- fusion_bench_config/taskpool/clip-vit-base-patch32_robustness_corrupted.yaml +27 -0
- fusion_bench_config/taskpool/clip-vit-base-patch32_svhn_and_mnist.yaml +22 -0
- fusion_bench_config/taskpool/dummy.yaml +2 -0
- fusion_bench_config/taskpool/flan-t5_glue_text_generation.yaml +44 -0
- fusion_bench_config/taskpool/gpt-2_glue.yaml +39 -0
- fusion_bench_config/taskpool/nyuv2_taskpool.yaml +9 -0
- fusion_bench_config/taskpool/reward_model_evaluation.yaml +18 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from transformers import AutoConfig, AutoModel, AutoModelForCausalLM
|
|
2
|
+
|
|
3
|
+
from .configuration_smile_mistral import SmileMistralConfig
|
|
4
|
+
from .modeling_smile_mistral import SmileMistralForCausalLM, SmileMistralModel
|
|
5
|
+
|
|
6
|
+
AutoConfig.register("smile_mistral", SmileMistralConfig)
|
|
7
|
+
AutoModel.register(SmileMistralConfig, SmileMistralModel)
|
|
8
|
+
AutoModelForCausalLM.register(SmileMistralConfig, SmileMistralForCausalLM)
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import torch.nn as nn
|
|
3
|
+
import torch.nn.functional as F
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DeepLabHead(nn.Sequential):
|
|
7
|
+
def __init__(self, in_channels: int, num_classes: int):
|
|
8
|
+
super(DeepLabHead, self).__init__(
|
|
9
|
+
ASPP(in_channels, [12, 24, 36]),
|
|
10
|
+
nn.Conv2d(256, 256, 3, padding=1, bias=False),
|
|
11
|
+
nn.BatchNorm2d(256),
|
|
12
|
+
nn.ReLU(),
|
|
13
|
+
nn.Conv2d(256, num_classes, 1),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ASPPConv(nn.Sequential):
|
|
18
|
+
def __init__(self, in_channels, out_channels, dilation):
|
|
19
|
+
modules = [
|
|
20
|
+
nn.Conv2d(
|
|
21
|
+
in_channels,
|
|
22
|
+
out_channels,
|
|
23
|
+
3,
|
|
24
|
+
padding=dilation,
|
|
25
|
+
dilation=dilation,
|
|
26
|
+
bias=False,
|
|
27
|
+
),
|
|
28
|
+
nn.BatchNorm2d(out_channels),
|
|
29
|
+
nn.ReLU(),
|
|
30
|
+
]
|
|
31
|
+
super(ASPPConv, self).__init__(*modules)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ASPPPooling(nn.Sequential):
|
|
35
|
+
def __init__(self, in_channels, out_channels):
|
|
36
|
+
super(ASPPPooling, self).__init__(
|
|
37
|
+
nn.AdaptiveAvgPool2d(1),
|
|
38
|
+
nn.Conv2d(in_channels, out_channels, 1, bias=False),
|
|
39
|
+
nn.BatchNorm2d(out_channels),
|
|
40
|
+
nn.ReLU(),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def forward(self, x):
|
|
44
|
+
size = x.shape[-2:]
|
|
45
|
+
x = super(ASPPPooling, self).forward(x)
|
|
46
|
+
return F.interpolate(x, size=size, mode="bilinear", align_corners=False)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ASPP(nn.Module):
|
|
50
|
+
def __init__(self, in_channels: int, atrous_rates):
|
|
51
|
+
super(ASPP, self).__init__()
|
|
52
|
+
out_channels = 256
|
|
53
|
+
modules = []
|
|
54
|
+
modules.append(
|
|
55
|
+
nn.Sequential(
|
|
56
|
+
nn.Conv2d(in_channels, out_channels, 1, bias=False),
|
|
57
|
+
nn.BatchNorm2d(out_channels),
|
|
58
|
+
nn.ReLU(),
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
rate1, rate2, rate3 = tuple(atrous_rates)
|
|
63
|
+
modules.append(ASPPConv(in_channels, out_channels, rate1))
|
|
64
|
+
modules.append(ASPPConv(in_channels, out_channels, rate2))
|
|
65
|
+
modules.append(ASPPConv(in_channels, out_channels, rate3))
|
|
66
|
+
modules.append(ASPPPooling(in_channels, out_channels))
|
|
67
|
+
|
|
68
|
+
self.convs = nn.ModuleList(modules)
|
|
69
|
+
|
|
70
|
+
self.project = nn.Sequential(
|
|
71
|
+
nn.Conv2d(5 * out_channels, out_channels, 1, bias=False),
|
|
72
|
+
nn.BatchNorm2d(out_channels),
|
|
73
|
+
nn.ReLU(),
|
|
74
|
+
nn.Dropout(0.5),
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
def forward(self, x):
|
|
78
|
+
res = []
|
|
79
|
+
for conv in self.convs:
|
|
80
|
+
res.append(conv(x))
|
|
81
|
+
res = torch.cat(res, dim=1)
|
|
82
|
+
return self.project(res)
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
from typing import Dict, List, Literal, Optional, cast
|
|
3
|
+
|
|
4
|
+
import lightning as L
|
|
5
|
+
import torch.nn.functional as F
|
|
6
|
+
from torch import Tensor, nn
|
|
7
|
+
from torchmetrics import Metric
|
|
8
|
+
|
|
9
|
+
from fusion_bench.metrics.nyuv2 import metric_classes
|
|
10
|
+
from fusion_bench.metrics.nyuv2.loss import loss_fn
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NYUv2Model(nn.Module):
|
|
14
|
+
image_size = (288, 384)
|
|
15
|
+
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
encoder: nn.Module,
|
|
19
|
+
decoders: nn.ModuleDict,
|
|
20
|
+
):
|
|
21
|
+
R"""
|
|
22
|
+
Args:
|
|
23
|
+
encoder: The encoder module.
|
|
24
|
+
decoders: A dictionary of the decoder modules.
|
|
25
|
+
"""
|
|
26
|
+
super().__init__()
|
|
27
|
+
|
|
28
|
+
self.encoder = encoder
|
|
29
|
+
self.decoders = decoders
|
|
30
|
+
|
|
31
|
+
def encode(self, images: Tensor) -> Tensor:
|
|
32
|
+
return self.encoder(images)
|
|
33
|
+
|
|
34
|
+
def decode(self, features: Tensor, key: str) -> Tensor:
|
|
35
|
+
return self.decoders[key](features)
|
|
36
|
+
|
|
37
|
+
def model_parameters(self):
|
|
38
|
+
"parameters of the encoder and the decoders"
|
|
39
|
+
return itertools.chain(
|
|
40
|
+
self.encoder.parameters(),
|
|
41
|
+
self.decoders.parameters(),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def _compute_loss(
|
|
45
|
+
self,
|
|
46
|
+
outputs: Dict[str, Tensor],
|
|
47
|
+
targets: Dict[str, Tensor],
|
|
48
|
+
task: Literal["segmentation", "depth", "normal"] | List[str],
|
|
49
|
+
) -> Tensor | List[Tensor]:
|
|
50
|
+
if isinstance(task, str):
|
|
51
|
+
return loss_fn[task](outputs[task], targets[task])
|
|
52
|
+
else:
|
|
53
|
+
return [loss_fn[t](outputs[t], targets[t]) for t in task]
|
|
54
|
+
|
|
55
|
+
def forward(
|
|
56
|
+
self, images: Tensor, tasks: Optional[List[str]] = None
|
|
57
|
+
) -> Dict[str, Tensor]:
|
|
58
|
+
features = self.encode(images)
|
|
59
|
+
|
|
60
|
+
if tasks is None:
|
|
61
|
+
tasks = self.decoders.keys()
|
|
62
|
+
outputs = {}
|
|
63
|
+
for task in tasks:
|
|
64
|
+
outputs[task] = F.interpolate(
|
|
65
|
+
self.decode(features, task),
|
|
66
|
+
self.image_size,
|
|
67
|
+
mode="bilinear",
|
|
68
|
+
align_corners=True,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return outputs
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class NYUv2MTLModule(NYUv2Model, L.LightningModule):
|
|
75
|
+
R"""
|
|
76
|
+
multi-task learning module for NYUv2 dataset, with weighted loss
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def __init__(
|
|
80
|
+
self,
|
|
81
|
+
encoder: nn.Module,
|
|
82
|
+
decoders: nn.ModuleDict,
|
|
83
|
+
tasks: List[str],
|
|
84
|
+
task_weights: List[float],
|
|
85
|
+
):
|
|
86
|
+
R"""
|
|
87
|
+
By using this module, you optimize the weighted sum of the losses of the tasks.
|
|
88
|
+
The joint loss is defined as:
|
|
89
|
+
|
|
90
|
+
.. math::
|
|
91
|
+
\mathcal{L} = \sum_{i=1}^{N} w_i \mathcal{L}_i
|
|
92
|
+
|
|
93
|
+
where :math:`N` is the number of tasks, :math:`w_i` is the weight for the task :math:`i`,
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
encoder (nn.Module): The encoder module.
|
|
97
|
+
decoders (nn.ModuleDict): A dictionary of the decoder modules.
|
|
98
|
+
tasks (List[str]): A list of tasks.
|
|
99
|
+
task_weights (List[float]): A list of weights for each task.
|
|
100
|
+
|
|
101
|
+
Raises:
|
|
102
|
+
AssertionError: If tasks and task_weights do not have the same length.
|
|
103
|
+
"""
|
|
104
|
+
assert len(tasks) == len(
|
|
105
|
+
task_weights
|
|
106
|
+
), "tasks and task_weights must have the same length"
|
|
107
|
+
|
|
108
|
+
super().__init__(encoder, decoders)
|
|
109
|
+
self.tasks = tasks
|
|
110
|
+
self.task_weights = task_weights
|
|
111
|
+
|
|
112
|
+
self.metrics = nn.ModuleDict({t: metric_classes[t]() for t in self.tasks})
|
|
113
|
+
|
|
114
|
+
# training
|
|
115
|
+
|
|
116
|
+
def on_train_epoch_start(self):
|
|
117
|
+
for t in self.tasks:
|
|
118
|
+
self.metrics[t].reset()
|
|
119
|
+
|
|
120
|
+
def _single_step(self, images, targets):
|
|
121
|
+
outputs = self(images, self.tasks)
|
|
122
|
+
losses = self._compute_loss(outputs, targets, self.tasks)
|
|
123
|
+
weighted_loss = sum([w * l for w, l in zip(self.task_weights, losses)])
|
|
124
|
+
|
|
125
|
+
for t in self.metrics:
|
|
126
|
+
self.metrics[t].update(outputs[t], targets[t])
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
"outputs": outputs,
|
|
130
|
+
"losses": losses,
|
|
131
|
+
"weighted_loss": weighted_loss,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
def training_step(self, batch, batch_idx: int):
|
|
135
|
+
images, targets = batch
|
|
136
|
+
results = self._single_step(images, targets)
|
|
137
|
+
|
|
138
|
+
outputs = results["outputs"]
|
|
139
|
+
losses = results["losses"]
|
|
140
|
+
weighted_loss = results["weighted_loss"]
|
|
141
|
+
|
|
142
|
+
for i, t in enumerate(self.tasks):
|
|
143
|
+
self.log(f"train/{t}_loss", losses[i])
|
|
144
|
+
self.log("train/loss", weighted_loss, prog_bar=True)
|
|
145
|
+
|
|
146
|
+
return weighted_loss
|
|
147
|
+
|
|
148
|
+
def on_train_epoch_end(self) -> None:
|
|
149
|
+
for t in self.tasks:
|
|
150
|
+
metrics = cast(Metric, self.metrics[t]).compute()
|
|
151
|
+
for metric_name, metric_value in zip(self.metrics[t].metric_names, metrics):
|
|
152
|
+
self.log(f"train/{t}_{metric_name}", metric_value)
|
|
153
|
+
|
|
154
|
+
# validation
|
|
155
|
+
|
|
156
|
+
def on_validation_epoch_start(self) -> None:
|
|
157
|
+
for t in self.tasks:
|
|
158
|
+
self.metrics[t].reset()
|
|
159
|
+
|
|
160
|
+
def validation_step(self, batch, batch_idx: int):
|
|
161
|
+
images, targets = batch
|
|
162
|
+
results = self._single_step(images, targets)
|
|
163
|
+
|
|
164
|
+
outputs = results["outputs"]
|
|
165
|
+
losses = results["losses"]
|
|
166
|
+
weighted_loss = results["weighted_loss"]
|
|
167
|
+
|
|
168
|
+
for i, t in enumerate(self.tasks):
|
|
169
|
+
self.log(f"val/{t}_loss", losses[i])
|
|
170
|
+
self.log("val/loss", weighted_loss, prog_bar=True)
|
|
171
|
+
|
|
172
|
+
def on_validation_epoch_end(self) -> None:
|
|
173
|
+
for t in self.tasks:
|
|
174
|
+
metrics = cast(Metric, self.metrics[t]).compute()
|
|
175
|
+
for metric_name, metric_value in zip(self.metrics[t].metric_names, metrics):
|
|
176
|
+
self.log(f"val/{t}_{metric_name}", metric_value)
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import torch.nn as nn
|
|
3
|
+
from torch.hub import load_state_dict_from_url
|
|
4
|
+
|
|
5
|
+
# from torchvision.models.utils import load_state_dict_from_url
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
|
|
9
|
+
# 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
|
|
10
|
+
# 'wide_resnet50_2', 'wide_resnet101_2']
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
model_urls = {
|
|
14
|
+
"resnet18": "https://download.pytorch.org/models/resnet18-5c106cde.pth",
|
|
15
|
+
"resnet34": "https://download.pytorch.org/models/resnet34-333f7ec4.pth",
|
|
16
|
+
"resnet50": "https://download.pytorch.org/models/resnet50-19c8e357.pth",
|
|
17
|
+
"resnet101": "https://download.pytorch.org/models/resnet101-5d3b4d8f.pth",
|
|
18
|
+
"resnet152": "https://download.pytorch.org/models/resnet152-b121ed2d.pth",
|
|
19
|
+
"resnext50_32x4d": "https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth",
|
|
20
|
+
"resnext101_32x8d": "https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth",
|
|
21
|
+
"wide_resnet50_2": "https://download.pytorch.org/models/wide_resnet50_2-95faca4d.pth",
|
|
22
|
+
"wide_resnet101_2": "https://download.pytorch.org/models/wide_resnet101_2-32ee1156.pth",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
|
|
27
|
+
"""3x3 convolution with padding"""
|
|
28
|
+
return nn.Conv2d(
|
|
29
|
+
in_planes,
|
|
30
|
+
out_planes,
|
|
31
|
+
kernel_size=3,
|
|
32
|
+
stride=stride,
|
|
33
|
+
padding=dilation,
|
|
34
|
+
groups=groups,
|
|
35
|
+
bias=False,
|
|
36
|
+
dilation=dilation,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def conv1x1(in_planes, out_planes, stride=1):
|
|
41
|
+
"""1x1 convolution"""
|
|
42
|
+
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class BasicBlock(nn.Module):
|
|
46
|
+
expansion = 1
|
|
47
|
+
__constants__ = ["downsample"]
|
|
48
|
+
|
|
49
|
+
def __init__(
|
|
50
|
+
self,
|
|
51
|
+
inplanes,
|
|
52
|
+
planes,
|
|
53
|
+
stride=1,
|
|
54
|
+
downsample=None,
|
|
55
|
+
groups=1,
|
|
56
|
+
base_width=64,
|
|
57
|
+
dilation=1,
|
|
58
|
+
norm_layer=None,
|
|
59
|
+
):
|
|
60
|
+
super(BasicBlock, self).__init__()
|
|
61
|
+
if norm_layer is None:
|
|
62
|
+
norm_layer = nn.BatchNorm2d
|
|
63
|
+
if groups != 1 or base_width != 64:
|
|
64
|
+
raise ValueError("BasicBlock only supports groups=1 and base_width=64")
|
|
65
|
+
if dilation > 1:
|
|
66
|
+
raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
|
|
67
|
+
# Both self.conv1 and self.downsample layers downsample the input when stride != 1
|
|
68
|
+
self.conv1 = conv3x3(inplanes, planes, stride)
|
|
69
|
+
self.bn1 = norm_layer(planes)
|
|
70
|
+
self.relu = nn.ReLU(inplace=True)
|
|
71
|
+
self.conv2 = conv3x3(planes, planes)
|
|
72
|
+
self.bn2 = norm_layer(planes)
|
|
73
|
+
self.downsample = downsample
|
|
74
|
+
self.stride = stride
|
|
75
|
+
|
|
76
|
+
def forward(self, x):
|
|
77
|
+
identity = x
|
|
78
|
+
|
|
79
|
+
out = self.conv1(x)
|
|
80
|
+
out = self.bn1(out)
|
|
81
|
+
out = self.relu(out)
|
|
82
|
+
|
|
83
|
+
out = self.conv2(out)
|
|
84
|
+
out = self.bn2(out)
|
|
85
|
+
|
|
86
|
+
if self.downsample is not None:
|
|
87
|
+
identity = self.downsample(x)
|
|
88
|
+
|
|
89
|
+
out += identity
|
|
90
|
+
out = self.relu(out)
|
|
91
|
+
|
|
92
|
+
return out
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Bottleneck(nn.Module):
|
|
96
|
+
expansion = 4
|
|
97
|
+
__constants__ = ["downsample"]
|
|
98
|
+
|
|
99
|
+
def __init__(
|
|
100
|
+
self,
|
|
101
|
+
inplanes,
|
|
102
|
+
planes,
|
|
103
|
+
stride=1,
|
|
104
|
+
downsample=None,
|
|
105
|
+
groups=1,
|
|
106
|
+
base_width=64,
|
|
107
|
+
dilation=1,
|
|
108
|
+
norm_layer=None,
|
|
109
|
+
):
|
|
110
|
+
super(Bottleneck, self).__init__()
|
|
111
|
+
if norm_layer is None:
|
|
112
|
+
norm_layer = nn.BatchNorm2d
|
|
113
|
+
width = int(planes * (base_width / 64.0)) * groups
|
|
114
|
+
# Both self.conv2 and self.downsample layers downsample the input when stride != 1
|
|
115
|
+
self.conv1 = conv1x1(inplanes, width)
|
|
116
|
+
self.bn1 = norm_layer(width)
|
|
117
|
+
self.conv2 = conv3x3(width, width, stride, groups, dilation)
|
|
118
|
+
self.bn2 = norm_layer(width)
|
|
119
|
+
self.conv3 = conv1x1(width, planes * self.expansion)
|
|
120
|
+
self.bn3 = norm_layer(planes * self.expansion)
|
|
121
|
+
self.relu = nn.ReLU(inplace=True)
|
|
122
|
+
self.downsample = downsample
|
|
123
|
+
self.stride = stride
|
|
124
|
+
|
|
125
|
+
def forward(self, x):
|
|
126
|
+
identity = x
|
|
127
|
+
|
|
128
|
+
out = self.conv1(x)
|
|
129
|
+
out = self.bn1(out)
|
|
130
|
+
out = self.relu(out)
|
|
131
|
+
|
|
132
|
+
out = self.conv2(out)
|
|
133
|
+
out = self.bn2(out)
|
|
134
|
+
out = self.relu(out)
|
|
135
|
+
|
|
136
|
+
out = self.conv3(out)
|
|
137
|
+
out = self.bn3(out)
|
|
138
|
+
|
|
139
|
+
if self.downsample is not None:
|
|
140
|
+
identity = self.downsample(x)
|
|
141
|
+
|
|
142
|
+
out += identity
|
|
143
|
+
out = self.relu(out)
|
|
144
|
+
|
|
145
|
+
return out
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class ResNet(nn.Module):
|
|
149
|
+
def __init__(
|
|
150
|
+
self,
|
|
151
|
+
block,
|
|
152
|
+
layers,
|
|
153
|
+
num_classes=1000,
|
|
154
|
+
zero_init_residual=False,
|
|
155
|
+
groups=1,
|
|
156
|
+
width_per_group=64,
|
|
157
|
+
replace_stride_with_dilation=None,
|
|
158
|
+
norm_layer=None,
|
|
159
|
+
):
|
|
160
|
+
super(ResNet, self).__init__()
|
|
161
|
+
if norm_layer is None:
|
|
162
|
+
norm_layer = nn.BatchNorm2d
|
|
163
|
+
self._norm_layer = norm_layer
|
|
164
|
+
|
|
165
|
+
self.inplanes = 64
|
|
166
|
+
self.dilation = 1
|
|
167
|
+
if replace_stride_with_dilation is None:
|
|
168
|
+
# each element in the tuple indicates if we should replace
|
|
169
|
+
# the 2x2 stride with a dilated convolution instead
|
|
170
|
+
replace_stride_with_dilation = [False, False, False]
|
|
171
|
+
if len(replace_stride_with_dilation) != 3:
|
|
172
|
+
raise ValueError(
|
|
173
|
+
"replace_stride_with_dilation should be None "
|
|
174
|
+
"or a 3-element tuple, got {}".format(replace_stride_with_dilation)
|
|
175
|
+
)
|
|
176
|
+
self.groups = groups
|
|
177
|
+
self.base_width = width_per_group
|
|
178
|
+
self.conv1 = nn.Conv2d(
|
|
179
|
+
3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False
|
|
180
|
+
)
|
|
181
|
+
self.bn1 = norm_layer(self.inplanes)
|
|
182
|
+
self.relu = nn.ReLU(inplace=True)
|
|
183
|
+
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
|
|
184
|
+
self.layer1 = self._make_layer(block, 64, layers[0])
|
|
185
|
+
self.layer2 = self._make_layer(
|
|
186
|
+
block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]
|
|
187
|
+
)
|
|
188
|
+
self.layer3 = self._make_layer(
|
|
189
|
+
block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]
|
|
190
|
+
)
|
|
191
|
+
self.layer4 = self._make_layer(
|
|
192
|
+
block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]
|
|
193
|
+
)
|
|
194
|
+
# self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
|
|
195
|
+
# self.fc = nn.Linear(512 * block.expansion, num_classes)
|
|
196
|
+
self.feature_dim = 512 * block.expansion
|
|
197
|
+
for m in self.modules():
|
|
198
|
+
if isinstance(m, nn.Conv2d):
|
|
199
|
+
nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
|
|
200
|
+
elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
|
|
201
|
+
nn.init.constant_(m.weight, 1)
|
|
202
|
+
nn.init.constant_(m.bias, 0)
|
|
203
|
+
|
|
204
|
+
# Zero-initialize the last BN in each residual branch,
|
|
205
|
+
# so that the residual branch starts with zeros, and each residual block behaves like an identity.
|
|
206
|
+
# This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
|
|
207
|
+
if zero_init_residual:
|
|
208
|
+
for m in self.modules():
|
|
209
|
+
if isinstance(m, Bottleneck):
|
|
210
|
+
nn.init.constant_(m.bn3.weight, 0)
|
|
211
|
+
elif isinstance(m, BasicBlock):
|
|
212
|
+
nn.init.constant_(m.bn2.weight, 0)
|
|
213
|
+
|
|
214
|
+
def _make_layer(self, block, planes, blocks, stride=1, dilate=False):
|
|
215
|
+
norm_layer = self._norm_layer
|
|
216
|
+
downsample = None
|
|
217
|
+
previous_dilation = self.dilation
|
|
218
|
+
if dilate:
|
|
219
|
+
self.dilation *= stride
|
|
220
|
+
stride = 1
|
|
221
|
+
if stride != 1 or self.inplanes != planes * block.expansion:
|
|
222
|
+
downsample = nn.Sequential(
|
|
223
|
+
conv1x1(self.inplanes, planes * block.expansion, stride),
|
|
224
|
+
norm_layer(planes * block.expansion),
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
layers = []
|
|
228
|
+
layers.append(
|
|
229
|
+
block(
|
|
230
|
+
self.inplanes,
|
|
231
|
+
planes,
|
|
232
|
+
stride,
|
|
233
|
+
downsample,
|
|
234
|
+
self.groups,
|
|
235
|
+
self.base_width,
|
|
236
|
+
previous_dilation,
|
|
237
|
+
norm_layer,
|
|
238
|
+
)
|
|
239
|
+
)
|
|
240
|
+
self.inplanes = planes * block.expansion
|
|
241
|
+
for _ in range(1, blocks):
|
|
242
|
+
layers.append(
|
|
243
|
+
block(
|
|
244
|
+
self.inplanes,
|
|
245
|
+
planes,
|
|
246
|
+
groups=self.groups,
|
|
247
|
+
base_width=self.base_width,
|
|
248
|
+
dilation=self.dilation,
|
|
249
|
+
norm_layer=norm_layer,
|
|
250
|
+
)
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
return nn.Sequential(*layers)
|
|
254
|
+
|
|
255
|
+
def forward(self, x):
|
|
256
|
+
x = self.conv1(x)
|
|
257
|
+
x = self.bn1(x)
|
|
258
|
+
x = self.relu(x)
|
|
259
|
+
x = self.maxpool(x)
|
|
260
|
+
|
|
261
|
+
x = self.layer1(x)
|
|
262
|
+
x = self.layer2(x)
|
|
263
|
+
x = self.layer3(x)
|
|
264
|
+
x = self.layer4(x)
|
|
265
|
+
|
|
266
|
+
# We remove the original classifier, to attach task-specific decoders.
|
|
267
|
+
# x = self.avgpool(x)
|
|
268
|
+
# x = torch.flatten(x, 1)
|
|
269
|
+
# x = self.fc(x)
|
|
270
|
+
return x
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def _resnet(arch, block, layers, pretrained, progress, **kwargs):
|
|
274
|
+
model = ResNet(block, layers, **kwargs)
|
|
275
|
+
if pretrained:
|
|
276
|
+
state_dict = load_state_dict_from_url(model_urls[arch], progress=progress)
|
|
277
|
+
model.load_state_dict(state_dict, strict=False)
|
|
278
|
+
return model
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def resnet18(pretrained=False, progress=True, **kwargs):
|
|
282
|
+
r"""ResNet-18 model from
|
|
283
|
+
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
|
|
284
|
+
|
|
285
|
+
Args:
|
|
286
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
287
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
288
|
+
"""
|
|
289
|
+
return _resnet("resnet18", BasicBlock, [2, 2, 2, 2], pretrained, progress, **kwargs)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def resnet34(pretrained=False, progress=True, **kwargs):
|
|
293
|
+
r"""ResNet-34 model from
|
|
294
|
+
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
|
|
295
|
+
|
|
296
|
+
Args:
|
|
297
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
298
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
299
|
+
"""
|
|
300
|
+
return _resnet("resnet34", BasicBlock, [3, 4, 6, 3], pretrained, progress, **kwargs)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def resnet50(pretrained=False, progress=True, **kwargs):
|
|
304
|
+
r"""ResNet-50 model from
|
|
305
|
+
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
|
|
306
|
+
|
|
307
|
+
Args:
|
|
308
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
309
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
310
|
+
"""
|
|
311
|
+
return _resnet("resnet50", Bottleneck, [3, 4, 6, 3], pretrained, progress, **kwargs)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def resnet101(pretrained=False, progress=True, **kwargs):
|
|
315
|
+
r"""ResNet-101 model from
|
|
316
|
+
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
|
|
317
|
+
|
|
318
|
+
Args:
|
|
319
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
320
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
321
|
+
"""
|
|
322
|
+
return _resnet(
|
|
323
|
+
"resnet101", Bottleneck, [3, 4, 23, 3], pretrained, progress, **kwargs
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def resnet152(pretrained=False, progress=True, **kwargs):
|
|
328
|
+
r"""ResNet-152 model from
|
|
329
|
+
`"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_
|
|
330
|
+
|
|
331
|
+
Args:
|
|
332
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
333
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
334
|
+
"""
|
|
335
|
+
return _resnet(
|
|
336
|
+
"resnet152", Bottleneck, [3, 8, 36, 3], pretrained, progress, **kwargs
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def resnext50_32x4d(pretrained=False, progress=True, **kwargs):
|
|
341
|
+
r"""ResNeXt-50 32x4d model from
|
|
342
|
+
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
|
|
343
|
+
|
|
344
|
+
Args:
|
|
345
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
346
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
347
|
+
"""
|
|
348
|
+
kwargs["groups"] = 32
|
|
349
|
+
kwargs["width_per_group"] = 4
|
|
350
|
+
return _resnet(
|
|
351
|
+
"resnext50_32x4d", Bottleneck, [3, 4, 6, 3], pretrained, progress, **kwargs
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def resnext101_32x8d(pretrained=False, progress=True, **kwargs):
|
|
356
|
+
r"""ResNeXt-101 32x8d model from
|
|
357
|
+
`"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_
|
|
358
|
+
|
|
359
|
+
Args:
|
|
360
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
361
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
362
|
+
"""
|
|
363
|
+
kwargs["groups"] = 32
|
|
364
|
+
kwargs["width_per_group"] = 8
|
|
365
|
+
return _resnet(
|
|
366
|
+
"resnext101_32x8d", Bottleneck, [3, 4, 23, 3], pretrained, progress, **kwargs
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def wide_resnet50_2(pretrained=False, progress=True, **kwargs):
|
|
371
|
+
r"""Wide ResNet-50-2 model from
|
|
372
|
+
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_
|
|
373
|
+
|
|
374
|
+
The model is the same as ResNet except for the number of bottleneck channels
|
|
375
|
+
which is twice larger in every block. The number of channels in outer 1x1
|
|
376
|
+
convolutions is the same, e.g., the last block in ResNet-50 has 2048-512-2048
|
|
377
|
+
channels, while in wide ResNet-50-2 there are 2048-1024-2048.
|
|
378
|
+
|
|
379
|
+
Args:
|
|
380
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
381
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
382
|
+
"""
|
|
383
|
+
kwargs["width_per_group"] = 64 * 2
|
|
384
|
+
return _resnet(
|
|
385
|
+
"wide_resnet50_2", Bottleneck, [3, 4, 6, 3], pretrained, progress, **kwargs
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def wide_resnet101_2(pretrained=False, progress=True, **kwargs):
|
|
390
|
+
r"""Wide ResNet-101-2 model from
|
|
391
|
+
`"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_
|
|
392
|
+
|
|
393
|
+
The model is the same as ResNet except for the number of bottleneck channels
|
|
394
|
+
which is twice larger in every block. The number of channels in outer 1x1
|
|
395
|
+
convolutions is the same, e.g., the last block in ResNet-101 has 2048-512-2048
|
|
396
|
+
channels, while in wide ResNet-101-2 there are 2048-1024-2048.
|
|
397
|
+
|
|
398
|
+
Args:
|
|
399
|
+
pretrained (bool): If True, returns a model pre-trained on the ImageNet dataset.
|
|
400
|
+
progress (bool): If True, displays a progress bar of the download to stderr.
|
|
401
|
+
"""
|
|
402
|
+
kwargs["width_per_group"] = 64 * 2
|
|
403
|
+
return _resnet(
|
|
404
|
+
"wide_resnet101_2", Bottleneck, [3, 4, 23, 3], pretrained, progress, **kwargs
|
|
405
|
+
)
|