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,141 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Dict, List, Optional, Union
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from datasets import Dataset
|
|
6
|
+
from transformers import PreTrainedTokenizer
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def tokenize_sharegpt_dataset(
|
|
12
|
+
dataset: Dataset,
|
|
13
|
+
tokenizer: PreTrainedTokenizer,
|
|
14
|
+
max_length: int = 2048,
|
|
15
|
+
padding: bool = True,
|
|
16
|
+
system_template: str = "### System: {system}\n\n",
|
|
17
|
+
tools_template: str = "### Tools: {tools}\n\n",
|
|
18
|
+
human_template: str = "### Human: {message}\n",
|
|
19
|
+
assistant_template: str = "### Assistant: {message}\n",
|
|
20
|
+
function_template: str = "### Function Call: {message}\n",
|
|
21
|
+
observation_template: str = "### Observation: {message}\n",
|
|
22
|
+
) -> Dataset:
|
|
23
|
+
"""
|
|
24
|
+
Tokenize ShareGPT format dataset with support for system prompts, tools, and tool calls.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
dataset: Input dataset in ShareGPT format.
|
|
28
|
+
tokenizer: The tokenizer to use.
|
|
29
|
+
max_length: Maximum sequence length.
|
|
30
|
+
padding: Whether to pad the tokenized inputs to `max_length`.
|
|
31
|
+
system_template: Template for system messages.
|
|
32
|
+
tools_template: Template for tool descriptions.
|
|
33
|
+
human_template: Template for human messages.
|
|
34
|
+
assistant_template: Template for assistant responses.
|
|
35
|
+
function_template: Template for function calls.
|
|
36
|
+
observation_template: Template for function observations.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Tokenized dataset
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def build_conversation(
|
|
43
|
+
conversations: List[Dict[str, str]],
|
|
44
|
+
system: Optional[str] = None,
|
|
45
|
+
tools: Optional[str] = None,
|
|
46
|
+
) -> tuple[List[int], List[int]]:
|
|
47
|
+
"""
|
|
48
|
+
Build prompt and response token ids from conversations.
|
|
49
|
+
Returns (prompt_tokens, response_tokens) for the last assistant message.
|
|
50
|
+
"""
|
|
51
|
+
# Initialize conversation history
|
|
52
|
+
history = ""
|
|
53
|
+
|
|
54
|
+
# Add system prompt if provided
|
|
55
|
+
if system:
|
|
56
|
+
history += system_template.format(system=system.strip())
|
|
57
|
+
|
|
58
|
+
# Add tools description if provided
|
|
59
|
+
if tools:
|
|
60
|
+
history += tools_template.format(tools=tools.strip())
|
|
61
|
+
|
|
62
|
+
prompt_tokens = []
|
|
63
|
+
response_tokens = []
|
|
64
|
+
|
|
65
|
+
for i, message in enumerate(conversations):
|
|
66
|
+
msg_from = message["from"]
|
|
67
|
+
msg_value = message["value"].strip()
|
|
68
|
+
|
|
69
|
+
# If this is the last assistant message
|
|
70
|
+
if msg_from == "gpt" and i == len(conversations) - 1:
|
|
71
|
+
# Tokenize the current history as prompt
|
|
72
|
+
prompt_tokens = tokenizer.encode(history, add_special_tokens=False)
|
|
73
|
+
# Tokenize the assistant's message as response
|
|
74
|
+
response_tokens = tokenizer.encode(
|
|
75
|
+
assistant_template.format(message=msg_value),
|
|
76
|
+
add_special_tokens=False,
|
|
77
|
+
)
|
|
78
|
+
break
|
|
79
|
+
|
|
80
|
+
# Build conversation history
|
|
81
|
+
if msg_from == "human":
|
|
82
|
+
history += human_template.format(message=msg_value)
|
|
83
|
+
elif msg_from == "gpt":
|
|
84
|
+
history += assistant_template.format(message=msg_value)
|
|
85
|
+
elif msg_from == "function_call":
|
|
86
|
+
history += function_template.format(message=msg_value)
|
|
87
|
+
elif msg_from == "observation":
|
|
88
|
+
history += observation_template.format(message=msg_value)
|
|
89
|
+
else:
|
|
90
|
+
log.warning(f"Unkonwn role: {msg_from}")
|
|
91
|
+
|
|
92
|
+
return prompt_tokens, response_tokens
|
|
93
|
+
|
|
94
|
+
def prepare_sample(sample: dict) -> dict:
|
|
95
|
+
# Get prompt and response tokens
|
|
96
|
+
prompt_tokens, response_tokens = build_conversation(
|
|
97
|
+
conversations=sample["conversations"],
|
|
98
|
+
system=sample.get("system"), # system prompt is optional
|
|
99
|
+
tools=sample.get("tools"), # tools description is optional
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Create input_ids with EOS token
|
|
103
|
+
input_ids = prompt_tokens + response_tokens + [tokenizer.eos_token_id]
|
|
104
|
+
|
|
105
|
+
# Create attention mask (1 for tokens, 0 for padding)
|
|
106
|
+
attention_mask = [1] * len(input_ids)
|
|
107
|
+
|
|
108
|
+
# Create labels (-100 for prompt, actual tokens for response)
|
|
109
|
+
labels = (
|
|
110
|
+
[-100] * len(prompt_tokens) + response_tokens + [tokenizer.eos_token_id]
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Truncate if exceeds max length
|
|
114
|
+
if len(input_ids) > max_length:
|
|
115
|
+
input_ids = input_ids[:max_length]
|
|
116
|
+
attention_mask = attention_mask[:max_length]
|
|
117
|
+
labels = labels[:max_length]
|
|
118
|
+
|
|
119
|
+
# Pad if necessary
|
|
120
|
+
if padding:
|
|
121
|
+
padding_length = max_length - len(input_ids)
|
|
122
|
+
if padding_length > 0:
|
|
123
|
+
input_ids.extend([tokenizer.pad_token_id] * padding_length)
|
|
124
|
+
attention_mask.extend([0] * padding_length)
|
|
125
|
+
labels.extend([-100] * padding_length)
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
"input_ids": input_ids,
|
|
129
|
+
"attention_mask": attention_mask,
|
|
130
|
+
"labels": labels,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if tokenizer.pad_token is None:
|
|
134
|
+
log.warning("Tokenizer does not have a `pad_token`. Set it the `eos_token`.")
|
|
135
|
+
tokenizer.pad_token = tokenizer.eos_token
|
|
136
|
+
# Process the dataset
|
|
137
|
+
tokenized_dataset = dataset.map(
|
|
138
|
+
prepare_sample, remove_columns=dataset.column_names, desc="Tokenizing dataset"
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return tokenized_dataset
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
from typing import Any, Dict, List, Literal, Optional
|
|
4
|
+
|
|
5
|
+
from datasets import load_dataset, load_from_disk
|
|
6
|
+
from transformers import PreTrainedTokenizer
|
|
7
|
+
|
|
8
|
+
import fusion_bench
|
|
9
|
+
|
|
10
|
+
log = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def load_tokenized_squad_dataset(
|
|
14
|
+
tokenizer: Optional[PreTrainedTokenizer],
|
|
15
|
+
path: Literal["squard_v2", "squad"] = "squard_v2",
|
|
16
|
+
split: Optional[str] = None,
|
|
17
|
+
max_length: int = 384, # The maximum length of a feature (question and context)
|
|
18
|
+
doc_stride: int = 128, # The authorized overlap between two part of the context when splitting it is needed.
|
|
19
|
+
datasets: Optional[Any] = None,
|
|
20
|
+
cache_path: Optional[str] = None,
|
|
21
|
+
):
|
|
22
|
+
if cache_path is not None and fusion_bench.utils.path.path_is_dir_and_not_empty(
|
|
23
|
+
cache_path
|
|
24
|
+
):
|
|
25
|
+
datasets = load_from_disk(cache_path)
|
|
26
|
+
if split is None:
|
|
27
|
+
return datasets
|
|
28
|
+
else:
|
|
29
|
+
return datasets[split]
|
|
30
|
+
else:
|
|
31
|
+
assert (
|
|
32
|
+
tokenizer is not None
|
|
33
|
+
), "Cached dataset not found. Need tokenizer to process the raw data."
|
|
34
|
+
|
|
35
|
+
# 1. load raw dataset
|
|
36
|
+
if datasets is not None:
|
|
37
|
+
log.info("Use `datasets`, `path` is ignored.")
|
|
38
|
+
else:
|
|
39
|
+
datasets = load_dataset(path)
|
|
40
|
+
|
|
41
|
+
# 2. tokenize the dataset
|
|
42
|
+
pad_on_right = tokenizer.padding_side == "right"
|
|
43
|
+
if tokenizer.pad_token is None:
|
|
44
|
+
tokenizer.pad_token = tokenizer.eos_token
|
|
45
|
+
|
|
46
|
+
def prepare_train_features(examples):
|
|
47
|
+
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
|
|
48
|
+
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
|
|
49
|
+
# left whitespace
|
|
50
|
+
examples["question"] = [q.lstrip() for q in examples["question"]]
|
|
51
|
+
|
|
52
|
+
# Tokenize our examples with truncation and padding, but keep the overflows using a stride. This results
|
|
53
|
+
# in one example possible giving several features when a context is long, each of those features having a
|
|
54
|
+
# context that overlaps a bit the context of the previous feature.
|
|
55
|
+
tokenized_examples = tokenizer(
|
|
56
|
+
examples["question" if pad_on_right else "context"],
|
|
57
|
+
examples["context" if pad_on_right else "question"],
|
|
58
|
+
truncation="only_second" if pad_on_right else "only_first",
|
|
59
|
+
max_length=max_length,
|
|
60
|
+
stride=doc_stride,
|
|
61
|
+
return_overflowing_tokens=True,
|
|
62
|
+
return_offsets_mapping=True,
|
|
63
|
+
padding="max_length",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# Since one example might give us several features if it has a long context, we need a map from a feature to
|
|
67
|
+
# its corresponding example. This key gives us just that.
|
|
68
|
+
sample_mapping = tokenized_examples.pop("overflow_to_sample_mapping")
|
|
69
|
+
# The offset mappings will give us a map from token to character position in the original context. This will
|
|
70
|
+
# help us compute the start_positions and end_positions.
|
|
71
|
+
offset_mapping = tokenized_examples.pop("offset_mapping")
|
|
72
|
+
|
|
73
|
+
# Initialize arrays for start and end positions
|
|
74
|
+
start_positions = []
|
|
75
|
+
end_positions = []
|
|
76
|
+
|
|
77
|
+
for i, offset in enumerate(offset_mapping):
|
|
78
|
+
# Get corresponding example from the original dataset
|
|
79
|
+
sample_idx = sample_mapping[i]
|
|
80
|
+
answer = examples["answers"][sample_idx]
|
|
81
|
+
|
|
82
|
+
# Character start/end positions of the answer
|
|
83
|
+
start_char = answer["answer_start"][0]
|
|
84
|
+
end_char = start_char + len(answer["text"][0])
|
|
85
|
+
|
|
86
|
+
# Convert character positions to token positions
|
|
87
|
+
# Find start token position
|
|
88
|
+
token_start_index = 0
|
|
89
|
+
while (
|
|
90
|
+
token_start_index < len(offset)
|
|
91
|
+
and offset[token_start_index][0] <= start_char
|
|
92
|
+
):
|
|
93
|
+
token_start_index += 1
|
|
94
|
+
token_start_index -= 1
|
|
95
|
+
|
|
96
|
+
# Find end token position
|
|
97
|
+
token_end_index = token_start_index
|
|
98
|
+
while (
|
|
99
|
+
token_end_index < len(offset) and offset[token_end_index][1] <= end_char
|
|
100
|
+
):
|
|
101
|
+
token_end_index += 1
|
|
102
|
+
token_end_index -= 1
|
|
103
|
+
|
|
104
|
+
start_positions.append(token_start_index)
|
|
105
|
+
end_positions.append(token_end_index)
|
|
106
|
+
|
|
107
|
+
tokenized_examples["start_positions"] = start_positions
|
|
108
|
+
tokenized_examples["end_positions"] = end_positions
|
|
109
|
+
|
|
110
|
+
return tokenized_examples
|
|
111
|
+
|
|
112
|
+
tokenized_datasets = datasets.map(
|
|
113
|
+
prepare_train_features,
|
|
114
|
+
batched=True,
|
|
115
|
+
remove_columns=datasets["train"].column_names,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
if cache_path is not None:
|
|
119
|
+
os.makedirs(cache_path, exist_ok=True)
|
|
120
|
+
tokenized_datasets.save_to_disk(cache_path)
|
|
121
|
+
|
|
122
|
+
if split is None:
|
|
123
|
+
return tokenized_datasets
|
|
124
|
+
else:
|
|
125
|
+
return tokenized_datasets[split]
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from copy import deepcopy
|
|
3
|
+
from typing import TYPE_CHECKING, Optional
|
|
4
|
+
|
|
5
|
+
from datasets import Dataset, load_dataset, load_from_disk
|
|
6
|
+
from lightning.fabric.utilities import rank_zero_only
|
|
7
|
+
from tqdm.auto import tqdm
|
|
8
|
+
|
|
9
|
+
from fusion_bench.utils import timeit_context
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from transformers import PreTrainedTokenizer
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def load_tokenized_stanford_shp_for_rlhf(
|
|
16
|
+
tokenizer: "PreTrainedTokenizer",
|
|
17
|
+
path: str = "stanfordnlp/SHP",
|
|
18
|
+
split: str = "train",
|
|
19
|
+
num_proc: int = 8,
|
|
20
|
+
cache_path: Optional[str] = None,
|
|
21
|
+
):
|
|
22
|
+
if cache_path is not None and os.path.isdir(cache_path):
|
|
23
|
+
dataset = load_from_disk(cache_path)
|
|
24
|
+
return dataset
|
|
25
|
+
|
|
26
|
+
dataset = load_dataset(path, split=split)
|
|
27
|
+
|
|
28
|
+
def tokenize(sample):
|
|
29
|
+
"""
|
|
30
|
+
- history: the post title concatented to the post body (string)
|
|
31
|
+
- human_ref_A: text of comment A (string)
|
|
32
|
+
- human_ref_B: text of comment B (string)
|
|
33
|
+
- labels: the preference label -- it is 1 if A is preferred to B; 0 if B is preferred to A. This was randomized such that the label distribution is roughly 50/50. (integer)
|
|
34
|
+
"""
|
|
35
|
+
# Create a conversation with the post title and body, followed by comments
|
|
36
|
+
conversation = [{"role": "user", "content": sample["history"]}]
|
|
37
|
+
if sample["labels"] == 0:
|
|
38
|
+
sample["chosen"] = deepcopy(conversation).append(
|
|
39
|
+
{"role": "assistant", "content": sample["human_ref_B"]}
|
|
40
|
+
)
|
|
41
|
+
sample["rejected"] = deepcopy(conversation).append(
|
|
42
|
+
{"role": "assistant", "content": sample["human_ref_A"]}
|
|
43
|
+
)
|
|
44
|
+
else:
|
|
45
|
+
sample["chosen"] = deepcopy(conversation).append(
|
|
46
|
+
{"role": "assistant", "content": sample["human_ref_A"]}
|
|
47
|
+
)
|
|
48
|
+
sample["rejected"] = deepcopy(conversation).append(
|
|
49
|
+
{"role": "assistant", "content": sample["human_ref_B"]}
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# apply chat template
|
|
53
|
+
sample["chosen_chat"] = tokenizer.apply_chat_template(
|
|
54
|
+
sample["chosen"], tokenize=False, add_generation_prompt=False
|
|
55
|
+
)
|
|
56
|
+
sample["rejected_chat"] = tokenizer.apply_chat_template(
|
|
57
|
+
sample["rejected"], tokenize=False, add_generation_prompt=False
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# tokenize the conversation
|
|
61
|
+
tokenized_pos = tokenizer(sample["chosen_chat"], truncation=True)
|
|
62
|
+
tokenized_neg = tokenizer(sample["rejected_chat"], truncation=True)
|
|
63
|
+
|
|
64
|
+
# Ensure that the chosen response does not contain an EOS token
|
|
65
|
+
sample["chosen_input_ids"] = tokenized_pos["input_ids"]
|
|
66
|
+
sample["chosen_attention_mask"] = tokenized_pos["attention_mask"]
|
|
67
|
+
assert (
|
|
68
|
+
tokenizer.eos_token_id not in tokenized_pos["input_ids"][:-1]
|
|
69
|
+
), f"Prompt contains EOS token: {sample['positive']}"
|
|
70
|
+
if sample["chosen_input_ids"][-1] != tokenizer.eos_token_id:
|
|
71
|
+
sample["chosen_input_ids"].append(tokenizer.eos_token_id)
|
|
72
|
+
sample["chosen_attention_mask"].append(1)
|
|
73
|
+
|
|
74
|
+
sample["rejected_input_ids"] = tokenized_neg["input_ids"]
|
|
75
|
+
sample["rejected_attention_mask"] = tokenized_neg["attention_mask"]
|
|
76
|
+
# Ensure that the rejected response does not contain an EOS token
|
|
77
|
+
assert (
|
|
78
|
+
tokenizer.eos_token_id not in tokenized_neg["input_ids"][:-1]
|
|
79
|
+
), f"Prompt contains EOS token: {sample['rejected']}"
|
|
80
|
+
if sample["rejected_input_ids"][-1] != tokenizer.eos_token_id:
|
|
81
|
+
sample["rejected_input_ids"].append(tokenizer.eos_token_id)
|
|
82
|
+
sample["rejected_attention_mask"].append(1)
|
|
83
|
+
|
|
84
|
+
return sample
|
|
85
|
+
|
|
86
|
+
dataset = dataset.map(tokenize, num_proc=num_proc)
|
|
87
|
+
|
|
88
|
+
if cache_path is not None and rank_zero_only.rank == 0:
|
|
89
|
+
dataset.save_to_disk(cache_path)
|
|
90
|
+
return dataset
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import TYPE_CHECKING, Optional
|
|
3
|
+
|
|
4
|
+
from datasets import Dataset, load_dataset, load_from_disk
|
|
5
|
+
from lightning.fabric.utilities import rank_zero_only
|
|
6
|
+
from tqdm.auto import tqdm
|
|
7
|
+
|
|
8
|
+
from fusion_bench.utils import timeit_context
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from transformers import PreTrainedTokenizer
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load_tokenized_ultrachat_200k(
|
|
15
|
+
tokenizer: "PreTrainedTokenizer",
|
|
16
|
+
path: str = "HuggingFaceH4/ultrachat_200k",
|
|
17
|
+
split: str = "train_sft",
|
|
18
|
+
num_proc: int = 8,
|
|
19
|
+
cache_path: Optional[str] = None,
|
|
20
|
+
):
|
|
21
|
+
R"""
|
|
22
|
+
Load and tokenized Ultrachat 200k dataset for Bradley-Terry ranking model.
|
|
23
|
+
|
|
24
|
+
The returned dataset contains the following fields:
|
|
25
|
+
|
|
26
|
+
- input_ids: The input token ids for the winner.
|
|
27
|
+
- attention_mask: The attention mask for the winner.
|
|
28
|
+
"""
|
|
29
|
+
if cache_path is not None and os.path.exists(cache_path):
|
|
30
|
+
dataset = load_from_disk(cache_path)
|
|
31
|
+
return dataset
|
|
32
|
+
|
|
33
|
+
dataset = load_dataset(path, split=split)
|
|
34
|
+
|
|
35
|
+
def tokenize(sample):
|
|
36
|
+
|
|
37
|
+
# ? is it necessary to `.replace(tokenizer.bos_token, "")`?
|
|
38
|
+
sample["input_ids"] = tokenizer.apply_chat_template(
|
|
39
|
+
sample["messages"], tokenize=True, add_generation_prompt=False
|
|
40
|
+
)
|
|
41
|
+
sample["attention_mask"] = [1] * len(sample["input_ids"])
|
|
42
|
+
|
|
43
|
+
return sample
|
|
44
|
+
|
|
45
|
+
dataset = dataset.map(tokenize, num_proc=num_proc)
|
|
46
|
+
|
|
47
|
+
if cache_path is not None and rank_zero_only.rank == 0:
|
|
48
|
+
dataset.save_to_disk(cache_path)
|
|
49
|
+
return dataset
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
# Example usage and testing
|
|
54
|
+
from transformers import AutoTokenizer
|
|
55
|
+
|
|
56
|
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B-Instruct")
|
|
57
|
+
dataset = load_tokenized_ultrachat_200k(tokenizer)
|
|
58
|
+
print(dataset)
|
|
File without changes
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from datasets import load_dataset, load_from_disk
|
|
6
|
+
from transformers import PreTrainedTokenizer
|
|
7
|
+
|
|
8
|
+
import fusion_bench
|
|
9
|
+
|
|
10
|
+
log = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def load_tokenized_wiki_dataset(
|
|
14
|
+
tokenizer: Optional[PreTrainedTokenizer],
|
|
15
|
+
path: str = "wikitext",
|
|
16
|
+
name: str = "wikitext-2-raw-v1",
|
|
17
|
+
split: Optional[str] = None,
|
|
18
|
+
datasets: Optional[Any] = None,
|
|
19
|
+
block_size: int = 128,
|
|
20
|
+
cache_path: Optional[str] = None,
|
|
21
|
+
):
|
|
22
|
+
"""
|
|
23
|
+
Reference: https://github.com/huggingface/notebooks/blob/main/examples/language_modeling.ipynb
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
block_size (int):
|
|
27
|
+
dataset: If dataset is provided, `path` and `name` will be ignored.
|
|
28
|
+
"""
|
|
29
|
+
if cache_path is not None and fusion_bench.utils.path.path_is_dir_and_not_empty(
|
|
30
|
+
cache_path
|
|
31
|
+
):
|
|
32
|
+
datasets = load_from_disk(cache_path)
|
|
33
|
+
if split is None:
|
|
34
|
+
return datasets
|
|
35
|
+
else:
|
|
36
|
+
return datasets[split]
|
|
37
|
+
else:
|
|
38
|
+
assert (
|
|
39
|
+
tokenizer is not None
|
|
40
|
+
), "Cached dataset not found. Need tokenizer to process the raw data."
|
|
41
|
+
|
|
42
|
+
# 1. load raw dataset
|
|
43
|
+
if datasets is not None:
|
|
44
|
+
log.info("Use `datasets`, `path` and `name` are ignored.")
|
|
45
|
+
else:
|
|
46
|
+
datasets = load_dataset(path, name)
|
|
47
|
+
|
|
48
|
+
# 2. tokenize the dataset
|
|
49
|
+
def tokenize_function(examples):
|
|
50
|
+
return tokenizer(examples["text"])
|
|
51
|
+
|
|
52
|
+
tokenized_datasets = datasets.map(
|
|
53
|
+
tokenize_function, batched=True, num_proc=4, remove_columns=["text"]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# If we now look at an element of our datasets, we will see the text have been replaced by the input_ids the model will need:
|
|
57
|
+
# { 'attention_mask': <list of int>, 'input_ids': <list of int> }
|
|
58
|
+
|
|
59
|
+
# 3. concat and truncate tokens
|
|
60
|
+
def group_texts(examples: Dict[str, List]):
|
|
61
|
+
# Concatenate all texts.
|
|
62
|
+
concatenated_examples = {k: sum(examples[k], []) for k in examples.keys()}
|
|
63
|
+
total_length = len(concatenated_examples[list(examples.keys())[0]])
|
|
64
|
+
# We drop the small remainder, we could add padding if the model supported it instead of this drop, you can
|
|
65
|
+
# customize this part to your needs.
|
|
66
|
+
total_length = (total_length // block_size) * block_size
|
|
67
|
+
# Split by chunks of max_len.
|
|
68
|
+
result = {
|
|
69
|
+
k: [t[i : i + block_size] for i in range(0, total_length, block_size)]
|
|
70
|
+
for k, t in concatenated_examples.items()
|
|
71
|
+
}
|
|
72
|
+
result["labels"] = result["input_ids"].copy()
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
lm_datasets = tokenized_datasets.map(
|
|
76
|
+
group_texts,
|
|
77
|
+
batched=True,
|
|
78
|
+
batch_size=1000,
|
|
79
|
+
num_proc=4,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if cache_path is not None:
|
|
83
|
+
os.makedirs(cache_path, exist_ok=True)
|
|
84
|
+
lm_datasets.save_to_disk(cache_path)
|
|
85
|
+
|
|
86
|
+
if split is None:
|
|
87
|
+
return lm_datasets
|
|
88
|
+
else:
|
|
89
|
+
return lm_datasets[split]
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import fnmatch
|
|
2
|
+
import os
|
|
3
|
+
from typing import Callable, Optional
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import torch
|
|
7
|
+
from torch.utils.data import Dataset
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class NYUv2(Dataset):
|
|
11
|
+
R"""
|
|
12
|
+
NYUv2 dataset, 3 tasks + 1 generated useless task
|
|
13
|
+
Included tasks:
|
|
14
|
+
|
|
15
|
+
1. Semantic Segmentation,
|
|
16
|
+
2. Depth prediction,
|
|
17
|
+
3. Surface Normal prediction,
|
|
18
|
+
4. Noise prediction [to test auxiliary learning, purely conflict gradients]
|
|
19
|
+
|
|
20
|
+
Modified from https://github.com/lorenmt/auto-lambda/blob/main/create_dataset.py
|
|
21
|
+
|
|
22
|
+
removed the `augmentation` arg and add `transform` args
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
num_out_channels = {
|
|
26
|
+
"segmentation": 13,
|
|
27
|
+
"depth": 1,
|
|
28
|
+
"normal": 3,
|
|
29
|
+
"noise": 1,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
root: str,
|
|
35
|
+
train: bool = True,
|
|
36
|
+
transform: Optional[Callable] = None,
|
|
37
|
+
seg_transform: Optional[Callable] = None,
|
|
38
|
+
sn_transform: Optional[Callable] = None,
|
|
39
|
+
depth_transform: Optional[Callable] = None,
|
|
40
|
+
):
|
|
41
|
+
"""
|
|
42
|
+
Initialize the NYUv2 dataset.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
root (str): The root directory of the dataset.
|
|
46
|
+
train (bool, optional): If True, use training set. If False, use validation set. Defaults to True.
|
|
47
|
+
transform (Callable, optional): image transform. Defaults to None.
|
|
48
|
+
seg_transform (Callable, optional): segmentation transform. Defaults to None.
|
|
49
|
+
sn_transform (Callable, optional): surface normal transform. Defaults to None.
|
|
50
|
+
depth_transform (Callable, optional): depth transform. Defaults to None.
|
|
51
|
+
"""
|
|
52
|
+
self.root = os.path.expanduser(root)
|
|
53
|
+
self.train = train
|
|
54
|
+
|
|
55
|
+
self.transform = transform
|
|
56
|
+
self.seg_transform = seg_transform
|
|
57
|
+
self.sn_transform = sn_transform
|
|
58
|
+
self.depth_transform = depth_transform
|
|
59
|
+
|
|
60
|
+
if train:
|
|
61
|
+
self.data_path = self.root + "/train"
|
|
62
|
+
else:
|
|
63
|
+
self.data_path = self.root + "/val"
|
|
64
|
+
|
|
65
|
+
# calculate data length
|
|
66
|
+
self.data_len = len(
|
|
67
|
+
fnmatch.filter(os.listdir(self.data_path + "/image"), "*.npy")
|
|
68
|
+
)
|
|
69
|
+
self.noise = torch.rand(self.data_len, 1, 288, 384)
|
|
70
|
+
|
|
71
|
+
def __getitem__(self, index):
|
|
72
|
+
"""
|
|
73
|
+
Retrieve an item from the dataset.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
index (int): The index of the item to retrieve.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
tuple: A tuple containing the image and a dictionary of task-specific outputs.
|
|
80
|
+
"""
|
|
81
|
+
# load data from the pre-processed npy files
|
|
82
|
+
image = torch.from_numpy(
|
|
83
|
+
np.moveaxis(
|
|
84
|
+
np.load(self.data_path + "/image/{:d}.npy".format(index)), -1, 0
|
|
85
|
+
)
|
|
86
|
+
).float()
|
|
87
|
+
semantic = torch.from_numpy(
|
|
88
|
+
np.load(self.data_path + "/label/{:d}.npy".format(index))
|
|
89
|
+
).float()
|
|
90
|
+
depth = torch.from_numpy(
|
|
91
|
+
np.moveaxis(
|
|
92
|
+
np.load(self.data_path + "/depth/{:d}.npy".format(index)), -1, 0
|
|
93
|
+
)
|
|
94
|
+
).float()
|
|
95
|
+
normal = torch.from_numpy(
|
|
96
|
+
np.moveaxis(
|
|
97
|
+
np.load(self.data_path + "/normal/{:d}.npy".format(index)), -1, 0
|
|
98
|
+
)
|
|
99
|
+
).float()
|
|
100
|
+
noise = self.noise[index].float()
|
|
101
|
+
|
|
102
|
+
if self.transform is not None:
|
|
103
|
+
image = self.transform(image)
|
|
104
|
+
if self.seg_transform is not None:
|
|
105
|
+
semantic = self.seg_transform(semantic)
|
|
106
|
+
if self.sn_transform is not None:
|
|
107
|
+
normal = self.sn_transform(normal)
|
|
108
|
+
if self.depth_transform is not None:
|
|
109
|
+
depth = self.depth_transform(depth)
|
|
110
|
+
|
|
111
|
+
return image, {
|
|
112
|
+
"segmentation": semantic,
|
|
113
|
+
"depth": depth,
|
|
114
|
+
"normal": normal,
|
|
115
|
+
"noise": noise,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
def __len__(self):
|
|
119
|
+
return self.data_len
|