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,149 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import itertools
|
|
3
|
+
import logging
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
import torch
|
|
8
|
+
import torch.nn.functional as F
|
|
9
|
+
from omegaconf import DictConfig
|
|
10
|
+
from torch.utils.data import DataLoader
|
|
11
|
+
from torchmetrics import Accuracy, MeanMetric
|
|
12
|
+
from tqdm.autonotebook import tqdm
|
|
13
|
+
from transformers import (
|
|
14
|
+
GPT2ForSequenceClassification,
|
|
15
|
+
GPT2Model,
|
|
16
|
+
GPT2Tokenizer,
|
|
17
|
+
default_data_collator,
|
|
18
|
+
)
|
|
19
|
+
from typing_extensions import override
|
|
20
|
+
|
|
21
|
+
from fusion_bench.dataset.gpt2_glue import TokenizedGLUE
|
|
22
|
+
from fusion_bench.mixins import LightningFabricMixin
|
|
23
|
+
from fusion_bench.taskpool import BaseTaskPool
|
|
24
|
+
from fusion_bench.utils import instantiate
|
|
25
|
+
|
|
26
|
+
log = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
tokenizer: GPT2Tokenizer = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@functools.cache
|
|
32
|
+
def load_gpt2_dataset(name: str, split: Optional[str] = None):
|
|
33
|
+
global tokenizer
|
|
34
|
+
dataset = TokenizedGLUE(tokenizer=tokenizer).load_dataset(name)
|
|
35
|
+
if split is not None:
|
|
36
|
+
dataset = dataset[split]
|
|
37
|
+
return dataset
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class GPT2TextClassificationTaskPool(BaseTaskPool, LightningFabricMixin):
|
|
41
|
+
"""
|
|
42
|
+
A task pool for GPT2 text classification tasks.
|
|
43
|
+
This class manages the tasks and provides methods for loading test dataset and evaluation.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
_config_mapping = BaseTaskPool._config_mapping | {
|
|
47
|
+
"_test_datasets": "test_datasets",
|
|
48
|
+
"_tokenizer": "tokenizer",
|
|
49
|
+
"dataloader_kwargs": "dataloader_kwargs",
|
|
50
|
+
"fast_dev_run": "fast_dev_run",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
test_datasets: DictConfig,
|
|
56
|
+
tokenizer: DictConfig,
|
|
57
|
+
dataloader_kwargs: DictConfig,
|
|
58
|
+
fast_dev_run: bool,
|
|
59
|
+
**kwargs,
|
|
60
|
+
):
|
|
61
|
+
self._test_datasets = test_datasets
|
|
62
|
+
self._tokenizer = tokenizer
|
|
63
|
+
self.dataloader_kwargs = dataloader_kwargs
|
|
64
|
+
self.fast_dev_run = fast_dev_run
|
|
65
|
+
super().__init__(**kwargs)
|
|
66
|
+
|
|
67
|
+
self.setup()
|
|
68
|
+
|
|
69
|
+
def setup(self):
|
|
70
|
+
global tokenizer
|
|
71
|
+
self.tokenizer = tokenizer = instantiate(self._tokenizer)
|
|
72
|
+
|
|
73
|
+
def get_classifier(
|
|
74
|
+
self, task_name: str, model: GPT2Model
|
|
75
|
+
) -> GPT2ForSequenceClassification:
|
|
76
|
+
modelpool = self._program.modelpool
|
|
77
|
+
classifier = modelpool.load_classifier(task_name)
|
|
78
|
+
classifier.transformer = deepcopy(model)
|
|
79
|
+
return classifier
|
|
80
|
+
|
|
81
|
+
@torch.no_grad()
|
|
82
|
+
def evaluate_single_task(
|
|
83
|
+
self,
|
|
84
|
+
task_name: str,
|
|
85
|
+
model: GPT2Model,
|
|
86
|
+
test_loader: DataLoader,
|
|
87
|
+
):
|
|
88
|
+
loss_metric = MeanMetric()
|
|
89
|
+
# load classifier and replace the backbone with the passed model
|
|
90
|
+
model: GPT2ForSequenceClassification = self.get_classifier(task_name, model)
|
|
91
|
+
accuracy = Accuracy("multiclass", num_classes=model.num_labels)
|
|
92
|
+
model = self.fabric.setup(model)
|
|
93
|
+
|
|
94
|
+
if self.config.get("fast_dev_run", False):
|
|
95
|
+
log.info("Running under fast_dev_run mode, evaluating on a single batch.")
|
|
96
|
+
test_loader = itertools.islice(test_loader, 1)
|
|
97
|
+
else:
|
|
98
|
+
test_loader = test_loader
|
|
99
|
+
|
|
100
|
+
for batch in (
|
|
101
|
+
pbar := tqdm(
|
|
102
|
+
test_loader, desc="Evaluating", leave=False, dynamic_ncols=True
|
|
103
|
+
)
|
|
104
|
+
):
|
|
105
|
+
input_ids = batch["input_ids"]
|
|
106
|
+
attention_mask = batch["attention_mask"]
|
|
107
|
+
labels = batch["labels"]
|
|
108
|
+
|
|
109
|
+
outputs = model(input_ids, attention_mask=attention_mask)
|
|
110
|
+
logits = outputs.logits
|
|
111
|
+
loss = F.cross_entropy(logits, labels)
|
|
112
|
+
|
|
113
|
+
accuracy(logits.detach().cpu(), labels.detach().cpu())
|
|
114
|
+
loss_metric.update(loss.detach().cpu())
|
|
115
|
+
pbar.set_postfix(
|
|
116
|
+
{
|
|
117
|
+
"accuracy": accuracy.compute().item(),
|
|
118
|
+
"loss": loss_metric.compute().item(),
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
acc = accuracy.compute().item()
|
|
123
|
+
loss = loss_metric.compute().item()
|
|
124
|
+
results = {"accuracy": acc, "loss": loss}
|
|
125
|
+
log.info(f"Results for task {task_name}: {results}")
|
|
126
|
+
return results
|
|
127
|
+
|
|
128
|
+
def get_test_dataloader(self, task_name: str):
|
|
129
|
+
dataset = instantiate(self._test_datasets[task_name])
|
|
130
|
+
dataloader_kwargs = {
|
|
131
|
+
"shuffle": False,
|
|
132
|
+
}
|
|
133
|
+
dataloader_kwargs.update(self.dataloader_kwargs)
|
|
134
|
+
dataloader = DataLoader(
|
|
135
|
+
dataset, collate_fn=default_data_collator, **dataloader_kwargs
|
|
136
|
+
)
|
|
137
|
+
if self.fabric is not None:
|
|
138
|
+
dataloader = self.fabric.setup_dataloaders(dataloader)
|
|
139
|
+
return dataloader
|
|
140
|
+
|
|
141
|
+
@override
|
|
142
|
+
def evaluate(self, model: GPT2Model):
|
|
143
|
+
report = {}
|
|
144
|
+
for task_name in (pbar := tqdm(self._test_datasets, desc="Evaluating tasks")):
|
|
145
|
+
pbar.set_description(f"Evaluating task {task_name}")
|
|
146
|
+
dataloader = self.get_test_dataloader(task_name)
|
|
147
|
+
result = self.evaluate_single_task(task_name, model, dataloader)
|
|
148
|
+
report[task_name] = result
|
|
149
|
+
return report
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .test_generation import LlamaTestGenerationTaskPool
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The dataset contains the following fields:
|
|
3
|
+
|
|
4
|
+
- chosen_input_ids: The input token ids for the winner.
|
|
5
|
+
- chosen_attention_mask: The attention mask for the winner.
|
|
6
|
+
- rejected_input_ids: The input token ids for the loser.
|
|
7
|
+
- rejected_attention_mask: The attention mask for the loser.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import functools
|
|
11
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
|
|
12
|
+
|
|
13
|
+
import lightning as L
|
|
14
|
+
import numpy as np
|
|
15
|
+
import torch
|
|
16
|
+
from omegaconf import DictConfig
|
|
17
|
+
from torch.utils.data import Subset
|
|
18
|
+
from tqdm.auto import tqdm
|
|
19
|
+
|
|
20
|
+
from fusion_bench.dataset.llama.collate import bradley_terry_rm_collate
|
|
21
|
+
from fusion_bench.mixins import LightningFabricMixin
|
|
22
|
+
from fusion_bench.taskpool import BaseTaskPool
|
|
23
|
+
from fusion_bench.utils import instantiate
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from transformers import LlamaForSequenceClassification
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def evaluate_batch(model: "LlamaForSequenceClassification", batch):
|
|
30
|
+
batch_size = batch["input_ids"].size(0)
|
|
31
|
+
assert batch_size % 2 == 0, "Batch size must be even."
|
|
32
|
+
|
|
33
|
+
outputs = model(
|
|
34
|
+
input_ids=batch["input_ids"],
|
|
35
|
+
attention_mask=batch["attention_mask"],
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
rewards = outputs[0]
|
|
39
|
+
chosen_reward = rewards[: batch_size // 2]
|
|
40
|
+
rejected_rewards = rewards[batch_size // 2 :]
|
|
41
|
+
|
|
42
|
+
loss = -torch.log(torch.sigmoid(chosen_reward - rejected_rewards)).mean()
|
|
43
|
+
correct = (chosen_reward > rejected_rewards).sum().item()
|
|
44
|
+
total = batch_size // 2
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
"loss": loss.item(),
|
|
48
|
+
"correct": correct,
|
|
49
|
+
"total": total,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def evaluate_dataloader(model: "LlamaForSequenceClassification", dataloader):
|
|
54
|
+
"""
|
|
55
|
+
Compute the accuracy of the reward model on the given dataloader.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
model: The reward model
|
|
59
|
+
dataloader: The dataloader for the dataset
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
float: The accuracy of the reward model on the dataset
|
|
63
|
+
"""
|
|
64
|
+
metrics = {
|
|
65
|
+
"loss": 0.0,
|
|
66
|
+
"correct": 0,
|
|
67
|
+
"total": 0,
|
|
68
|
+
}
|
|
69
|
+
with torch.no_grad():
|
|
70
|
+
for batch in (pbar := tqdm(dataloader)):
|
|
71
|
+
batch_result = evaluate_batch(model, batch)
|
|
72
|
+
new_total = metrics["total"] + batch_result["total"]
|
|
73
|
+
metrics["loss"] = (
|
|
74
|
+
metrics["loss"] * metrics["total"] / new_total
|
|
75
|
+
+ batch_result["loss"] * batch_result["total"] / new_total
|
|
76
|
+
)
|
|
77
|
+
metrics["correct"] += batch_result["correct"]
|
|
78
|
+
metrics["total"] += batch_result["total"]
|
|
79
|
+
pbar.set_postfix(metrics)
|
|
80
|
+
|
|
81
|
+
metrics["accuracy"] = metrics["correct"] / metrics["total"]
|
|
82
|
+
return metrics
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class RewardModelEvaluationTaskPool(
|
|
86
|
+
BaseTaskPool,
|
|
87
|
+
LightningFabricMixin,
|
|
88
|
+
):
|
|
89
|
+
def __init__(
|
|
90
|
+
self,
|
|
91
|
+
test_datasets: List[DictConfig],
|
|
92
|
+
dataloader_kwargs: DictConfig,
|
|
93
|
+
tokenizer: Optional[DictConfig],
|
|
94
|
+
max_num_samples: int = -1,
|
|
95
|
+
seed: int = 0,
|
|
96
|
+
**kwargs,
|
|
97
|
+
):
|
|
98
|
+
self.seed = seed
|
|
99
|
+
L.seed_everything(seed)
|
|
100
|
+
self._test_datasets = test_datasets
|
|
101
|
+
self.dataloader_kwargs = dataloader_kwargs
|
|
102
|
+
self._tokenizer = tokenizer
|
|
103
|
+
self.max_num_samples = max_num_samples
|
|
104
|
+
super().__init__(**kwargs)
|
|
105
|
+
|
|
106
|
+
def setup(self):
|
|
107
|
+
if self._tokenizer is None:
|
|
108
|
+
# try to load the tokenizer from the model pool
|
|
109
|
+
tokenizer = self._program.modelpool.load_tokenizer()
|
|
110
|
+
else:
|
|
111
|
+
tokenizer = instantiate(self._tokenizer)
|
|
112
|
+
self.tokenizer = tokenizer
|
|
113
|
+
|
|
114
|
+
test_datasets = {
|
|
115
|
+
dataset_name: instantiate(self._test_datasets[dataset_name])
|
|
116
|
+
for dataset_name in self._test_datasets
|
|
117
|
+
}
|
|
118
|
+
if self.max_num_samples > 0:
|
|
119
|
+
test_datasets = {
|
|
120
|
+
dataset_name: Subset(
|
|
121
|
+
test_dataset,
|
|
122
|
+
np.random.permutation(len(test_dataset))[: self.max_num_samples],
|
|
123
|
+
)
|
|
124
|
+
for dataset_name, test_dataset in test_datasets.items()
|
|
125
|
+
}
|
|
126
|
+
test_dataloaders = {
|
|
127
|
+
dataset_name: torch.utils.data.DataLoader(
|
|
128
|
+
test_dataset,
|
|
129
|
+
collate_fn=functools.partial(
|
|
130
|
+
bradley_terry_rm_collate,
|
|
131
|
+
pad_token_id=tokenizer.pad_token_id,
|
|
132
|
+
),
|
|
133
|
+
**self.dataloader_kwargs,
|
|
134
|
+
)
|
|
135
|
+
for dataset_name, test_dataset in test_datasets.items()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
self.test_dataloaders = {
|
|
139
|
+
dataset_name: self.fabric.setup_dataloaders(test_dataloader)
|
|
140
|
+
for dataset_name, test_dataloader in test_dataloaders.items()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@torch.no_grad()
|
|
144
|
+
def evaluate(self, model: "LlamaForSequenceClassification"):
|
|
145
|
+
self.setup()
|
|
146
|
+
|
|
147
|
+
model = self.fabric.setup_module(model)
|
|
148
|
+
if model.config.pad_token_id is None:
|
|
149
|
+
model.config.pad_token_id = self.tokenizer.pad_token_id
|
|
150
|
+
|
|
151
|
+
model.eval()
|
|
152
|
+
report = {}
|
|
153
|
+
for dataset_name, test_dataloader in self.test_dataloaders.items():
|
|
154
|
+
report[dataset_name] = evaluate_dataloader(model, test_dataloader)
|
|
155
|
+
|
|
156
|
+
print(report)
|
|
157
|
+
return report
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
import logging
|
|
3
|
+
import time
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
|
|
5
|
+
|
|
6
|
+
import torch
|
|
7
|
+
|
|
8
|
+
from fusion_bench import BaseTaskPool
|
|
9
|
+
from fusion_bench.taskpool.dummy import get_model_summary
|
|
10
|
+
from fusion_bench.utils.devices import get_device
|
|
11
|
+
from fusion_bench.utils.rich_utils import print_bordered
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from transformers import LlamaForCausalLM, PreTrainedTokenizer
|
|
15
|
+
|
|
16
|
+
from fusion_bench.modelpool import CausalLMPool
|
|
17
|
+
log = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def generate_text(
|
|
21
|
+
model: "LlamaForCausalLM",
|
|
22
|
+
tokenizer: "PreTrainedTokenizer",
|
|
23
|
+
prompt: str,
|
|
24
|
+
max_length: int = 1024,
|
|
25
|
+
temperature: float = 0.01,
|
|
26
|
+
top_p=0.9,
|
|
27
|
+
device: torch.device = None,
|
|
28
|
+
):
|
|
29
|
+
"""
|
|
30
|
+
Generate text using the loaded model.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
model: The loaded language model
|
|
34
|
+
tokenizer: The loaded tokenizer
|
|
35
|
+
prompt (str): Input prompt text
|
|
36
|
+
max_length (int): Maximum length of generated sequence
|
|
37
|
+
temperature (float): Controls randomness (higher = more random)
|
|
38
|
+
top_p (float): Nucleus sampling parameter
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
str: Generated text
|
|
42
|
+
"""
|
|
43
|
+
if device is None:
|
|
44
|
+
device = get_device(model)
|
|
45
|
+
|
|
46
|
+
# Encode the prompt
|
|
47
|
+
inputs = tokenizer(prompt, return_tensors="pt")
|
|
48
|
+
|
|
49
|
+
# Move to GPU if available
|
|
50
|
+
inputs = {k: v.to(device) for k, v in inputs.items()}
|
|
51
|
+
|
|
52
|
+
# Generate
|
|
53
|
+
with torch.no_grad():
|
|
54
|
+
outputs = model.generate(
|
|
55
|
+
**inputs,
|
|
56
|
+
max_length=max_length,
|
|
57
|
+
temperature=temperature,
|
|
58
|
+
top_p=top_p,
|
|
59
|
+
pad_token_id=tokenizer.pad_token_id,
|
|
60
|
+
eos_token_id=tokenizer.eos_token_id,
|
|
61
|
+
do_sample=True,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Decode and return the generated text
|
|
65
|
+
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=False)
|
|
66
|
+
response = generated_text[len(prompt) :]
|
|
67
|
+
return {
|
|
68
|
+
"generated_text": generated_text,
|
|
69
|
+
"response": response,
|
|
70
|
+
"num_tokens": len(outputs[0]) - len(inputs["input_ids"][0]),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class LlamaTestGenerationTaskPool(BaseTaskPool):
|
|
75
|
+
"""
|
|
76
|
+
This task pool is used to evaluate a language model on a set of prompts.
|
|
77
|
+
For the purpose of debugging, it can also be used in an interactive mode.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
def __init__(
|
|
81
|
+
self,
|
|
82
|
+
test_prompts: List[str],
|
|
83
|
+
max_length: int = 1024,
|
|
84
|
+
temperature: float = 0.01,
|
|
85
|
+
top_p: float = 0.9,
|
|
86
|
+
iterative_mode: bool = False,
|
|
87
|
+
**kwargs,
|
|
88
|
+
):
|
|
89
|
+
"""
|
|
90
|
+
Args:
|
|
91
|
+
test_prompts (List[str]): A list of prompts to be used for testing the model.
|
|
92
|
+
max_length (int, optional): The maximum length of the generated text. Defaults to 1024.
|
|
93
|
+
temperature (float, optional): The sampling temperature for text generation. Defaults to 0.01.
|
|
94
|
+
top_p (float, optional): The cumulative probability for nucleus sampling. Defaults to 0.9.
|
|
95
|
+
iterative_mode (bool, optional): If True, enables interactive mode for debugging. Defaults to False.
|
|
96
|
+
"""
|
|
97
|
+
self.test_prompts = test_prompts
|
|
98
|
+
self.max_length = max_length
|
|
99
|
+
self.temperature = temperature
|
|
100
|
+
self.top_p = top_p
|
|
101
|
+
self.iterative_mode = iterative_mode
|
|
102
|
+
super().__init__(**kwargs)
|
|
103
|
+
|
|
104
|
+
def evaluate(
|
|
105
|
+
self,
|
|
106
|
+
model: Union["LlamaForCausalLM", Any],
|
|
107
|
+
tokenizer: Optional["PreTrainedTokenizer"] = None,
|
|
108
|
+
):
|
|
109
|
+
if tokenizer is None:
|
|
110
|
+
if self._program is None:
|
|
111
|
+
log.error(
|
|
112
|
+
"`_program` is not set. This is probably happening when you are not runing the program via `fusion_bench` CLI."
|
|
113
|
+
"Please pass `tokenizer` to this function."
|
|
114
|
+
)
|
|
115
|
+
modelpool: "CausalLMPool" = self._program.modelpool
|
|
116
|
+
tokenizer = modelpool.load_tokenizer()
|
|
117
|
+
|
|
118
|
+
report = get_model_summary(model)
|
|
119
|
+
if self.test_prompts is not None:
|
|
120
|
+
for prompt_idx, prompt in enumerate(self.test_prompts):
|
|
121
|
+
print(f"=== Generating text {prompt_idx+1}/{len(self.test_prompts)}")
|
|
122
|
+
report[f"conversation_{prompt_idx+1}"] = self._generate_text(
|
|
123
|
+
model, tokenizer, prompt
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
if self.iterative_mode:
|
|
127
|
+
for prompt_idx in itertools.count():
|
|
128
|
+
# Prompt for input
|
|
129
|
+
# print usage instructions
|
|
130
|
+
print("Enter a prompt to generate text. Type 'exit' to exit the loop.")
|
|
131
|
+
prompt = input(
|
|
132
|
+
f"Enter a prompt, or type 'exit' to quit ({prompt_idx+1}): "
|
|
133
|
+
)
|
|
134
|
+
if prompt == "exit":
|
|
135
|
+
break
|
|
136
|
+
report[f"iterative_conversation_{prompt_idx+1}"] = self._generate_text(
|
|
137
|
+
model, tokenizer, prompt
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
return report
|
|
141
|
+
|
|
142
|
+
def _generate_text(
|
|
143
|
+
self, model: "LlamaForCausalLM", tokenizer: "PreTrainedTokenizer", prompt: str
|
|
144
|
+
) -> dict:
|
|
145
|
+
"""
|
|
146
|
+
Generate text using the provided model and tokenizer for a given prompt.
|
|
147
|
+
|
|
148
|
+
This method generates text based on the given prompt using the specified model and tokenizer.
|
|
149
|
+
It prints the prompt and the generated response, and returns a dictionary containing the prompt,
|
|
150
|
+
response, wall time, number of characters, and number of tokens.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
model: The language model to be used for text generation.
|
|
154
|
+
tokenizer: The tokenizer to be used for encoding and decoding text.
|
|
155
|
+
prompt (str): The input prompt for text generation.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
dict: A dictionary containing the following keys:
|
|
159
|
+
- "prompt" (str): The input prompt.
|
|
160
|
+
- "response" (str): The generated response.
|
|
161
|
+
- "wall_time" (float): The time taken to generate the response.
|
|
162
|
+
- "num_chars" (int): The number of characters in the generated response.
|
|
163
|
+
- "num_tokens" (int): The number of tokens in the generated response.
|
|
164
|
+
"""
|
|
165
|
+
print(prompt)
|
|
166
|
+
start_time = time.time()
|
|
167
|
+
outputs = generate_text(
|
|
168
|
+
model,
|
|
169
|
+
tokenizer=tokenizer,
|
|
170
|
+
prompt=prompt,
|
|
171
|
+
max_length=self.max_length,
|
|
172
|
+
temperature=self.temperature,
|
|
173
|
+
top_p=self.top_p,
|
|
174
|
+
)
|
|
175
|
+
print_bordered(
|
|
176
|
+
outputs["response"], title="Generated Text", code_style="markdown"
|
|
177
|
+
)
|
|
178
|
+
print("\n")
|
|
179
|
+
return {
|
|
180
|
+
"prompt": prompt,
|
|
181
|
+
"response": outputs["response"],
|
|
182
|
+
"wall_time": time.time() - start_time,
|
|
183
|
+
"num_chars": len(outputs["response"]),
|
|
184
|
+
"num_tokens": outputs["num_tokens"],
|
|
185
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import lightning as L
|
|
5
|
+
from omegaconf import DictConfig
|
|
6
|
+
from torch import nn
|
|
7
|
+
from torch.utils.data import DataLoader
|
|
8
|
+
|
|
9
|
+
from fusion_bench.compat.taskpool.base_pool import TaskPool
|
|
10
|
+
from fusion_bench.dataset.nyuv2 import NYUv2
|
|
11
|
+
from fusion_bench.models.nyuv2.lightning_module import NYUv2MTLModule
|
|
12
|
+
from fusion_bench.models.nyuv2.resnet_dilated import ResnetDilated
|
|
13
|
+
|
|
14
|
+
log = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NYUv2TaskPool(TaskPool):
|
|
18
|
+
_trainer: L.Trainer = None
|
|
19
|
+
|
|
20
|
+
def __init__(self, taskpool_config: DictConfig):
|
|
21
|
+
self.config = taskpool_config
|
|
22
|
+
|
|
23
|
+
def load_datasets(self):
|
|
24
|
+
log.info("Loading NYUv2 dataset")
|
|
25
|
+
data_path = str(Path(self.config.data_dir) / "nyuv2")
|
|
26
|
+
|
|
27
|
+
train_dataset = NYUv2(root=data_path, train=True)
|
|
28
|
+
val_dataset = NYUv2(root=data_path, train=False)
|
|
29
|
+
return train_dataset, val_dataset
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def trainer(self):
|
|
33
|
+
if self._trainer is None:
|
|
34
|
+
self._trainer = L.Trainer(devices=1)
|
|
35
|
+
return self._trainer
|
|
36
|
+
|
|
37
|
+
def get_decoders(self):
|
|
38
|
+
from fusion_bench.modelpool.nyuv2_modelpool import NYUv2ModelPool
|
|
39
|
+
|
|
40
|
+
modelpool: NYUv2ModelPool = self._program.modelpool
|
|
41
|
+
decoders = nn.ModuleDict()
|
|
42
|
+
for task in self.config.tasks:
|
|
43
|
+
decoders[task] = modelpool.load_model(task, encoder_only=False).decoders[
|
|
44
|
+
task
|
|
45
|
+
]
|
|
46
|
+
return decoders
|
|
47
|
+
|
|
48
|
+
def evaluate(self, encoder: ResnetDilated):
|
|
49
|
+
model = NYUv2MTLModule(
|
|
50
|
+
encoder,
|
|
51
|
+
self.get_decoders(),
|
|
52
|
+
tasks=self.config.tasks,
|
|
53
|
+
task_weights=[1] * len(self.config.tasks),
|
|
54
|
+
)
|
|
55
|
+
_, val_dataset = self.load_datasets()
|
|
56
|
+
val_loader = DataLoader(
|
|
57
|
+
val_dataset,
|
|
58
|
+
batch_size=self.config.batch_size,
|
|
59
|
+
shuffle=False,
|
|
60
|
+
num_workers=self.config.num_workers,
|
|
61
|
+
)
|
|
62
|
+
report = self.trainer.validate(model, val_loader)
|
|
63
|
+
if isinstance(report, list) and len(report) == 1:
|
|
64
|
+
report = report[0]
|
|
65
|
+
return report
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
from omegaconf import DictConfig
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BaseTask(ABC):
|
|
7
|
+
_taskpool = None
|
|
8
|
+
|
|
9
|
+
def __init__(self, task_config: DictConfig):
|
|
10
|
+
self.config = task_config
|
|
11
|
+
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def evaluate(self, model):
|
|
14
|
+
"""
|
|
15
|
+
Evaluate the model on the task.
|
|
16
|
+
Returns a dictionary containing the evaluation metrics.
|
|
17
|
+
"""
|
|
18
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import itertools
|
|
3
|
+
import logging
|
|
4
|
+
from abc import abstractmethod
|
|
5
|
+
|
|
6
|
+
import torch
|
|
7
|
+
from torch import Tensor, nn
|
|
8
|
+
from torch.nn import functional as F
|
|
9
|
+
from torchmetrics import Accuracy, MeanMetric
|
|
10
|
+
from torchmetrics.classification.accuracy import MulticlassAccuracy
|
|
11
|
+
from tqdm.autonotebook import tqdm
|
|
12
|
+
|
|
13
|
+
from .base_task import BaseTask
|
|
14
|
+
|
|
15
|
+
log = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ClassificationTask(BaseTask):
|
|
19
|
+
def __init__(self, task_config):
|
|
20
|
+
super().__init__(task_config)
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def num_classes(self):
|
|
25
|
+
"""
|
|
26
|
+
Returns the number of classes in the dataset.
|
|
27
|
+
"""
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
@abstractmethod
|
|
32
|
+
def test_loader(self):
|
|
33
|
+
"""
|
|
34
|
+
Returns a test data loader.
|
|
35
|
+
"""
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
@torch.no_grad()
|
|
39
|
+
def evaluate(self, classifier: nn.Module, device=None):
|
|
40
|
+
accuracy: MulticlassAccuracy = Accuracy(
|
|
41
|
+
task="multiclass", num_classes=self.num_classes
|
|
42
|
+
)
|
|
43
|
+
classifier.eval()
|
|
44
|
+
loss_metric = MeanMetric()
|
|
45
|
+
# if fast_dev_run is set, we only evaluate on a batch of the data
|
|
46
|
+
if self.config.get("fast_dev_run", False):
|
|
47
|
+
log.info("Running under fast_dev_run mode, evaluating on a single batch.")
|
|
48
|
+
test_loader = itertools.islice(self.test_loader, 1)
|
|
49
|
+
else:
|
|
50
|
+
test_loader = self.test_loader
|
|
51
|
+
|
|
52
|
+
for batch in (
|
|
53
|
+
pbar := tqdm(
|
|
54
|
+
test_loader, desc="Evaluating", leave=False, dynamic_ncols=True
|
|
55
|
+
)
|
|
56
|
+
):
|
|
57
|
+
inputs, targets = batch
|
|
58
|
+
if device is not None:
|
|
59
|
+
inputs, targets = inputs.to(device), targets.to(device)
|
|
60
|
+
logits: Tensor = classifier(inputs)
|
|
61
|
+
|
|
62
|
+
loss = F.cross_entropy(logits, targets)
|
|
63
|
+
loss_metric.update(loss.detach().cpu())
|
|
64
|
+
acc = accuracy(logits.detach().cpu(), targets.detach().cpu())
|
|
65
|
+
pbar.set_postfix(
|
|
66
|
+
{
|
|
67
|
+
"accuracy": accuracy.compute().item(),
|
|
68
|
+
"loss": loss_metric.compute().item(),
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
acc = accuracy.compute().item()
|
|
73
|
+
loss = loss_metric.compute().item()
|
|
74
|
+
results = {"accuracy": acc, "loss": loss}
|
|
75
|
+
return results
|