Views
No views yet
1git clone https://github.com/zaydzuhri/flame.git
2cd flame
3git checkout token-order-prediction
4git submodule update --init --recursive --remote
5pip install .
6pip install wheel
7pip install flash-attn==2.7.3 --no-build-isolation --no-cache-dir1from datasets import load_dataset
2dataset = load_dataset("HuggingFaceFW/fineweb-edu", name="sample-100BT", num_proc=32, cache_dir="~/.cache")1NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/vanilla.340M.batch16.seqlen4096.context4096.warmup1000.update1.steps100000.lr3e-4.cosine --model.config configs/vanilla_transformer_340M.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 3e-4 --lr_scheduler.warmup_steps 1000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 16 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 1 --training.steps 100000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/vanilla-340M-4096-batch16-steps100000 --comm.init_timeout_seconds 600 --comm.train_timeout_seconds 300
2
3NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/mtp.340M.batch16.seqlen4096.context4096.warmup1000.update1.steps100000.lr3e-4.cosine --model.config configs/mtp_transformer_340M.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 3e-4 --lr_scheduler.warmup_steps 1000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 16 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 1 --training.steps 100000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/mtp-340M-4096-batch16-steps100000 --comm.init_timeout_seconds 1800 --comm.train_timeout_seconds 1800
4
5NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/top.340M.batch8.seqlen4096.context4096.warmup1000.update2.steps100000.lr3e-4.cosine --model.config configs/top_transformer_340M.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 3e-4 --lr_scheduler.warmup_steps 1000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 8 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 2 --training.steps 100000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/top-340M-4096-batch16-steps100000 --comm.init_timeout_seconds 600 --comm.train_timeout_seconds 300
6
7NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/vanilla.1B.batch8.seqlen4096.context4096.warmup2000.update2.steps200000.lr2e-4.cosine --model.config configs/vanilla_transformer_1B.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 2e-4 --lr_scheduler.warmup_steps 2000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 8 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 2 --training.steps 200000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/vanilla-1B-4096-batch8x2-steps200000 --comm.init_timeout_seconds 600 --comm.train_timeout_seconds 300
8
9NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/mtp.1B.batch16.seqlen4096.context4096.warmup2000.update1.steps200000.lr2e-4.cosine --model.config configs/mtp_transformer_1B.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 2e-4 --lr_scheduler.warmup_steps 2000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 16 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 1 --training.steps 200000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/mtp-1B-4096-batch16x1-steps200000 --comm.init_timeout_seconds 1800 --comm.train_timeout_seconds 1800
10
11NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/top.1B.batch8.seqlen4096.context4096.warmup2000.update2.steps200000.lr2e-4.cosine --model.config configs/top_transformer_1B.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 2e-4 --lr_scheduler.warmup_steps 2000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 8 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 2 --training.steps 200000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/top-1B-4096-batch8x2-steps200000 --comm.init_timeout_seconds 600 --comm.train_timeout_seconds 300
12
13NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/vanilla.7B.batch8.seqlen4096.context4096.warmup2000.update2.steps200000.lr1.2e-4.cosine --model.config configs/transformer_7B.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 1.2e-4 --lr_scheduler.warmup_steps 2000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 8 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 2 --training.steps 200000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/vanilla-7B-4096-batch8x2-steps200000 --comm.init_timeout_seconds 1800 --comm.train_timeout_seconds 1800
14
15NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/mtp.7B.batch8.seqlen4096.context4096.warmup2000.update2.steps200000.lr1.2e-4.cosine --model.config configs/mtp_transformer_7B.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 1.2e-4 --lr_scheduler.warmup_steps 2000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 8 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 2 --training.steps 200000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/mtp-7B-4096-batch8x2-steps200000 --comm.init_timeout_seconds 1800 --comm.train_timeout_seconds 1800
16
17NGPU=8 bash train.sh --job.config_file flame/models/fla.toml --job.dump_folder exp/top.7B.batch8.seqlen4096.context4096.warmup2000.update2.steps200000.lr1.2e-4.cosine --model.config configs/top_transformer_7B.json --model.tokenizer_path fla-hub/transformer-1.3B-100B --optimizer.name AdamW --optimizer.eps 1e-15 --optimizer.lr 1.2e-4 --lr_scheduler.warmup_steps 2000 --lr_scheduler.lr_min 0.1 --lr_scheduler.decay_type cosine --training.batch_size 8 --training.seq_len 4096 --training.context_len 4096 --training.gradient_accumulation_steps 2 --training.steps 200000 --training.max_norm 1.0 --training.skip_nan_inf --training.dataset ~/.cache/HuggingFaceFW___fineweb-edu/sample-100BT --training.dataset_split train --training.num_workers 32 --training.prefetch_factor 2 --training.seed 79 --training.compile --checkpoint.interval 10000 --checkpoint.load_step -1 --metrics.log_freq 5 --checkpoint.hf_upload_enabled --checkpoint.hf_repo_base_name zaydzuhri/top-7B-4096-batch8x2-steps200000 --comm.init_timeout_seconds 1800 --comm.train_timeout_seconds 1800flame, a minimal and efficient framework built on torchtitan for training Flash Linear Attention (FLA) models (and more broadly, arbitrary autoregressive language models) with blazing efficiency.fla and transformersflame repository and install the required dependencies:1git clone https://github.com/fla-org/flame.git
2cd flame
3pip install .flame manages minimal dependencies, only including fla and torchtitan as submodules.
After installation, initialize and update the submodules:git submodule update --init --recursive1from datasets import load_dataset
2
3# load fineweb-edu with parallel processing
4dataset = load_dataset("HuggingFaceFW/fineweb-edu", name="default", num_proc=64, cache_dir="/your/cache/path")
5
6# or load a subset with roughly 100B tokens, suitable for small- or medium-sized experiments
7dataset = load_dataset("HuggingFaceFW/fineweb-edu", name="sample-100BT", num_proc=64, cache_dir="/your/cache/path")[!WARNING] If the dataset is not downloaded beforehand, the streaming mode will attempt to fetch it from a remote server and download it on-the-fly, which can be highly unstable during training due to network issues.
For stable training, ensure the dataset is downloaded locally (see Dataset Preparation). Otherwise, we assume you are only testing the new corpus.
1bash train.sh \
2 --job.config_file flame/models/fla.toml \
3 --job.dump_folder exp/transformer-340M-4K-10B/batch1.seqlen65536.context4096.warmup1024.update1.steps20480.lr3e-4.cosine \
4 --model.config configs/transformer_340M.json \
5 --model.tokenizer_path fla-hub/transformer-1.3B-100B \
6 --optimizer.name AdamW \
7 --optimizer.eps 1e-15 \
8 --optimizer.lr 3e-4 \
9 --lr_scheduler.warmup_steps 1024 \
10 --lr_scheduler.lr_min 0.1 \
11 --lr_scheduler.decay_type cosine \
12 --training.batch_size 1 \
13 --training.seq_len 65536 \
14 --training.context_len 4096 \
15 --training.varlen \
16 --training.gradient_accumulation_steps 1 \
17 --training.steps 20480 \
18 --training.max_norm 1.0 \
19 --training.skip_nan_inf \
20 --training.dataset HuggingFaceFW/fineweb-edu \
21 --training.dataset_name sample-100BT \
22 --training.dataset_split train \
23 --training.streaming \
24 --training.num_workers 32 \
25 --training.prefetch_factor 2 \
26 --training.seed 42 \
27 --training.compile \
28 --checkpoint.interval 2048 \
29 --checkpoint.load_step -1 \
30 --checkpoint.keep_latest_k 2 \
31 --metrics.log_freq 1NGPU, which defaults to 8.NGPU=1.--lr_scheduler.decay_ratio: The proportion of the steps allocated to the decay phase. The learning rate will remain stable after the warmup period and only start decaying during the last decay_ratio portion of the total training steps, which is known as the Warmup-Stable-Decay (WSD) schedule.--lr_scheduler.warmup_steps: The number of steps for the learning rate warmup phase.--training.steps: Total number of training steps.--training.batch_size: Batch size per device, must be 1 if --training.varlen is set.--training.seq_len: The length of each sequence in the batch, which is concatenated from multiple samples.--training.context_len: The max allowed length of a sample. For non-varlen mode, this is equivalent to seq_len.--training.varlen: Whether to conduct variable-length sequence training.--training.gradient_accumulation_steps: Number of gradient accumulation steps.[!WARNING] The total number of tokens processed per batch, referred to asglobal_batch_size, is calculated as batch_size × gradient_accumulation_steps × num_gpus. Each step processesglobal_batch_size * seq_lentokens.
Monitor the value ofglobal_batch_size,warmup_steps, andstepscarefully when modifying any of the hyperparameters!
bash train.sh -h1options:
2 -h, --help show this help message and exit
3 --job.config_file JOB.CONFIG_FILE
4 Job config file
5 --job.dump_folder JOB.DUMP_FOLDER
6 Folder to dump job outputs
7 --job.description JOB.DESCRIPTION
8 Description of the job
9 --job.use_for_integration_test
10 Add this config to the integration test suite
11 --job.print_args Print the args to terminal
12 --model.config MODEL.CONFIG
13 Path to the model config
14 --model.norm_type MODEL.NORM_TYPE
15 Type of layer normalization to use [layernorm,
16 np_layernorm, rmsnorm, fused_rmsnorm]
17 --model.tokenizer_path MODEL.TOKENIZER_PATH
18 Tokenizer path
19 --profiling.enable_profiling
20 Whether to enable pytorch profiler
21 --profiling.save_traces_folder PROFILING.SAVE_TRACES_FOLDER
22 Trace files location
23 --profiling.profile_freq PROFILING.PROFILE_FREQ
24 How often to collect profiler traces, in iterations
25 --profiling.enable_memory_snapshot
26 Whether to dump memory snapshot
27 --profiling.save_memory_snapshot_folder PROFILING.SAVE_MEMORY_SNAPSHOT_FOLDER
28 Memeory snapshot files location
29 --optimizer.name OPTIMIZER.NAME
30 Optimizer to use
31 --optimizer.eps OPTIMIZER.EPS
32 Epsilon value for the optimizer.
33 --optimizer.fused Whether the fused implementation(CUDA only) is used.
34 --optimizer.scheduler {wsd,cosine,linear}
35 Scheduler to use. Currently supported: wsd, cosine,
36 and linear.
37 --optimizer.lr OPTIMIZER.LR
38 Learning rate to use
39 --optimizer.min_lr_ratio OPTIMIZER.MIN_LR_RATIO
40 Min lr ratio for lr scheduler
41 --optimizer.early_step_in_backward
42 Whether to apply optimizer in the backward. Caution,
43 optimizer_in_backward is not compatible with gradients
44 clipping, users should not call
45 register_post_accumulate_grad_hook after the optimizer
46 is built.
47 --training.batch_size TRAINING.BATCH_SIZE
48 Batch size
49 --training.seq_len TRAINING.SEQ_LEN
50 Sequence length
51 --training.context_len TRAINING.CONTEXT_LEN
52 Max length allowed for each sequence
53 --training.varlen Whether to take sequences of variable length as input
54 --training.warmup_steps TRAINING.WARMUP_STEPS
55 Steps for lr scheduler warmup, normally 1/5 of
56 --training.steps
57 --training.gradient_accumulation_steps TRAINING.GRADIENT_ACCUMULATION_STEPS
58 Number of steps to accumulate gradients before
59 updating parameters
60 --training.steps TRAINING.STEPS
61 How many train steps to run
62 --training.max_norm TRAINING.MAX_NORM
63 Max norm for gradient clipping
64 --training.skip_nan_inf
65 Skip batch updates when NaN or INF gradients are
66 encountered during training
67 --training.dataset TRAINING.DATASET
68 Dataset to use, with comma separated values
69 --training.dataset_name TRAINING.DATASET_NAME
70 The name of the dataset config, with comma separated
71 values if provided
72 --training.dataset_split TRAINING.DATASET_SPLIT
73 Dataset split to use, with comma separated values if
74 provided
75 --training.data_dir TRAINING.DATA_DIR
76 Data dirs to use, with comma separated values if
77 provided
78 --training.data_files TRAINING.DATA_FILES
79 Data files to use, with comma separated values if
80 provided
81 --training.data_probs TRAINING.DATA_PROBS
82 Data sampling probabilities, with comma separated
83 values if provided
84 --training.streaming Whether to load dataset in streaming mode, used for
85 huge dataset
86 --training.num_workers TRAINING.NUM_WORKERS
87 Number of subprocesses to use for data loading. 0
88 means that the data will be loaded in the main
89 process.
90 --training.prefetch_factor TRAINING.PREFETCH_FACTOR
91 Number of batches loaded in advance by each worker.2
92 means there will be a total of 2 * num_workers batches
93 prefetched across all workers.
94 --training.data_parallel_replicate_degree TRAINING.DATA_PARALLEL_REPLICATE_DEGREE
95 The `data_parallel_replicate_degree` argument
96 specifies the degree of data parallelism for weight
97 replication. When this value is greater than 1,
98 weights will be replicated across
99 `data_parallel_replicate_degree` ranks. If
100 `data_parallel_shard_degree` is also greater than 1,
101 the parallelism method used is HSDP (Hybrid Sharded
102 Data Parallelism). Otherwise, the parallelism method
103 used is DDP (Distributed Data Parallelism). 1 means
104 disabled.
105 --training.data_parallel_shard_degree TRAINING.DATA_PARALLEL_SHARD_DEGREE
106 The `data_parallel_shard_degree` argument specifies
107 the degree of data parallelism for weight sharding.
108 When this value is greater than 1, weights will be
109 sharded across `data_parallel_shard_degree` ranks. If
110 `data_parallel_replicate_degree` is also greater than
111 1, the parallelism method used is HSDP (Hybrid Sharded
112 Data Parallelism). Otherwise, the parallelism method
113 used is FSDP (Fully Sharded Data Parallelism). -1
114 means leftover ranks will be used (After
115 DP_REPLICATE/SP/PP). Note that only
116 `data_parallel_shard_degree` can be negative. 1 means
117 disabled.
118 --training.enable_cpu_offload
119 Whether to apply CPU offloading of parameters,
120 gradients, and optimizer states in FSDP
121 --training.tensor_parallel_degree TRAINING.TENSOR_PARALLEL_DEGREE
122 Tensor Parallelism degree. 1 means disabled.
123 --training.disable_loss_parallel
124 Whether to apply loss parallel when sequence parallel
125 is enabled
126 --training.mixed_precision_param {bfloat16,float32}
127 torch dtype to use for parameters when applying mixed
128 precision via FSDP. This feature only takes effect
129 when data_parallel_shard_degree > 1
130 --training.mixed_precision_reduce {float32}
131 torch dtype to use for reductions when applying mixed
132 precision via FSDP. This feature only takes effect
133 when data_parallel_shard_degree > 1
134 --training.compile Whether to compile the model
135 --training.gc_freq TRAINING.GC_FREQ
136 Python garbage control scheduling interval, in steps
137 --training.seed TRAINING.SEED
138 Choose the base RNG seed used for training
139 --training.deterministic
140 Use deterministic algorithms wherever possible, may be
141 slower
142 --metrics.log_freq METRICS.LOG_FREQ
143 How often to log metrics to TensorBoard, in iterations
144 --metrics.enable_tensorboard
145 Whether to log metrics to TensorBoard
146 --metrics.disable_color_printing
147 Whether to disable color printing in logs
148 --metrics.save_tb_folder METRICS.SAVE_TB_FOLDER
149 Folder to dump TensorBoard states
150 --metrics.rank_0_only
151 Whether to save TensorBoard metrics only for rank 0 or
152 for all ranks. When pipeline_parallel_degree is > 1,
153 this option uses the 0th rank of the last stage
154 pipeline group, which is the only stage that computes
155 loss metrics.
156 --metrics.enable_wandb
157 Whether to log metrics to Weights & Biases
158 --experimental.enable_async_tensor_parallel
159 Whether to apply async tensor parallel (currently only
160 effective when compile is enabled)
161 --experimental.pipeline_parallel_degree EXPERIMENTAL.PIPELINE_PARALLEL_DEGREE
162 Pipeline Parallelism degree, or number of ranks. 1
163 means disabled. If using looped schedules, this still
164 specifies the number of physical ranks, not the number
165 of stages. Stages per rank are inferred from split
166 points degree, and schedule.
167 --experimental.pipeline_parallel_split_points EXPERIMENTAL.PIPELINE_PARALLEL_SPLIT_POINTS [EXPERIMENTAL.PIPELINE_PARALLEL_SPLIT_POINTS ...]
168 Specify comma-separated names of modules to use as the
169 beginning of a split point. e.g. "layers.0,layers.2"
170 will cause the model to be split into 3 stages, the
171 first containing all the layers up to layers.0, the
172 second containing layers.0 and up to layers.2, the
173 third containing layers.2 and all the remaining
174 layers. Note: fully-automated splitting may be enabled
175 in the future, but currently the split points must be
176 specified manually.
177 --experimental.pipeline_parallel_schedule EXPERIMENTAL.PIPELINE_PARALLEL_SCHEDULE
178 Specify the Pipeline Parallel schedule to use. The
179 supported schedules are: https://github.com/pytorch/py
180 torch/blob/de4c2a3b4e89d96334dc678d1c3f2ae51a6630a0/to
181 rch/distributed/pipelining/schedules.py#L2161. The
182 schedule must be compatible with the split points and
183 stages_per_rank. Looped schedules (e.g.
184 Interleaved1F1B) require specifying
185 pipeline_parallel_degree = number of ranks, and
186 split_points = number of stages - 1
187 --experimental.pipeline_parallel_schedule_csv EXPERIMENTAL.PIPELINE_PARALLEL_SCHEDULE_CSV
188 Specify the path to the pipeline parallel schedule csv
189 file to use. The pipeline_parallel_schedule argument
190 must be either PipelineScheduleSingle,
191 PipelineScheduleMulti, or _PipelineScheduleRuntime.
192 --experimental.pipeline_parallel_microbatches EXPERIMENTAL.PIPELINE_PARALLEL_MICROBATCHES
193 How many microbatches to split the global training
194 batch into when using pipeline parallelism. The global
195 training batch size must be evenly divisible by the
196 number of microbatches. The default value will be the
197 number of pipeline stages, if unspecified.
198 --experimental.enable_compiled_autograd
199 Enable CompiledAutograd to compile the backward.
200 --experimental.context_parallel_degree EXPERIMENTAL.CONTEXT_PARALLEL_DEGREE
201 Context parallelism degree. 1 means disabled.
202 --experimental.context_parallel_rotate_method EXPERIMENTAL.CONTEXT_PARALLEL_ROTATE_METHOD
203 The collective to use in context parallel SDPA for kv
204 shards exchange. 'allgather' means to all-gather all
205 kv shards on ranks after the first sub-SDPA
206 computation, 'alltoall' means to all-to-all shuffle
207 the kv shards. The default value is 'allgather'.
208 --checkpoint.enable_checkpoint
209 Whether to enable checkpoint
210 --checkpoint.folder CHECKPOINT.FOLDER
211 The folder to store the checkpoints. When
212 enable_checkpoint is set to true, checkpoints will be
213 in {--job.dump_folder}/{--checkpoint.folder}.
214 --checkpoint.interval_type CHECKPOINT.INTERVAL_TYPE
215 Checkpointing interval unit of measurement ['step',
216 'seconds']
217 --checkpoint.interval CHECKPOINT.INTERVAL
218 Checkpointing interval, in steps or seconds depending
219 on --checkpoint.interval_type
220 --checkpoint.model_weights_only
221 When model_weights_only=True, only model weights will
222 be saved at the end of training. With this,
223 checkpoints can be loaded using `torch.load(...,
224 weights_only=True)` after conversion. When
225 model_weights_only=False, the full checkpoint will be
226 saved. A full checkpoint includes model, optimizer and
227 train_state, which can be used to resume training. The
228 default value is false.
229 --checkpoint.export_dtype {float16,bfloat16,float32}
230 Converts to the specified precision when training
231 completes and model_weights_only=true. Currently
232 supports float32, float16, and bfloat16. The default
233 value is float32.
234 --checkpoint.create_seed_checkpoint
235 Initializes the full model without applying
236 parallelisms, and then saves it as a seed checkpoint.
237 Note: requires user to call train.py without
238 specifying any parallelisms, e.g. NGPU=1. Could be
239 implemented as a separate script, but this way shares
240 more code.
241 --checkpoint.async_mode CHECKPOINT.ASYNC_MODE
242 Which async checkpoint mode to use. Currently there
243 are 3 different modes. 1. "disabled": synchronized
244 checkpointing will be used. 2. "async":
245 torch.distributed.checkpoint.async_save will be used.
246 1. "async_with_pinned_mem": this option utilizes a
247 dedicated pinned memory space and creates a separate
248 process for faster GPU->CPU transfer performance and
249 eliminating GIL contention. The cost is increased CPU
250 memory usage. If insufficient CPU memory is available,
251 performance may degrade due to memory paging. For most
252 users, "async" should suffice as the performance
253 overhead is typically small (on the order of tens of
254 seconds) compared to checkpointing frequency. This
255 mode can be employed to pursue near-zero checkpointing
256 times (e.g., < 1 second) given appropriate hardware
257 support such as ample CPU memory and fast PCIe.
258 "disabled" is the default mode.
259 --checkpoint.keep_latest_k CHECKPOINT.KEEP_LATEST_K
260 Keeps only the latest k checkpoints, and purging older
261 ones. If 0, keep all checkpoints. 0 is the default
262 value.
263 --checkpoint.load_step CHECKPOINT.LOAD_STEP
264 Load the checkpoint at the specified step. If -1, load
265 the latest checkpoint.
266 --float8.enable_float8_linear
267 If true, swaps `torch.nn.Linear` with `Float8Linear`.
268 This feature requires you to install 'torchao' which
269 can be found here: https://github.com/pytorch/ao
270 --float8.enable_fsdp_float8_all_gather
271 Whether enable float8 all-gather in FSDP
272 --float8.precompute_float8_dynamic_scale_for_fsdp
273 Whether precompute float8 scales dynamically for FSDP
274 --float8.scaling_type_input {dynamic,delayed}
275 float8 scaling for input, dynamic (default) or delayed
276 --float8.scaling_type_weight FLOAT8.SCALING_TYPE_WEIGHT
277 float8 scaling for input, dynamic (default) or delayed
278 --float8.scaling_type_grad_output FLOAT8.SCALING_TYPE_GRAD_OUTPUT
279 float8 scaling for input, dynamic (default) or delayed
280 --comm.init_timeout_seconds COMM.INIT_TIMEOUT_SECONDS
281 Timeout for communication operations, during
282 initialization and first train step.
283 --comm.train_timeout_seconds COMM.TRAIN_TIMEOUT_SECONDS
284 Timeout for communication operations after the first
285 train step -- usually a tighter bound than during
286 initialization.
287 --comm.trace_buf_size COMM.TRACE_BUF_SIZE
288 Flight recorder ring buffer size, >0 means recording
289 by default, 0 means disabled
290 --memory_estimation.enabled
291 Whether to estimate memory usage for FSDP
292 --memory_estimation.disable_fake_mode
293 Whether to estimate memory under FakeTensorModetorch.compiletorch 2.0, torch.compile has been introduced as a new feature to seamlessly accelerate training processes.
In flame, one can simply enable torch.compile by adding --training.compile flag to your training script.fla has integrated numerous fused kernels for acceleration, which may potentially conflict with torch.compile.
We are actively working on resolving these issues to make compilation transparent to users.
In the meantime, please ensure you are using the latest dependencies.torch>=2.6 and triton>=3.0.flame allows training with multiple datasets easily.
For example, you can specify the following arguments to train on 6 datasets with different proportions:1 --training.dataset HuggingFaceFW/fineweb-edu,opencsg/Fineweb-Edu-Chinese-V2.1,OpenCoder-LLM/opc-fineweb-code-corpus,math-ai/AutoMathText,EleutherAI/proof-pile-2,OpenCoder-LLM/opc-fineweb-math-corpus \
2 --training.data_probs 0.6,0.15,0.15,0.014,0.058,0.028 \[!NOTE]
We have done this conversion automatically in the training script since our latest updates.
python -m flame.utils.convert_dcp_to_hf --path <path_to_model> --step <step> --config <path_to_config> --tokenizer <path_to_tokenizer>huggingface_hub for wider accessibility.flame.python -m flame.utils.convert_hf_to_dcp --model <path_to_hf> --checkpoint <path_to_dcp/checkpoint/step-0><path_to_dcp> is the directory where your distributed checkpoints will be stored.
The checkpoint is intentionally saved at <step-0> within the checkpoint folder to ensure it is loadable by flame during the initial training step, similar to how a seed checkpoint is handled.flame as usual, continuing from where the pretrained model left off.MASTER_ADDR=<ip> and MASTER_PORT=<port> before running the training script across all nodes.torchtitan provides a Slurm script for multi-node training, which you can use as a reference or starting point.