fusion-bench 0.2.24__py3-none-any.whl → 0.2.26__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.
Files changed (75) hide show
  1. fusion_bench/__init__.py +152 -42
  2. fusion_bench/dataset/__init__.py +27 -4
  3. fusion_bench/dataset/clip_dataset.py +2 -2
  4. fusion_bench/method/__init__.py +12 -1
  5. fusion_bench/method/classification/__init__.py +27 -2
  6. fusion_bench/method/classification/clip_finetune.py +6 -4
  7. fusion_bench/method/classification/image_classification_finetune.py +214 -0
  8. fusion_bench/method/dop/__init__.py +1 -0
  9. fusion_bench/method/dop/dop.py +366 -0
  10. fusion_bench/method/dop/min_norm_solvers.py +227 -0
  11. fusion_bench/method/dop/utils.py +73 -0
  12. fusion_bench/method/opcm/opcm.py +1 -0
  13. fusion_bench/method/pwe_moe/module.py +0 -2
  14. fusion_bench/method/tall_mask/task_arithmetic.py +2 -2
  15. fusion_bench/mixins/__init__.py +2 -0
  16. fusion_bench/mixins/pyinstrument.py +174 -0
  17. fusion_bench/mixins/simple_profiler.py +106 -23
  18. fusion_bench/modelpool/__init__.py +2 -0
  19. fusion_bench/modelpool/base_pool.py +77 -14
  20. fusion_bench/modelpool/clip_vision/modelpool.py +56 -19
  21. fusion_bench/modelpool/resnet_for_image_classification.py +208 -0
  22. fusion_bench/models/__init__.py +35 -9
  23. fusion_bench/optim/__init__.py +40 -2
  24. fusion_bench/optim/lr_scheduler/__init__.py +27 -1
  25. fusion_bench/optim/muon.py +339 -0
  26. fusion_bench/programs/__init__.py +2 -0
  27. fusion_bench/programs/fabric_fusion_program.py +2 -2
  28. fusion_bench/programs/fusion_program.py +271 -0
  29. fusion_bench/tasks/clip_classification/__init__.py +15 -0
  30. fusion_bench/utils/__init__.py +167 -21
  31. fusion_bench/utils/lazy_imports.py +91 -12
  32. fusion_bench/utils/lazy_state_dict.py +55 -5
  33. fusion_bench/utils/misc.py +104 -13
  34. fusion_bench/utils/packages.py +4 -0
  35. fusion_bench/utils/path.py +7 -0
  36. fusion_bench/utils/pylogger.py +6 -0
  37. fusion_bench/utils/rich_utils.py +1 -0
  38. fusion_bench/utils/state_dict_arithmetic.py +935 -162
  39. {fusion_bench-0.2.24.dist-info → fusion_bench-0.2.26.dist-info}/METADATA +8 -2
  40. {fusion_bench-0.2.24.dist-info → fusion_bench-0.2.26.dist-info}/RECORD +75 -56
  41. fusion_bench_config/method/bitdelta/bitdelta.yaml +3 -0
  42. fusion_bench_config/method/classification/image_classification_finetune.yaml +16 -0
  43. fusion_bench_config/method/classification/image_classification_finetune_test.yaml +6 -0
  44. fusion_bench_config/method/depth_upscaling.yaml +9 -0
  45. fusion_bench_config/method/dop/dop.yaml +30 -0
  46. fusion_bench_config/method/dummy.yaml +6 -0
  47. fusion_bench_config/method/ensemble/max_model_predictor.yaml +6 -0
  48. fusion_bench_config/method/ensemble/simple_ensemble.yaml +8 -1
  49. fusion_bench_config/method/ensemble/weighted_ensemble.yaml +8 -0
  50. fusion_bench_config/method/linear/linear_interpolation.yaml +8 -0
  51. fusion_bench_config/method/linear/weighted_average.yaml +3 -0
  52. fusion_bench_config/method/linear/weighted_average_for_llama.yaml +1 -1
  53. fusion_bench_config/method/model_recombination.yaml +8 -0
  54. fusion_bench_config/method/model_stock/model_stock.yaml +4 -1
  55. fusion_bench_config/method/opcm/opcm.yaml +5 -0
  56. fusion_bench_config/method/opcm/task_arithmetic.yaml +6 -0
  57. fusion_bench_config/method/opcm/ties_merging.yaml +5 -0
  58. fusion_bench_config/method/opcm/weight_average.yaml +5 -0
  59. fusion_bench_config/method/simple_average.yaml +9 -0
  60. fusion_bench_config/method/slerp/slerp.yaml +9 -0
  61. fusion_bench_config/method/slerp/slerp_lm.yaml +5 -0
  62. fusion_bench_config/method/smile_upscaling/smile_upscaling.yaml +3 -0
  63. fusion_bench_config/method/task_arithmetic.yaml +9 -0
  64. fusion_bench_config/method/ties_merging.yaml +3 -0
  65. fusion_bench_config/model_fusion.yaml +45 -0
  66. fusion_bench_config/modelpool/ResNetForImageClassfication/transformers/resnet152_cifar10.yaml +14 -0
  67. fusion_bench_config/modelpool/ResNetForImageClassfication/transformers/resnet152_cifar100.yaml +14 -0
  68. fusion_bench_config/modelpool/ResNetForImageClassfication/transformers/resnet18_cifar10.yaml +14 -0
  69. fusion_bench_config/modelpool/ResNetForImageClassfication/transformers/resnet18_cifar100.yaml +14 -0
  70. fusion_bench_config/modelpool/ResNetForImageClassfication/transformers/resnet50_cifar10.yaml +14 -0
  71. fusion_bench_config/modelpool/ResNetForImageClassfication/transformers/resnet50_cifar100.yaml +14 -0
  72. {fusion_bench-0.2.24.dist-info → fusion_bench-0.2.26.dist-info}/WHEEL +0 -0
  73. {fusion_bench-0.2.24.dist-info → fusion_bench-0.2.26.dist-info}/entry_points.txt +0 -0
  74. {fusion_bench-0.2.24.dist-info → fusion_bench-0.2.26.dist-info}/licenses/LICENSE +0 -0
  75. {fusion_bench-0.2.24.dist-info → fusion_bench-0.2.26.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,12 @@
1
+ # =============================================================================
2
+ # FusionBench Method Configuration: Spherical Linear Interpolation (SLERP)
3
+ # =============================================================================
4
+ # Interpolates between two parameter vectors on a hypersphere.
5
+ #
6
+ # - t in [0,1]: interpolation factor; 0 returns model0; 1 returns model1.
7
+ # - DOT_THRESHOLD: threshold to switch to linear interpolation when vectors are near-aligned.
8
+ # - epsilon: small constant to avoid division by zero.
9
+ # =============================================================================
1
10
  _target_: fusion_bench.method.SlerpMergeAlgorithm
2
11
  t: 0.5 # interpolation factor
3
12
  DOT_THRESHOLD: 0.9995
@@ -1,3 +1,8 @@
1
+ # =============================================================================
2
+ # FusionBench Method Configuration: SLERP for Causal LM
3
+ # =============================================================================
4
+ # Spherical linear interpolation between two causal language models.
5
+ # =============================================================================
1
6
  _target_: fusion_bench.method.SlerpForCausalLM
2
7
  t: 0.5
3
8
  model_save_path: ${path.log_dir}/checkpoint
@@ -1,3 +1,6 @@
1
+ # =============================================================================
2
+ # FusionBench Method Configuration: SMILE Upscaling
3
+ # =============================================================================
1
4
  _target_: fusion_bench.method.SmileUpscalingAlgorithm
2
5
  # merge device on cuda can accelerate the SVD computation
3
6
  device: cpu
@@ -1,2 +1,11 @@
1
+ # =============================================================================
2
+ # FusionBench Method Configuration: Task Arithmetic
3
+ # =============================================================================
4
+ # Performs task vector arithmetic: base + lambda * \sum_i (task_i - base).
5
+ #
6
+ # Notes
7
+ # - scaling_factor controls the contribution of the task delta.
8
+ # - Model compatibility is required (matching parameter shapes).
9
+ # =============================================================================
1
10
  _target_: fusion_bench.method.TaskArithmeticAlgorithm
2
11
  scaling_factor: 0.3
@@ -1,3 +1,6 @@
1
+ # =============================================================================
2
+ # FusionBench Method Configuration: Ties Merging
3
+ # =============================================================================
1
4
  _target_: fusion_bench.method.TiesMergingAlgorithm
2
5
  # Scaling factor $\lambda$
3
6
  scaling_factor: 0.3
@@ -0,0 +1,45 @@
1
+ # =============================================================================
2
+ # FusionBench Model Fusion Configuration
3
+ # =============================================================================
4
+ # This configuration file defines the settings for running model fusion experiments
5
+ # within FusionBench using standard PyTorch (without Lightning Fabric).
6
+ #
7
+ # The configuration includes:
8
+ #
9
+ # - Hydra framework settings and overrides
10
+ # - Path management for data, outputs, and logs
11
+ # - (core components) Model pool, fusion method, and task pool specifications
12
+ # - Experiment execution parameters and debugging options
13
+ #
14
+ # =============================================================================
15
+ # Hydra Configuration Defaults
16
+ # =============================================================================
17
+ defaults:
18
+ - hydra: default # Hydra framework configuration
19
+ - path: default # Path management configuration
20
+ # --- Core Components ---
21
+ - modelpool: CLIPVisionModelPool/clip-vit-base-patch32_TA8 # Model pool specification
22
+ - method: dummy # Fusion method (placeholder)
23
+ - taskpool: dummy # Task pool specification (placeholder)
24
+ - _self_ # Self-reference for override priority
25
+ # =============================================================================
26
+ # Program Configuration
27
+ # =============================================================================
28
+ _target_: fusion_bench.programs.ModelFusionProgram
29
+ _recursive_: false # Disable recursive instantiation
30
+ # =============================================================================
31
+ # Experiment Execution Settings
32
+ # =============================================================================
33
+ # Development and debugging options
34
+ fast_dev_run: false # This option is for quick testing. For example, run single batch instead of full dataset
35
+ dry_run: false # Show configuration without running experiment
36
+ print_config: true # Display full configuration before execution
37
+ print_function_call: true # Show detailed instantiation calls
38
+ # =============================================================================
39
+ # Output and Logging Configuration
40
+ # =============================================================================
41
+ # Model saving configuration
42
+ merged_model_save_path: null # Path to save merged model.
43
+ merged_model_save_kwargs: null # Additional kwargs for model saving.
44
+ # Report generation
45
+ report_save_path: "{log_dir}/program_report.json" # Experiment results report path
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ - /dataset/image_classification/train@train_datasets:
3
+ - cifar10
4
+ - /dataset/image_classification/test@val_datasets:
5
+ - cifar10
6
+ - _self_
7
+ _target_: fusion_bench.modelpool.ResNetForImageClassificationPool
8
+ _recursive_: False
9
+ type: transformers
10
+ models:
11
+ _pretrained_:
12
+ config_path: microsoft/resnet-152
13
+ pretrained: true
14
+ dataset_name: cifar10
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ - /dataset/image_classification/train@train_datasets:
3
+ - cifar100
4
+ - /dataset/image_classification/test@val_datasets:
5
+ - cifar100
6
+ - _self_
7
+ _target_: fusion_bench.modelpool.ResNetForImageClassificationPool
8
+ _recursive_: False
9
+ type: transformers
10
+ models:
11
+ _pretrained_:
12
+ config_path: microsoft/resnet-152
13
+ pretrained: true
14
+ dataset_name: cifar100
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ - /dataset/image_classification/train@train_datasets:
3
+ - cifar10
4
+ - /dataset/image_classification/test@val_datasets:
5
+ - cifar10
6
+ - _self_
7
+ _target_: fusion_bench.modelpool.ResNetForImageClassificationPool
8
+ _recursive_: False
9
+ type: transformers
10
+ models:
11
+ _pretrained_:
12
+ config_path: microsoft/resnet-18
13
+ pretrained: true
14
+ dataset_name: cifar10
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ - /dataset/image_classification/train@train_datasets:
3
+ - cifar100
4
+ - /dataset/image_classification/test@val_datasets:
5
+ - cifar100
6
+ - _self_
7
+ _target_: fusion_bench.modelpool.ResNetForImageClassificationPool
8
+ _recursive_: False
9
+ type: transformers
10
+ models:
11
+ _pretrained_:
12
+ config_path: microsoft/resnet-18
13
+ pretrained: true
14
+ dataset_name: cifar100
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ - /dataset/image_classification/train@train_datasets:
3
+ - cifar10
4
+ - /dataset/image_classification/test@val_datasets:
5
+ - cifar10
6
+ - _self_
7
+ _target_: fusion_bench.modelpool.ResNetForImageClassificationPool
8
+ _recursive_: False
9
+ type: transformers
10
+ models:
11
+ _pretrained_:
12
+ config_path: microsoft/resnet-50
13
+ pretrained: true
14
+ dataset_name: cifar10
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ - /dataset/image_classification/train@train_datasets:
3
+ - cifar100
4
+ - /dataset/image_classification/test@val_datasets:
5
+ - cifar100
6
+ - _self_
7
+ _target_: fusion_bench.modelpool.ResNetForImageClassificationPool
8
+ _recursive_: False
9
+ type: transformers
10
+ models:
11
+ _pretrained_:
12
+ config_path: microsoft/resnet-50
13
+ pretrained: true
14
+ dataset_name: cifar100