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,195 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from typing import Tuple
|
|
3
|
+
|
|
4
|
+
import cvxopt
|
|
5
|
+
import cvxpy as cp
|
|
6
|
+
import numpy as np
|
|
7
|
+
import torch
|
|
8
|
+
from torch import Tensor
|
|
9
|
+
|
|
10
|
+
"""Implementation of Pareto HyperNetworks with:
|
|
11
|
+
1. Linear scalarization
|
|
12
|
+
3. EPO
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
EPO code from: https://github.com/dbmptr/EPOSearch
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Solver:
|
|
20
|
+
def __init__(self, n_tasks):
|
|
21
|
+
super().__init__()
|
|
22
|
+
self.n_tasks = n_tasks
|
|
23
|
+
|
|
24
|
+
@abstractmethod
|
|
25
|
+
def get_weighted_loss(self, losses, ray, parameters=None, **kwargs):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def __call__(self, losses, ray, parameters, **kwargs):
|
|
29
|
+
return self.get_weighted_loss(losses, ray, parameters, **kwargs)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class LinearScalarizationSolver(Solver):
|
|
33
|
+
"""For LS we use the preference ray to weigh the losses"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, n_tasks):
|
|
36
|
+
super().__init__(n_tasks)
|
|
37
|
+
|
|
38
|
+
def get_weighted_loss(self, losses, ray, parameters=None, **kwargs):
|
|
39
|
+
return (losses * ray).sum()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class EPOSolver(Solver):
|
|
43
|
+
"""Wrapper over EPO"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, n_tasks, n_params):
|
|
46
|
+
super().__init__(n_tasks)
|
|
47
|
+
self.solver = EPO(n_tasks=n_tasks, n_params=n_params)
|
|
48
|
+
|
|
49
|
+
def get_weighted_loss(
|
|
50
|
+
self, losses, ray, parameters: Tuple[Tensor] = None, **kwargs
|
|
51
|
+
):
|
|
52
|
+
assert parameters is not None
|
|
53
|
+
return self.solver.get_weighted_loss(losses, ray, parameters)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class EPO:
|
|
57
|
+
def __init__(self, n_tasks, n_params):
|
|
58
|
+
self.n_tasks = n_tasks
|
|
59
|
+
self.n_params = n_params
|
|
60
|
+
|
|
61
|
+
def __call__(self, losses, ray, parameters):
|
|
62
|
+
return self.get_weighted_loss(losses, ray, parameters)
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def _flattening(grad: Tuple[Tensor]) -> Tensor:
|
|
66
|
+
return torch.cat(tuple(g.flatten() for g in grad), dim=0)
|
|
67
|
+
|
|
68
|
+
def get_weighted_loss(
|
|
69
|
+
self,
|
|
70
|
+
losses: Tuple[Tensor],
|
|
71
|
+
ray: Tensor,
|
|
72
|
+
parameters: Tuple[Tensor],
|
|
73
|
+
):
|
|
74
|
+
lp = ExactParetoLP(m=self.n_tasks, n=self.n_params, r=ray.cpu().numpy())
|
|
75
|
+
|
|
76
|
+
grads = []
|
|
77
|
+
for i, loss in enumerate(losses):
|
|
78
|
+
g = torch.autograd.grad(
|
|
79
|
+
loss, parameters, retain_graph=True, allow_unused=True
|
|
80
|
+
)
|
|
81
|
+
g = tuple(filter(lambda x: x is not None, g))
|
|
82
|
+
flat_grad = self._flattening(g)
|
|
83
|
+
grads.append(flat_grad.data)
|
|
84
|
+
|
|
85
|
+
G = torch.stack(grads)
|
|
86
|
+
GG_T = G @ G.T
|
|
87
|
+
GG_T = GG_T.detach().cpu().numpy()
|
|
88
|
+
|
|
89
|
+
numpy_losses = losses.detach().cpu().numpy()
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
alpha = lp.get_alpha(numpy_losses, G=GG_T, C=True)
|
|
93
|
+
except Exception as excep:
|
|
94
|
+
print(excep)
|
|
95
|
+
alpha = None
|
|
96
|
+
|
|
97
|
+
if alpha is None: # A patch for the issue in cvxpy
|
|
98
|
+
alpha = (ray / ray.sum()).cpu().numpy()
|
|
99
|
+
|
|
100
|
+
alpha *= self.n_tasks
|
|
101
|
+
alpha = torch.from_numpy(alpha).to(losses.device)
|
|
102
|
+
|
|
103
|
+
weighted_loss = torch.sum(losses * alpha)
|
|
104
|
+
return weighted_loss
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class ExactParetoLP(object):
|
|
108
|
+
"""modifications of the code in https://github.com/dbmptr/EPOSearch"""
|
|
109
|
+
|
|
110
|
+
def __init__(self, m, n, r, eps=1e-4):
|
|
111
|
+
cvxopt.glpk.options["msg_lev"] = "GLP_MSG_OFF"
|
|
112
|
+
self.m = m
|
|
113
|
+
self.n = n
|
|
114
|
+
self.r = r
|
|
115
|
+
self.eps = eps
|
|
116
|
+
self.last_move = None
|
|
117
|
+
self.a = cp.Parameter(m) # Adjustments
|
|
118
|
+
self.C = cp.Parameter((m, m)) # C: Gradient inner products, G^T G
|
|
119
|
+
self.Ca = cp.Parameter(m) # d_bal^TG
|
|
120
|
+
self.rhs = cp.Parameter(m) # RHS of constraints for balancing
|
|
121
|
+
|
|
122
|
+
self.alpha = cp.Variable(m) # Variable to optimize
|
|
123
|
+
|
|
124
|
+
obj_bal = cp.Maximize(self.alpha @ self.Ca) # objective for balance
|
|
125
|
+
constraints_bal = [
|
|
126
|
+
self.alpha >= 0,
|
|
127
|
+
cp.sum(self.alpha) == 1, # Simplex
|
|
128
|
+
self.C @ self.alpha >= self.rhs,
|
|
129
|
+
]
|
|
130
|
+
self.prob_bal = cp.Problem(obj_bal, constraints_bal) # LP balance
|
|
131
|
+
|
|
132
|
+
obj_dom = cp.Maximize(cp.sum(self.alpha @ self.C)) # obj for descent
|
|
133
|
+
constraints_res = [
|
|
134
|
+
self.alpha >= 0,
|
|
135
|
+
cp.sum(self.alpha) == 1, # Restrict
|
|
136
|
+
self.alpha @ self.Ca >= -cp.neg(cp.max(self.Ca)),
|
|
137
|
+
self.C @ self.alpha >= 0,
|
|
138
|
+
]
|
|
139
|
+
constraints_rel = [
|
|
140
|
+
self.alpha >= 0,
|
|
141
|
+
cp.sum(self.alpha) == 1, # Relaxed
|
|
142
|
+
self.C @ self.alpha >= 0,
|
|
143
|
+
]
|
|
144
|
+
self.prob_dom = cp.Problem(obj_dom, constraints_res) # LP dominance
|
|
145
|
+
self.prob_rel = cp.Problem(obj_dom, constraints_rel) # LP dominance
|
|
146
|
+
|
|
147
|
+
self.gamma = 0 # Stores the latest Optimum value of the LP problem
|
|
148
|
+
self.mu_rl = 0 # Stores the latest non-uniformity
|
|
149
|
+
|
|
150
|
+
def get_alpha(self, loss_terms, G: Tensor, r=None, C: bool = False, relax=False):
|
|
151
|
+
r = self.r if r is None else r
|
|
152
|
+
assert len(loss_terms) == len(G) == len(r) == self.m, "length != m"
|
|
153
|
+
rl, self.mu_rl, self.a.value = adjustments(loss_terms, r)
|
|
154
|
+
self.C.value = G if C else G @ G.T
|
|
155
|
+
self.Ca.value = self.C.value @ self.a.value
|
|
156
|
+
|
|
157
|
+
if self.mu_rl > self.eps:
|
|
158
|
+
J = self.Ca.value > 0
|
|
159
|
+
if len(np.where(J)[0]) > 0:
|
|
160
|
+
J_star_idx = np.where(rl == np.max(rl))[0]
|
|
161
|
+
self.rhs.value = self.Ca.value.copy()
|
|
162
|
+
self.rhs.value[J] = -np.inf # Not efficient; but works.
|
|
163
|
+
self.rhs.value[J_star_idx] = 0
|
|
164
|
+
else:
|
|
165
|
+
self.rhs.value = np.zeros_like(self.Ca.value)
|
|
166
|
+
self.gamma = self.prob_bal.solve(solver=cp.GLPK, verbose=False)
|
|
167
|
+
self.last_move = "bal"
|
|
168
|
+
else:
|
|
169
|
+
if relax:
|
|
170
|
+
self.gamma = self.prob_rel.solve(solver=cp.GLPK, verbose=False)
|
|
171
|
+
else:
|
|
172
|
+
self.gamma = self.prob_dom.solve(solver=cp.GLPK, verbose=False)
|
|
173
|
+
self.last_move = "dom"
|
|
174
|
+
|
|
175
|
+
return self.alpha.value
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def mu(rl, normed=False):
|
|
179
|
+
if len(np.where(rl < 0)[0]):
|
|
180
|
+
raise ValueError(f"rl<0 \n rl={rl}")
|
|
181
|
+
# return None
|
|
182
|
+
m = len(rl)
|
|
183
|
+
l_hat = rl if normed else rl / rl.sum()
|
|
184
|
+
eps = np.finfo(rl.dtype).eps
|
|
185
|
+
l_hat = l_hat[l_hat > eps]
|
|
186
|
+
return np.sum(l_hat * np.log(l_hat * m))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def adjustments(l, r=1):
|
|
190
|
+
m = len(l)
|
|
191
|
+
rl = r * l
|
|
192
|
+
l_hat = rl / rl.sum()
|
|
193
|
+
mu_rl = mu(l_hat, normed=True)
|
|
194
|
+
a = r * (np.log(l_hat * m) - mu_rl)
|
|
195
|
+
return rl, mu_rl, a
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def generate_simplex_grid(n: int, m: int):
|
|
7
|
+
"""
|
|
8
|
+
Generate a uniform grid of points on the n-dimensional simplex.
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
|
|
12
|
+
>>> generate_simplex_grid(3,2)
|
|
13
|
+
array([[0., 0., 1.],
|
|
14
|
+
[0., 1., 0.],
|
|
15
|
+
[1., 0., 0.]], dtype=float32)
|
|
16
|
+
|
|
17
|
+
>>> generate_simplex_grid(2,3)
|
|
18
|
+
array([[0. , 1. ],
|
|
19
|
+
[0.5, 0.5],
|
|
20
|
+
[1. , 0. ]], dtype=float32)
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
n (int): The dimension of the simplex.
|
|
24
|
+
m (int): The number of grid points along each dimension.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
list: A list of n-dimensional vectors representing the grid points.
|
|
28
|
+
"""
|
|
29
|
+
m = m - 1
|
|
30
|
+
# Generate all combinations of indices summing up to m
|
|
31
|
+
indices = list(itertools.combinations_with_replacement(range(m + 1), n - 1))
|
|
32
|
+
# Initialize an empty list to store the grid points
|
|
33
|
+
grid_points = []
|
|
34
|
+
|
|
35
|
+
# Iterate over each combination of indices
|
|
36
|
+
for idx in indices:
|
|
37
|
+
# Append 0 and m to the indices
|
|
38
|
+
extended_idx = [0] + list(idx) + [m]
|
|
39
|
+
# Compute the vector components by taking the differences between consecutive indices and dividing by m
|
|
40
|
+
point = [(extended_idx[i + 1] - extended_idx[i]) / m for i in range(n)]
|
|
41
|
+
grid_points.append(point)
|
|
42
|
+
|
|
43
|
+
return np.array(grid_points, dtype=np.float32)
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
|
|
6
|
+
import torch
|
|
7
|
+
from torch import Tensor
|
|
8
|
+
from torch.utils.data import DataLoader
|
|
9
|
+
from transformers.models.clip.modeling_clip import CLIPEncoder
|
|
10
|
+
|
|
11
|
+
from fusion_bench.dataset import CLIPDataset
|
|
12
|
+
from fusion_bench.method.task_arithmetic.task_arithmetic import task_arithmetic_merge
|
|
13
|
+
from fusion_bench.mixins import CLIPClassificationMixin
|
|
14
|
+
from fusion_bench.modelpool import CLIPVisionModelPool
|
|
15
|
+
from fusion_bench.models.rankone_moe import RankOneMoE
|
|
16
|
+
from fusion_bench.utils.data import InfiniteDataLoader
|
|
17
|
+
|
|
18
|
+
from .rankone_moe import RankOneMoEAlgorithm
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CLIPRankOneMoEAlgorithm(
|
|
24
|
+
RankOneMoEAlgorithm,
|
|
25
|
+
CLIPClassificationMixin,
|
|
26
|
+
):
|
|
27
|
+
"""
|
|
28
|
+
CLIPRankOneMoEAlgorithm is a class that implements the RankOneMoEAlgorithm (https://github.com/EnnengYang/RankOne-MoE)
|
|
29
|
+
for CLIP models. It extends the RankOneMoEAlgorithm and CLIPClassificationMixin classes.
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
modelpool (CLIPVisionModelPool): The model pool containing the CLIP models.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
modelpool: CLIPVisionModelPool = None
|
|
36
|
+
|
|
37
|
+
def load_checkpoint(self, model, checkpoint):
|
|
38
|
+
"""
|
|
39
|
+
Load the checkpoint file.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
model: The model to load the checkpoint into.
|
|
43
|
+
checkpoint: The path to the checkpoint file.
|
|
44
|
+
"""
|
|
45
|
+
state = {"model": model}
|
|
46
|
+
self._fabric.load(checkpoint, state)
|
|
47
|
+
|
|
48
|
+
def save_checkpoint(self, model, checkpoint):
|
|
49
|
+
"""
|
|
50
|
+
Save the checkpoint file.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
model: The model to save the checkpoint from.
|
|
54
|
+
checkpoint: The path to the checkpoint file.
|
|
55
|
+
"""
|
|
56
|
+
self._fabric.save(checkpoint, {"model": model})
|
|
57
|
+
|
|
58
|
+
def construct_moe_model(self) -> RankOneMoE:
|
|
59
|
+
"""
|
|
60
|
+
Construct the RankOne-MoE model using the models in the model pool.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
RankOne-MoE: The constructed MoE model.
|
|
64
|
+
"""
|
|
65
|
+
base_model = self.modelpool.load_model("_pretrained_")
|
|
66
|
+
expert_models = [
|
|
67
|
+
self.modelpool.load_model(m) for m in self.modelpool.model_names
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
# Merge the models using task arithmetic
|
|
71
|
+
moe_model = task_arithmetic_merge(
|
|
72
|
+
# This function modifies the model in place, so we need to pass a deepcopy
|
|
73
|
+
deepcopy(base_model),
|
|
74
|
+
expert_models,
|
|
75
|
+
scaling_factor=self.config.init_lambda,
|
|
76
|
+
).requires_grad_(False)
|
|
77
|
+
|
|
78
|
+
# Up-scale MLP modules
|
|
79
|
+
base_encoder: CLIPEncoder = base_model.vision_model.encoder
|
|
80
|
+
moe_encoder: CLIPEncoder = moe_model.vision_model.encoder
|
|
81
|
+
expert_encoders = [m.vision_model.encoder for m in expert_models]
|
|
82
|
+
|
|
83
|
+
num_layers = len(base_encoder.layers)
|
|
84
|
+
for layer_idx in range(num_layers):
|
|
85
|
+
base_mlp = base_encoder.layers[layer_idx].mlp
|
|
86
|
+
expert_mlps = [e.layers[layer_idx].mlp for e in expert_encoders]
|
|
87
|
+
|
|
88
|
+
moe_encoder.layers[layer_idx].mlp = RankOneMoE(
|
|
89
|
+
hidden_size=base_encoder.config.hidden_size,
|
|
90
|
+
base_model=base_mlp,
|
|
91
|
+
expert_models=expert_mlps,
|
|
92
|
+
init_lambda=self.config.init_lambda,
|
|
93
|
+
batch_first=True, # For open_clip models this is False
|
|
94
|
+
router_hidden_layers=self.config.router_hidden_layers,
|
|
95
|
+
batch_reduce=self.config.batch_reduce,
|
|
96
|
+
svd_accelerator=self.config.svd_accelerator,
|
|
97
|
+
rank_k=self.config.rank_k,
|
|
98
|
+
select_k=self.config.select_k,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return moe_model
|
|
102
|
+
|
|
103
|
+
@functools.cache
|
|
104
|
+
def get_shuffled_test_loader_iter(self, tta_dataset: str):
|
|
105
|
+
"""
|
|
106
|
+
Get an iterator for the shuffled test data loader.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
tta_dataset (str): The name of the test-time adaptation dataset.
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
Iterator: An iterator for the shuffled test data loader.
|
|
113
|
+
"""
|
|
114
|
+
dataset = self.modelpool.load_test_dataset(tta_dataset)
|
|
115
|
+
dataset = CLIPDataset(dataset, processor=self.clip_processor)
|
|
116
|
+
log.info("get_shuffled_test_loader_iter")
|
|
117
|
+
loader = DataLoader(
|
|
118
|
+
dataset,
|
|
119
|
+
batch_size=self.config.batch_size,
|
|
120
|
+
shuffle=True,
|
|
121
|
+
num_workers=self.config.num_workers,
|
|
122
|
+
pin_memory=True,
|
|
123
|
+
)
|
|
124
|
+
loader = self.fabric.setup_dataloaders(loader)
|
|
125
|
+
return iter(InfiniteDataLoader(loader))
|
|
126
|
+
|
|
127
|
+
def on_test_time_adaptation_start(self):
|
|
128
|
+
"""
|
|
129
|
+
Load the CLIP processor and construct the zero-shot classification head for each task.
|
|
130
|
+
"""
|
|
131
|
+
self.setup_zero_shot_classification_head()
|
|
132
|
+
|
|
133
|
+
def compute_logits(self, module, batch, task) -> Tensor:
|
|
134
|
+
"""
|
|
135
|
+
Compute the logits for the given batch and task.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
module: The model module.
|
|
139
|
+
batch: The input batch.
|
|
140
|
+
task: The task name.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Tensor: The computed logits.
|
|
144
|
+
"""
|
|
145
|
+
images, _ = batch
|
|
146
|
+
text_embeds = self.zeroshot_weights[task]
|
|
147
|
+
|
|
148
|
+
image_embeds = module(images)[1]
|
|
149
|
+
image_embeds = self.visual_projection(image_embeds)
|
|
150
|
+
|
|
151
|
+
# Normalize embeddings
|
|
152
|
+
image_embeds = image_embeds / image_embeds.norm(p=2, dim=-1, keepdim=True)
|
|
153
|
+
|
|
154
|
+
# Cosine similarity
|
|
155
|
+
logits_per_text = (
|
|
156
|
+
torch.matmul(text_embeds, image_embeds.t()) * self.logit_scale_exp
|
|
157
|
+
)
|
|
158
|
+
logits_per_image = logits_per_text.t()
|
|
159
|
+
|
|
160
|
+
return logits_per_image
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from abc import abstractmethod
|
|
3
|
+
from typing import cast # noqa: F401
|
|
4
|
+
|
|
5
|
+
import lightning as L
|
|
6
|
+
import lightning.fabric.wrappers
|
|
7
|
+
import torch
|
|
8
|
+
from lightning.pytorch.profilers import SimpleProfiler
|
|
9
|
+
from omegaconf import DictConfig
|
|
10
|
+
from torch import Tensor
|
|
11
|
+
from torch.utils.data import DataLoader
|
|
12
|
+
from tqdm.autonotebook import tqdm
|
|
13
|
+
|
|
14
|
+
from fusion_bench.compat.method.base_algorithm import ModelFusionAlgorithm
|
|
15
|
+
from fusion_bench.compat.modelpool import ModelPool
|
|
16
|
+
from fusion_bench.models.rankone_moe import RankOneMoE
|
|
17
|
+
from fusion_bench.utils import timeit_context
|
|
18
|
+
from fusion_bench.utils.parameters import print_parameters
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def entropy_loss(logits: Tensor) -> Tensor:
|
|
24
|
+
"""
|
|
25
|
+
Compute the entropy loss of a set of logits.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
logits (Tensor): The logits to compute the entropy loss of.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
Tensor: The entropy loss of the logits.
|
|
32
|
+
"""
|
|
33
|
+
probs = torch.softmax(logits, dim=-1)
|
|
34
|
+
return -torch.sum(probs * torch.log(probs + 1e-8), dim=-1).mean()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class RankOneMoEAlgorithm(ModelFusionAlgorithm):
|
|
38
|
+
"""
|
|
39
|
+
Algorithm for fusing models using RankOne-MoE (https://github.com/EnnengYang/RankOne-MoE).
|
|
40
|
+
|
|
41
|
+
This class provides methods for constructing the MoE model, performing test-time adaptation,
|
|
42
|
+
and running the fusion process.
|
|
43
|
+
|
|
44
|
+
Attributes:
|
|
45
|
+
_fabric (L.Fabric): The fabric for distributed training.
|
|
46
|
+
modelpool (ModelPool): The pool of models to be fused.
|
|
47
|
+
profiler (SimpleProfiler): The profiler for measuring performance.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
_fabric: L.Fabric = None
|
|
51
|
+
modelpool: ModelPool = None
|
|
52
|
+
|
|
53
|
+
def __init__(self, algorithm_config: DictConfig):
|
|
54
|
+
"""
|
|
55
|
+
Initialize the RankOneMoEAlgorithm with the given configuration.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
algorithm_config (DictConfig): The configuration for the algorithm.
|
|
59
|
+
"""
|
|
60
|
+
super().__init__(algorithm_config)
|
|
61
|
+
|
|
62
|
+
if self._fabric is None and torch.cuda.is_available():
|
|
63
|
+
self._fabric = L.Fabric(
|
|
64
|
+
devices=self.config.get("devices", 1),
|
|
65
|
+
)
|
|
66
|
+
self._fabric.launch()
|
|
67
|
+
else:
|
|
68
|
+
assert "No CUDA device available."
|
|
69
|
+
self.profiler = SimpleProfiler(
|
|
70
|
+
self.config.get("cache_dir", "outputs"), "we_moe_profiler.txt"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
@abstractmethod
|
|
74
|
+
def load_checkpoint(self, model, checkpoint):
|
|
75
|
+
"""
|
|
76
|
+
Load the checkpoint file.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
model: The model to load the checkpoint into.
|
|
80
|
+
checkpoint: The checkpoint file to load.
|
|
81
|
+
"""
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
@abstractmethod
|
|
85
|
+
def save_checkpoint(self, model, checkpoint):
|
|
86
|
+
"""
|
|
87
|
+
Save the checkpoint file.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
model: The model to save the checkpoint from.
|
|
91
|
+
checkpoint: The checkpoint file to save.
|
|
92
|
+
"""
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
def construct_moe_model(self) -> RankOneMoE:
|
|
97
|
+
"""
|
|
98
|
+
Construct the Mixture of Experts model using the models in the model pool.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
RankOne-MoE: The constructed MoE model.
|
|
102
|
+
"""
|
|
103
|
+
pass
|
|
104
|
+
|
|
105
|
+
def on_test_time_adaptation_start(self):
|
|
106
|
+
"""
|
|
107
|
+
Hook method called at the start of test-time adaptation.
|
|
108
|
+
"""
|
|
109
|
+
pass
|
|
110
|
+
|
|
111
|
+
@abstractmethod
|
|
112
|
+
def get_shuffled_test_loader_iter(self, task: str) -> DataLoader:
|
|
113
|
+
"""
|
|
114
|
+
Get an iterator for the shuffled test data loader for a specific task.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
task (str): The task for which to get the test data loader.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
DataLoader: The shuffled test data loader iterator.
|
|
121
|
+
"""
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
@abstractmethod
|
|
125
|
+
def compute_logits(self, module, batch, task) -> Tensor:
|
|
126
|
+
"""
|
|
127
|
+
Compute the logits for a given batch and task.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
module: The model module to use for computing logits.
|
|
131
|
+
batch: The batch of data.
|
|
132
|
+
task: The task for which to compute logits.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Tensor: The computed logits.
|
|
136
|
+
"""
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
def test_time_adaptation(self, module: RankOneMoE):
|
|
140
|
+
"""
|
|
141
|
+
Perform test-time adaptation for the given module.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
module (RankOne-MoE): The MoE module to adapt.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
RankOne-MoE: The adapted MoE module.
|
|
148
|
+
"""
|
|
149
|
+
self.on_test_time_adaptation_start()
|
|
150
|
+
|
|
151
|
+
# configure optimizer
|
|
152
|
+
if self.config.optimizer == "adam":
|
|
153
|
+
optimizer = torch.optim.Adam(
|
|
154
|
+
[p for p in module.parameters() if p.requires_grad], lr=self.config.lr
|
|
155
|
+
)
|
|
156
|
+
else:
|
|
157
|
+
raise ValueError(f"Unsupported optimizer: {self.config.optimizer}")
|
|
158
|
+
|
|
159
|
+
if self._fabric is not None:
|
|
160
|
+
module, optimizer = self._fabric.setup(module, optimizer)
|
|
161
|
+
|
|
162
|
+
module.train()
|
|
163
|
+
|
|
164
|
+
if self.config.get("fast_dev_run", False):
|
|
165
|
+
log.info("Running fast_dev_run, only one step")
|
|
166
|
+
pbar = tqdm(
|
|
167
|
+
range(1),
|
|
168
|
+
"Test-time adaptation",
|
|
169
|
+
dynamic_ncols=True,
|
|
170
|
+
)
|
|
171
|
+
else:
|
|
172
|
+
pbar = tqdm(
|
|
173
|
+
range(self.config.max_steps),
|
|
174
|
+
"Test-time adaptation",
|
|
175
|
+
dynamic_ncols=True,
|
|
176
|
+
)
|
|
177
|
+
for step_idx in pbar:
|
|
178
|
+
if self.config.use_grad_accumulate:
|
|
179
|
+
for task in self.modelpool.model_names:
|
|
180
|
+
with self.profiler.profile("data time"):
|
|
181
|
+
batch = next(self.get_shuffled_test_loader_iter(task))
|
|
182
|
+
with self.profiler.profile("forward pass"):
|
|
183
|
+
logits = self.compute_logits(module, batch, task)
|
|
184
|
+
assert (
|
|
185
|
+
logits.dim() == 2
|
|
186
|
+
), f"Expected logits to be 2D, got {logits.dim()}"
|
|
187
|
+
loss = entropy_loss(logits)
|
|
188
|
+
# .backward() accumulates when .zero_grad() wasn't called
|
|
189
|
+
# this can save memory
|
|
190
|
+
with self.profiler.profile("backward pass"):
|
|
191
|
+
self._fabric.backward(loss, retain_graph=True)
|
|
192
|
+
else:
|
|
193
|
+
loss = 0
|
|
194
|
+
for task in self.modelpool.model_names:
|
|
195
|
+
with self.profiler.profile("data time"):
|
|
196
|
+
batch = next(self.get_shuffled_test_loader_iter(task))
|
|
197
|
+
with self.profiler.profile("forward pass"):
|
|
198
|
+
logits = self.compute_logits(module, batch, task)
|
|
199
|
+
assert (
|
|
200
|
+
logits.dim() == 2
|
|
201
|
+
), f"Expected logits to be 2D, got {logits.dim()}"
|
|
202
|
+
loss = loss + entropy_loss(logits)
|
|
203
|
+
with self.profiler.profile("backward pass"):
|
|
204
|
+
self._fabric.backward(loss, retain_graph=True)
|
|
205
|
+
|
|
206
|
+
with self.profiler.profile("optimizer step"):
|
|
207
|
+
optimizer.step()
|
|
208
|
+
optimizer.zero_grad()
|
|
209
|
+
|
|
210
|
+
# print([m for m in module.parameters() if m.requires_grad][0])
|
|
211
|
+
|
|
212
|
+
return module
|
|
213
|
+
|
|
214
|
+
def run(self, modelpool: ModelPool):
|
|
215
|
+
"""
|
|
216
|
+
Run the RankOneMoEAlgorithm to fuse models using RankOne-MoE.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
modelpool (ModelPool): The pool of models to be fused.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
RankOne-MoE: The fused RankOne MoE model.
|
|
223
|
+
"""
|
|
224
|
+
log.info("Fusing models using RankOne-MoE modules.")
|
|
225
|
+
self.modelpool = modelpool
|
|
226
|
+
|
|
227
|
+
with timeit_context("upscaling models to a RankOne-MoE model"):
|
|
228
|
+
moe_model = self.construct_moe_model()
|
|
229
|
+
print_parameters(moe_model)
|
|
230
|
+
|
|
231
|
+
if self.config.get("checkpoint", False):
|
|
232
|
+
log.info(
|
|
233
|
+
f"load checkpoint from {self.config.checkpoint}, test-time adaptation will be skipped."
|
|
234
|
+
)
|
|
235
|
+
self.load_checkpoint(moe_model, self.config.checkpoint)
|
|
236
|
+
else:
|
|
237
|
+
with self.profiler.profile("test-time adaptation"):
|
|
238
|
+
moe_model = self.test_time_adaptation(moe_model)
|
|
239
|
+
if self.config.get("save_checkpoint", False):
|
|
240
|
+
log.info(f"save checkpoint to {self.config.save_checkpoint}")
|
|
241
|
+
self.save_checkpoint(moe_model, self.config.save_checkpoint)
|
|
242
|
+
|
|
243
|
+
if lightning.fabric.wrappers.is_wrapped(moe_model):
|
|
244
|
+
moe_model = lightning.fabric.wrappers._unwrap_objects(moe_model)
|
|
245
|
+
|
|
246
|
+
# enable sample-wise adaptation
|
|
247
|
+
moe_model.batch_reduce = False
|
|
248
|
+
print(self.profiler.summary())
|
|
249
|
+
return moe_model
|