PWEMoE: Pareto-Driven Weight-Ensembling Mixture of Experts¶
Abstract
Solving multi-objective optimization problems for large deep neural networks is a challenging task due to the complexity of the loss landscape and the expensive computational cost of training and evaluating models. Efficient Pareto front approximation of large models enables multi-objective optimization for various tasks such as multi-task learning and trade-off analysis. Existing algorithms for learning Pareto set, including (1) evolutionary, hypernetworks, and hypervolume-maximization methods, are computationally expensive and have restricted scalability to large models; (2) Scalarization algorithms, where a separate model is trained for each objective ray, which is inefficient for learning the entire Pareto set and fails to capture the objective trade-offs effectively. Inspired by the recent success of model merging, we propose a practical and scalable approach to Pareto set learning problem via mixture of experts (MoE) based model fusion. By ensembling the weights of specialized single-task models, the MoE module can effectively capture the trade-offs between multiple objectives and closely approximate the entire Pareto set of large neural networks. Once the routers are learned and a preference vector is set, the MoE module can be unloaded, thus no additional computational cost is introduced during inference. We conduct extensive experiments on vision and language tasks using large-scale models such as CLIP-ViT and GPT-2. The experimental results demonstrate that our method efficiently approximates the entire Pareto front of large models. Using only hundreds of trainable parameters of the MoE routers, our method even has lower memory usage compared to linear scalarization and algorithms that learn a single Pareto optimal solution, and are scalable to both the number of objectives and the size of the model. Our method significantly reduces the computational burden of learning the Pareto set, for example, in the two-task case, it can be achieved in just a few minutes. Code is available at: GitHub .
Examples¶
Not tested yet
The examples provided below have not been tested yet.
For a thoroughly tested and verified implementation of the algorithm, please refer to the original repository: tanganke/pareto_set_learning . Additionally, the experimental results and further insights into the algorithm can be found in the original research paper: arXiv:2406.09770 .
PWEMoE-LS on eight image classification tasks using CLIP-ViT-B/32 models, and the results are logged to outputs/logs/ViT-B-32/PWEMoE-LS-8tasks
.
fusion_bench \
method=pwe_moe_ls_for_clip \
modelpool=CLIPVisionModelPool/clip-vit-base-patch32_TA8 \
taskpool=CLIPVisionModelTaskPool/clip-vit-classification_TA8 \
fabric.loggers.root_dir=outputs/logs/ViT-B-32 \
fabric.loggers.name=PWEMoE-LS-8tasks
References¶
clip_pwe_moe
¶
PWEMoEAlgorithmForCLIP
¶
Bases: BaseAlgorithm
, SimpleProfilerMixin
, CLIPClassificationMixin
Source code in fusion_bench/method/pwe_moe/clip_pwe_moe.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
compute_loss(model, ray, losses)
abstractmethod
¶
Computes the overall losses using the given preference ray.
Parameters:
-
model
¶Module
) –The model being trained.
-
ray
¶Tensor
) –A tensor representing the preference ray, which contains the weights for each objective.
-
losses
¶List[Tensor]
) –A list of loss values for each objective.
Source code in fusion_bench/method/pwe_moe/clip_pwe_moe.py
load_clip_models()
¶
Loads the pretrained CLIP model and the fine-tuned models for each dataset specified in the configuration.
Source code in fusion_bench/method/pwe_moe/clip_pwe_moe.py
setup_train_loaders()
¶
Loads the datasets specified in the configuration.
Source code in fusion_bench/method/pwe_moe/clip_pwe_moe.py
PWEMoELinearScalarizationForCLIP
¶
PWEMoExactParetoOptimalForCLIP
¶
Bases: PWEMoEAlgorithmForCLIP