### Layer Reduction Configuration Source: https://www.deepspeed.ai/docs/config-json Configure layer reduction for model compression. This example enables layer reduction and specifies the number of layers to keep, along with module name prefixes and teacher layer indices. ```json "compression_training": { "layer_reduction": { "enabled": true, "keep_number_layer": 5, "module_name_prefix": "bert.encoder.layer", "teacher_layer": [ 2, 4, 6, 8, 10 ], "other_module_name": [ "bert.pooler", "bert.embeddings", "classifier" ] } } ``` -------------------------------- ### Configure FP16 Training Options Source: https://www.deepspeed.ai/docs/config-json Set up FP16 mixed precision training, including loss scaling and master weights. ```json "fp16": { "enabled": true, "auto_cast": false, "loss_scale": 0, "initial_scale_power": 16, "loss_scale_window": 1000, "hysteresis": 2, "consecutive_hysteresis": false, "min_loss_scale": 1, "fp16_master_weights_and_grads": false } ``` -------------------------------- ### Configure Parameter Offloading with ZeRO Stage 3 Source: https://www.deepspeed.ai/docs/config-json Enables and configures ZeRO optimization for parameter offloading to CPU or NVMe. This is only available with ZeRO stage 3. Ensure the 'device' value is supported to avoid assertions. ```json "offload_param": { "device": "[cpu|nvme]", "nvme_path": "/local_nvme", "pin_memory": [true|false], "buffer_count": 5, "buffer_size": 1e8, "max_in_cpu": 1e9 } ``` -------------------------------- ### Configure Optimizer Offloading with ZeRO Source: https://www.deepspeed.ai/docs/config-json Enables and configures ZeRO optimization for offloading optimizer computation to CPU and state to CPU/NVMe. CPU offloading works with ZeRO stage 1, 2, and 3. NVMe offloading requires ZeRO stage 3. Ensure the 'device' value is supported to avoid assertions. ```json "offload_optimizer": { "device": "[cpu|nvme]", "nvme_path": "/local_nvme", "pin_memory": [true|false], "ratio": 0.3, "buffer_count": 4, "fast_init": false } ``` -------------------------------- ### Configure Asynchronous I/O for Offloading Source: https://www.deepspeed.ai/docs/config-json Configures the asynchronous I/O module for offloading parameter and optimizer states to persistent storage using Linux native asynchronous I/O (libaio). ```json "aio": { "block_size": 1048576, "queue_depth": 8, "thread_count": 1, "single_submit": false, "overlap_events": true } ``` -------------------------------- ### Configure Checkpoint Options Source: https://www.deepspeed.ai/docs/config-json Set checkpointing behavior, including tag validation, universal loading, node-local storage usage, and parallel write configurations. ```json "checkpoint": { "tag_validation"="Warn", "load_universal"=false, "use_node_local_storage"=false, "parallel_write":{ "pipeline_stage": false } } ``` -------------------------------- ### Configure BFLOAT16 Training Source: https://www.deepspeed.ai/docs/config-json Enable BFLOAT16 training for improved performance on compatible hardware. This mode cannot be combined with AMP or FP16 training. ```json { "bf16": { "enabled": true, "bf16_master_weights_and_grads": true, "bf16_optimizer_states": true } } ``` -------------------------------- ### Configure Zero-One Adam Optimizer Source: https://www.deepspeed.ai/docs/config-json Configure the Zero-One Adam optimizer, which offers further optimizations over 1-bit Adam. Parameters like `var_freeze_step`, `var_update_scaler`, `local_step_scaler`, and `local_step_clipper` are specific to this variant. ```json "optimizer": { "type": "ZeroOneAdam", "params": { "lr": 1e-3, "weight_decay": 0.01, "bias_correction": false, "var_freeze_step": 1000, "var_update_scaler": 16, "local_step_scaler": 1000, "local_step_clipper": 16, "cuda_aware": false, "comm_backend_name": "nccl" } } ``` -------------------------------- ### Configure Muon Optimizer with Zero Stage 3 Source: https://www.deepspeed.ai/docs/config-json Configure the Muon optimizer, especially for Zero Stage 3 with NVMe offloading. Ensure `save_muon_momentum_buffer_in_memory` is set to true to keep momentum buffers in memory. ```json "optimizer": { "type": "Muon", "params": { "lr": 0.001, "momentum": 0.9, "weight_decay": 0.0, "muon_lr": 0.001, "ns_method": "gram" } }, "zero_optimization": { "stage": 3, "save_muon_momentum_buffer_in_memory": true } ``` -------------------------------- ### Configure AutoTP Tensor Parallelism Source: https://www.deepspeed.ai/docs/config-json Set up AutoTP tensor parallelism by specifying the autotp_size, preset model, and custom partition configurations. This enables efficient distributed training by sharding model parameters across multiple GPUs. ```json { "tensor_parallel": { "autotp_size": 4, "preset_model": "llama", "tp_overlap_comm": false, "partition_config": { "use_default_specs": false, "layer_specs": [ { "patterns": [".*\\.o_proj\\.weight$", ".*\\.down_proj\\.weight$"], "partition_type": "row" } ] } } } ``` -------------------------------- ### Configure Activation Checkpointing Source: https://www.deepspeed.ai/docs/config-json Use this JSON structure to configure activation checkpointing. Adjust boolean flags and integer values to control memory usage and performance. ```json { "activation_checkpointing": { "partition_activations": false, "cpu_checkpointing": false, "contiguous_memory_optimization": false, "number_checkpoints": null, "synchronize_checkpoint_boundary": false, "profile": false } } ``` -------------------------------- ### Configure WandB Logging in DeepSpeed Source: https://www.deepspeed.ai/docs/config-json Set up Weights & Biases (WandB) logging by enabling it and defining the project, team, and group for your runs. ```json { "wandb": { "enabled": true, "group": "my_group", "team": "my_team", "project": "my_project" } } ``` -------------------------------- ### Configure ZeRO Memory Optimizations Source: https://www.deepspeed.ai/docs/config-json Enables and configures ZeRO memory optimizations for FP16/BF16/FP32 training with the Adam optimizer. Specify the desired ZeRO stage and related parameters. ```json { "zero_optimization": { "stage": [0|1|2|3], "allgather_partitions": [true|false], "allgather_bucket_size": 5e8, "overlap_comm": false, "reduce_scatter": [true|false], "reduce_bucket_size": 5e8, "contiguous_gradients" : [true|false], "offload_param": { ... }, "offload_optimizer": { ... }, "stage3_max_live_parameters" : 1e9, "stage3_max_reuse_distance" : 1e9, "stage3_prefetch_bucket_size" : 5e8, "stage3_param_persistence_threshold" : 1e6, "sub_group_size" : 1e12, "elastic_checkpoint" : [true|false], "stage3_gather_16bit_weights_on_model_save": [true|false], "ignore_unused_parameters": [true|false], "round_robin_gradients": [true|false], "zero_hpz_partition_size": 1, "zero_quantized_weights": [true|false], "zero_quantized_gradients": [true|false], "log_trace_cache_warnings": [true|false], } } ``` -------------------------------- ### Configure Autotuning in Deepspeed Source: https://www.deepspeed.ai/docs/config-json Use this JSON configuration to enable and customize the autotuning feature. Specify directories for results and experiments, and define profiling parameters like metric, start/end steps, and batch size constraints. ```json { "autotuning": { "enabled": false, "results_dir": "autotuning_results", "exps_dir": "autotuning_exps", "overwrite": false, "metric": "throughput", "start_profile_step": 3, "end_profile_step": 5, "fast": true, "max_train_batch_size": null, "mp_size": 1, "num_tuning_micro_batch_sizes": 3, "tuner_type": "model_based", "tuner_early_stopping": 5, "tuner_num_trials": 50, "arg_mappings": null } } ``` -------------------------------- ### Configure Automatic Mixed Precision (AMP) Training Source: https://www.deepspeed.ai/docs/config-json Enable automatic mixed precision training using NVIDIA's Apex AMP package. This mode is not compatible with FP16 training or ZeRO. ```json { "amp": { "enabled": true, "opt_level": "O1" } } ``` -------------------------------- ### Elastic Training Configuration Source: https://www.deepspeed.ai/docs/config-json Configure elastic training parameters to enable dynamic scaling of resources during training. This includes settings for batch size, GPU count, and parallelism. ```json { "elasticity": { "enabled": true, "max_train_batch_size": "seqlen", "micro_batch_sizes": 8, "min_gpus": 1024, "max_gpus": "fixed_linear", "min_time": "seqlen", "version": 8, "ignore_non_elastic_batch_info": 1024, "num_gpus_per_node": "fixed_linear", "model_parallel_size": MODEL_PARALLEL_SIZE } } ``` -------------------------------- ### Configure FLOPs Profiler in Deepspeed Source: https://www.deepspeed.ai/docs/config-json Enable and configure the FLOPs profiler using this JSON snippet. Set the profile step, module depth, and whether to print detailed information. Specify an output file or print to stdout. ```json { "flops_profiler": { "enabled": false, "profile_step": 1, "module_depth": -1, "top_modules": 1, "detailed": true, "output_file": null, } } ``` -------------------------------- ### Configure Scheduler Parameters Source: https://www.deepspeed.ai/docs/config-json Define scheduler type and its parameters for learning rate scheduling during training. ```json "scheduler": { "type": "WarmupLR", "params": { "warmup_min_lr": 0, "warmup_max_lr": 0.001, "warmup_num_steps": 1000 } } ``` -------------------------------- ### Configure 1-bit Adam Optimizer Source: https://www.deepspeed.ai/docs/config-json Use this configuration for the 1-bit Adam optimizer, which includes parameters for compression and communication backends. `freeze_step`, `cuda_aware`, and `comm_backend_name` are specific to this optimizer. ```json "optimizer": { "type": "OneBitAdam", "params": { "lr": 0.001, "betas": [ 0.8, 0.999 ], "eps": 1e-8, "weight_decay": 3e-7, "freeze_step": 400, "cuda_aware": false, "comm_backend_name": "nccl" } } ``` -------------------------------- ### Configure Sparse Pruning with L1 Method Source: https://www.deepspeed.ai/docs/config-json Enables sparse pruning using the L1 method with shared parameters and specific group configurations. Use this for static, magnitude-based pruning. ```json "compression_training": { "sparse_pruning":{ "shared_parameters":{ "enabled": true, "schedule_offset": 30, "method": "l1" }, "different_groups":{ "sp1": { "params": { "dense_ratio": 0.5 }, "modules": [ "attention.self" ] } } } } ``` -------------------------------- ### Enable AutoSP with DeepSpeed Compile Source: https://www.deepspeed.ai/docs/config-json Configure the 'compile' section to enable Automatic Sequence Parallelism (AutoSP) and other compiler passes. Ensure 'deepcompile' is set to true and 'autosp' is included in the 'passes' list. ```json { "zero_optimization": {"stage": 0}, "compile": { "deepcompile": true, "passes": ["autosp"], } } ``` -------------------------------- ### Configure Activation Quantization Source: https://www.deepspeed.ai/docs/config-json Enable and configure activation quantization with shared parameters and specific quantization groups for modules. 'range_calibration' can be set to 'dynamic' or 'static'. ```json { "compression_training": { "activation_quantization": { "shared_parameters":{ "enabled": true, "quantization_type": "asymmetric", "range_calibration": "dynamic", "schedule_offset": 50 }, "different_groups":{ "aq1": { "params": { "bits": 8 }, "modules": [ "attention.output" ] } } } } ``` -------------------------------- ### Configure Weight Quantization Source: https://www.deepspeed.ai/docs/config-json Enable and configure weight quantization by specifying shared parameters and defining different quantization groups for specific modules. Ensure 'quantizer_kernel' is only enabled with DeepSpeed FP16 optimizer. ```json { "compression_training": { "weight_quantization": { "shared_parameters":{ "enabled": true, "quantizer_kernel": false, "schedule_offset": 0, "quantize_groups": 1, "quantize_verbose": false, "quantization_type": "symmetric", "rounding": "nearest", "quantize_weight_in_forward": false, "fp16_mixed_quantize":{ "enabled": false, "quantize_change_ratio": 0.001 } }, "different_groups":{ "wq1": { "params": { "start_bits": 8, "target_bits": 8, "quantization_period": 50 }, "modules": [ "attention.self", "intermediate" ] }, "wq2": { "params": { "start_bits": 4, "target_bits": 4, "quantization_period": 50 }, "modules": [ "attention.output" ] } } } } } ``` -------------------------------- ### Configure 1-bit LAMB Optimizer Source: https://www.deepspeed.ai/docs/config-json Configuration for the 1-bit LAMB optimizer. It includes parameters specific to LAMB optimization such as `max_coeff`, `min_coeff`, `coeff_beta`, and `factor_max`, along with 1-bit specific parameters. ```json "optimizer": { "type": "OneBitLamb", "params": { "lr": 11e-3, "weight_decay": 0.01, "bias_correction": false, "max_coeff": 0.3, "min_coeff": 0.01, "freeze_step": 1000, "cuda_aware": false, "comm_backend_name": "nccl", "coeff_beta": 0.9, "factor_max": 4.0 ``` -------------------------------- ### Configure TensorBoard Logging in DeepSpeed Source: https://www.deepspeed.ai/docs/config-json Enable and configure TensorBoard logging by specifying the output path and a job name for organizing logs. ```json { "tensorboard": { "enabled": true, "output_path": "output/ds_logs/", "job_name": "train_bert" } } ``` -------------------------------- ### Enable Curriculum Learning Source: https://www.deepspeed.ai/docs/config-json Enable curriculum learning by setting 'enabled' to true. Configure difficulty metrics, scheduling types, and specific schedule parameters. ```json { "curriculum_learning": { "enabled": true, "curriculum_type": "seqlen", "min_difficulty": 8, "max_difficulty": 1024, "schedule_type": "fixed_linear", "schedule_config": { "total_curriculum_step": 40000, "difficulty_step": 8 } } } ``` -------------------------------- ### Configure Comet ML Logging in DeepSpeed Source: https://www.deepspeed.ai/docs/config-json Enable Comet ML logging, specifying workspace, project, logging interval, experiment name, and API details. Supports online and offline modes. ```json { "comet": { "enabled": true, "workspace": "my_workspace", "project": "my_project", "samples_log_interval": 50, "experiment_name": "llama-fine-tuning", "experiment_key": "0c4a1c4a90664f2a8084e600b19a9d7", "online": false, "mode": "get" } } ``` -------------------------------- ### Communication Logging Configuration (Basic) Source: https://www.deepspeed.ai/docs/config-json Enable and configure basic communication logging to monitor operations launched via deepspeed.comm. Set verbose to false to avoid immediate printing of every operation. ```json "comms_logger": { "enabled": true, "verbose": false, "prof_all": true, "debug": false } ``` -------------------------------- ### Configure Row Pruning with TopK Method Source: https://www.deepspeed.ai/docs/config-json Enables row pruning using the TopK method, suitable for consecutive linear layers. This configuration specifies shared parameters and group-specific settings for pruning. ```json "compression_training": { "row_pruning":{ "shared_parameters":{ "enabled": true, "schedule_offset": 20, "method": "topk" }, "different_groups":{ "rp1": { "params": { "dense_ratio": 0.5 }, "modules": [ "intermediate.dense" ], "related_modules":[ ["layer.\w+.output.dense"] ] } } } } ``` -------------------------------- ### Configure PyTorch Autocast Training Source: https://www.deepspeed.ai/docs/config-json Enable PyTorch's native automatic mixed precision training via torch.autocast. Specify the dtype and modules for lower-precision communication. ```json { "torch_autocast": { "enabled": true, "dtype": "bfloat16", "lower_precision_safe_modules": ["torch.nn.Linear", "torch.nn.Conv2d"] } } ``` -------------------------------- ### Configure Gradient Clipping Source: https://www.deepspeed.ai/docs/config-json Enable gradient clipping to stabilize training by limiting the magnitude of gradients. The default value is 1.0. ```json { "gradient_clipping": 1.0 } ``` -------------------------------- ### Configure Adam Optimizer in DeepSpeed Source: https://www.deepspeed.ai/docs/config-json Use this configuration for the standard Adam optimizer. It supports common parameters like learning rate, betas, epsilon, and weight decay. ```json "optimizer": { "type": "Adam", "params": { "lr": 0.001, "betas": [ 0.8, 0.999 ], "eps": 1e-8, "weight_decay": 3e-7 } } ``` -------------------------------- ### 1-bit LAMB Optimizer Parameters Source: https://www.deepspeed.ai/docs/config-json These parameters are specific to the 1-bit LAMB optimizer. They control aspects like scaling coefficients, freeze steps, and communication backends. ```json { "factor_min": 0.5, "factor_threshold": 0.1 } } } ``` -------------------------------- ### Configure CSV File Logging in DeepSpeed Source: https://www.deepspeed.ai/docs/config-json Enable logging of training metrics to local CSV files. Specify the output path and a job name for organizing the CSV files. ```json { "csv_monitor": { "enabled": true, "output_path": "output/ds_logs/", "job_name": "train_bert" } } ``` -------------------------------- ### Configure Sparse Pruning with SNIP Momentum Source: https://www.deepspeed.ai/docs/config-json Enables sparse pruning with the SNIP Momentum method, including advanced scheduling and exclusion of specific modules. This configuration is mandatory for SNIP Momentum. ```json "compression_training": { "sparse_pruning":{ "shared_parameters":{ "enabled": true, "schedule_offset": 30, "schedule_offset_end": 90, "schedule_offset_stride": 15, "method": "snip_momentum", "block_pattern": "4x1", "dense_ratio": 0.4, "excluded_modules": ['classifier', 'pooler'] }, "different_groups":{ } } } ``` -------------------------------- ### Communication Logging Configuration (Specific Ops) Source: https://www.deepspeed.ai/docs/config-json Configure communication logging to profile only specific operations like 'all_reduce' and 'all_gather'. Ensure 'prof_all' is set to false when specifying operations. ```json "comms_logger": { "enabled": true, "verbose": false, "prof_all": false, "debug": false, "prof_ops": ["all_reduce", "all_gather"] } ``` -------------------------------- ### Configure DeepSpeed Data Efficiency Source: https://www.deepspeed.ai/docs/config-json Enable and configure data efficiency features like random-LTD and curriculum learning. Ensure 'enabled' is set to true to activate these techniques. The 'seed' parameter ensures reproducibility in data sampling. ```json { "data_efficiency": { "enabled": true, "seed": 1234, "data_routing": { "enabled": true, "random_ltd":{ "enabled": true, "total_layer_num": 24, "random_ltd_layer_num": 22, "random_ltd_layer_id": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22], "model_mask_name": "attention_mask", "model_type": "decoder", "hidden_state_order": "seq_batch_dim", "random_ltd_schedule": { "min_value": 128, "max_value": 2048, "schedule_type":"fixed_linear", "schedule_config": { "require_steps": 200000, "seq_per_step": 16 } } } }, "data_sampling": { "enabled": true, "num_epochs": 1, "num_workers": 0, "curriculum_learning": { "enabled": true, "data_cluster_path": "/path/to/data_clusters", "curriculum_metrics": { "vocabularyrarity": { "index_to_sample_path": "/path/to/index_to_sample", "index_to_metric_path": "/path/to/index_to_metric", "difficulty_type": "percentile", "clustering_type": "schedule_based", "min_difficulty": 1, "max_difficulty": 100, "schedule_type": "fixed_root", "schedule_config": { "total_curriculum_step": 110000, "difficulty_step": 1, "root_degree": 2 } } } } } } } ``` -------------------------------- ### Configure Head Pruning for Attention Layers Source: https://www.deepspeed.ai/docs/config-json Enable and configure head pruning for attention layers, specifying shared parameters and group-specific settings for pruning the output matrix and related Query/Key/Value matrices. ```json "compression_training": { "head_pruning":{ "shared_parameters":{ "enabled": true, "schedule_offset": 10, "method": "topk", "num_heads": 12 }, "different_groups":{ "rp1": { "params": { "dense_ratio": 0.5 }, "modules": [ "attention.output.dense" ], "related_modules":[ ["self.query", "self.key", "self.value"] ] } } } } ``` -------------------------------- ### Configure Channel Pruning for Conv2D Layers Source: https://www.deepspeed.ai/docs/config-json Enable and configure channel pruning for Conv2D layers, defining shared parameters and group-specific settings for pruning output channels and related layers. ```json "compression_training": { "channel_pruning":{ "shared_parameters":{ "enabled": true, "schedule_offset": 0, "method": "topk" }, "different_groups":{ "cp1": { "params": { "dense_ratio": 0.5 }, "modules": [ "layer....conv1" ], "related_modules": [ ["layer....conv2", "layer....bn1"] ] } } } } ``` -------------------------------- ### Configure Sparse Attention in DeepSpeed Source: https://www.deepspeed.ai/docs/config-json Use this JSON configuration to enable and customize sparse attention. Adjust parameters like 'mode', 'block', and 'attention' based on your model's requirements. ```json { "sparse_attention": { "mode": "fixed", "block": 16, "different_layout_per_head": true, "num_local_blocks": 4, "num_global_blocks": 1, "attention": "bidirectional", "horizontal_global_attention": false, "num_different_global_patterns": 4, "num_random_blocks": 0, "local_window_blocks": [4], "global_block_indices": [0], "global_block_end_indices": null, "num_sliding_window_blocks": 3 } } ``` -------------------------------- ### Configure Gradient Accumulation Data Type Source: https://www.deepspeed.ai/docs/config-json Specify the data type for gradient accumulation using the 'grad_accum_dtype' option within the 'data_types' configuration. This allows control over precision for accumulation, defaulting to match the model type if not specified. ```json "data_types": { "grad_accum_dtype"=["fp32" | "fp16" | "bf16"] } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.