|
| 1 | +# Copyright 2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# When scaling to a large number of devices with limited model dimensions, |
| 16 | +# introducing an additional FSDP axis prevents sharding limits and improves |
| 17 | +# GMM efficiency. This rule demonstrates using both `fsdp` and `fsdp_transpose` |
| 18 | +# to enable efficient training across O(1000) chips. |
| 19 | + |
| 20 | +mesh_axes: ['data', 'stage', 'fsdp', 'fsdp_transpose', 'context', 'expert'] |
| 21 | +data_sharding: [['data', 'stage', 'fsdp', 'fsdp_transpose', 'context', 'expert']] |
| 22 | +context_sharding: 'context' |
| 23 | +logical_axis_rules: [ |
| 24 | + # ========================================== |
| 25 | + # Vocabulary Embedding |
| 26 | + # ========================================== |
| 27 | + # Vocab Activations |
| 28 | + ['activation_embed_and_logits_batch', ['data', 'stage', 'fsdp', 'fsdp_transpose', 'expert']], |
| 29 | + ['activation_embed_and_logits_batch_sequence', ['data', 'stage', 'fsdp', 'fsdp_transpose', 'context', 'expert']], |
| 30 | + # Vocab Weights |
| 31 | + ['vocab', []], |
| 32 | + ['embed_vocab', ['fsdp', 'fsdp_transpose', 'context', 'expert']], |
| 33 | + # ========================================== |
| 34 | + # Attention |
| 35 | + # ========================================== |
| 36 | + # Attention Activations |
| 37 | + ['activation_batch_attn', ['data', 'fsdp', 'fsdp_transpose', 'expert']], |
| 38 | + ['activation_length_attn', ['context']], |
| 39 | + ['activation_q_length', ['context']], |
| 40 | + ['activation_kv_batch', ['data', 'fsdp', 'fsdp_transpose', 'expert']], |
| 41 | + # Attention Weights |
| 42 | + ['q_lora', ['fsdp']], |
| 43 | + ["q_lora_up_proj", ['fsdp_transpose', 'expert']], |
| 44 | + ['kv_lora', ['fsdp']], |
| 45 | + ["kv_lora_up_proj", ['fsdp_transpose', 'expert']], |
| 46 | + # ========================================== |
| 47 | + # Mixture of Experts (MoE) |
| 48 | + # ========================================== |
| 49 | + # MoE Activations |
| 50 | + ['activation_batch_moe', ['data', 'fsdp', 'fsdp_transpose']], |
| 51 | + ['activation_length_moe', ['context']], |
| 52 | + ['activation_norm_length_moe', ['context']], |
| 53 | + ['activation_mlp_moe', []], |
| 54 | + ['activation_exp', ['expert']], |
| 55 | + # MoE Weights |
| 56 | + ['exp', 'expert'], |
| 57 | + ['mlp_moe', ['fsdp_transpose']], |
| 58 | + ['embed_moe', ['fsdp', 'context']], |
| 59 | + # ========================================== |
| 60 | + # Standard MLP / Dense Layers / Model Structure |
| 61 | + # ========================================== |
| 62 | + # Dense Activations |
| 63 | + ['activation_mlp', []], |
| 64 | + # Note activation batch and length also get used in vocab |
| 65 | + ['activation_batch', ['data', 'fsdp', 'fsdp_transpose', 'expert']], |
| 66 | + ['activation_length', ['context']], |
| 67 | + ['activation_norm_length', ['context']], |
| 68 | + ['activation_embed', []], |
| 69 | + ['activation_stage', 'stage'], |
| 70 | + # General Weights |
| 71 | + ['mlp', ['fsdp_transpose']], |
| 72 | + ['embed', ['fsdp', 'context', 'expert']], |
| 73 | + ['norm', []], |
| 74 | + ['layers', 'stage'], |
| 75 | + ] |
0 commit comments