kaira.training.TrainingArguments

Inheritance diagram for TrainingArguments
- class kaira.training.TrainingArguments(snr_min: float = 0.0, snr_max: float = 20.0, noise_variance_min: float = 0.1, noise_variance_max: float = 2.0, channel_uses: int | None = None, code_length: int | None = None, info_length: int | None = None, channel_type: str = 'awgn', push_to_hub: bool = False, hub_model_id: str | None = None, hub_token: str | None = None, hub_private: bool = False, hub_strategy: str = 'end', output_dir: str = './results', num_train_epochs: float = 10.0, per_device_train_batch_size: int = 32, per_device_eval_batch_size: int = 32, learning_rate: float = 0.0001, warmup_steps: int = 1000, logging_steps: int = 100, eval_steps: int = 500, save_steps: int = 1000, eval_strategy: str = 'steps', logging_strategy: str = 'steps', save_strategy: str = 'steps', **kwargs)[source]
Bases:
TrainingArgumentsTraining arguments that support Hydra configuration management.
This class extends transformers.TrainingArguments to provide seamless integration with Hydra configuration management while maintaining full compatibility with Hugging Face ecosystem. It supports:
Direct instantiation from Hydra DictConfig via from_hydra_config
Communication-specific parameters
Automatic parameter filtering and validation
Examples
>>> # From Hydra config >>> hydra_config = OmegaConf.create({"training": {"output_dir": "./results", "num_train_epochs": 10}}) >>> args = TrainingArguments.from_hydra_config(hydra_config)
>>> # With communication parameters >>> args = TrainingArguments( ... output_dir="./results", ... snr_min=0.0, ... snr_max=20.0, ... channel_uses=64 ... )
Methods
Initialize TrainingArguments.
Create TrainingArguments from command-line arguments.
Create TrainingArguments from Hydra configuration.
Get noise variance range as tuple.
Returns the log level to be used depending on whether this process is the main process of node 0, main process of node non-0, or a non-main process.
Get SNR range as tuple.
Get number of steps used for a linear warmup.
A context manager for torch distributed environment where on needs to do something on the main process, while blocking replicas, and when it's finished releasing the replicas.
Convert to dictionary representation.
Convert to Hydra DictConfig.
Serializes this instance to a JSON string.
Sanitized serialization to use with TensorBoard’s hparams
Attributes
The actual timeout for torch.distributed.init_process_group since it expects a timedelta variable.
The device used by this process.
The actual batch size for evaluation (may differ from per_gpu_eval_batch_size in distributed training).
The index of the local process used.
The number of GPUs used by this process.
The current mode used for parallelism if multiple GPUs/TPU cores are available.
Can be subclassed and overridden for some specific integrations.
The index of the current process used.
Whether or not the current process should produce log.
Whether or not the current process should write to disk, e.g., to save models and checkpoints.
The actual batch size for training (may differ from per_gpu_train_batch_size in distributed training).
The number of processes used in parallel.
Examples using
kaira.training.TrainingArguments
Original DeepJSCC Model (Bourtsoulatze 2019) with Training
Original DeepJSCC Model (Bourtsoulatze 2019) with Training
Deep Joint Source-Channel Coding (DeepJSCC) Model - Bourtsoulatze2019 Implementation
Deep Joint Source-Channel Coding (DeepJSCC) Model - Bourtsoulatze2019 Implementation- __init__(snr_min: float = 0.0, snr_max: float = 20.0, noise_variance_min: float = 0.1, noise_variance_max: float = 2.0, channel_uses: int | None = None, code_length: int | None = None, info_length: int | None = None, channel_type: str = 'awgn', push_to_hub: bool = False, hub_model_id: str | None = None, hub_token: str | None = None, hub_private: bool = False, hub_strategy: str = 'end', output_dir: str = './results', num_train_epochs: float = 10.0, per_device_train_batch_size: int = 32, per_device_eval_batch_size: int = 32, learning_rate: float = 0.0001, warmup_steps: int = 1000, logging_steps: int = 100, eval_steps: int = 500, save_steps: int = 1000, eval_strategy: str = 'steps', logging_strategy: str = 'steps', save_strategy: str = 'steps', **kwargs)[source]
Initialize TrainingArguments.
- Parameters:
snr_min – Minimum SNR value for training
snr_max – Maximum SNR value for training
noise_variance_min – Minimum noise variance
noise_variance_max – Maximum noise variance
channel_uses – Number of channel uses
code_length – Length of the code
info_length – Length of information bits
channel_type – Type of channel simulation
push_to_hub – Whether to upload model to Hugging Face Hub
hub_model_id – Model ID for Hugging Face Hub (e.g., ‘username/model-name’)
hub_token – Hugging Face Hub authentication token
hub_private – Make the Hub repository private
hub_strategy – When to upload to Hub (‘end’ or ‘checkpoint’)
output_dir – Output directory for results
num_train_epochs – Number of training epochs
per_device_train_batch_size – Training batch size per device
per_device_eval_batch_size – Evaluation batch size per device
learning_rate – Learning rate
warmup_steps – Number of warmup steps
logging_steps – Log every X steps
eval_steps – Evaluate every X steps
save_steps – Save every X steps
eval_strategy – Evaluation strategy
logging_strategy – Logging strategy
save_strategy – Save strategy
**kwargs – Additional arguments passed to TrainingArguments
- classmethod from_hydra_config(hydra_cfg: DictConfig, **override_kwargs) TrainingArguments[source]
Create TrainingArguments from Hydra configuration.
- Parameters:
hydra_cfg – Hydra DictConfig containing training configuration
**override_kwargs – Additional arguments to override or add
- Returns:
TrainingArguments instance
- classmethod from_cli_args(args) TrainingArguments[source]
Create TrainingArguments from command-line arguments.
- Parameters:
args – Parsed command-line arguments (from argparse)
- Returns:
TrainingArguments instance
- to_hydra_config() Any[source]
Convert to Hydra DictConfig.
- Returns:
DictConfig representation
- Raises:
ImportError – If Hydra is not available
- property ddp_timeout_delta: timedelta
The actual timeout for torch.distributed.init_process_group since it expects a timedelta variable.
- default_optim = 'adamw_torch'
- property eval_batch_size: int
The actual batch size for evaluation (may differ from per_gpu_eval_batch_size in distributed training).
- framework = 'pt'
- get_process_log_level()[source]
Returns the log level to be used depending on whether this process is the main process of node 0, main process of node non-0, or a non-main process.
For the main process the log level defaults to the logging level set (logging.WARNING if you didn’t do anything) unless overridden by log_level argument.
For the replica processes the log level defaults to logging.WARNING unless overridden by log_level_replica argument.
The choice between the main and replica process settings is made according to the return value of should_log.
- property local_process_index
The index of the local process used.
- main_process_first(local=True, desc='work')[source]
A context manager for torch distributed environment where on needs to do something on the main process, while blocking replicas, and when it’s finished releasing the replicas.
One such use is for datasets’s map feature which to be efficient should be run once on the main process, which upon completion saves a cached version of results and which then automatically gets loaded by the replicas.
- Parameters:
local (bool, optional, defaults to True) – if True first means process of rank 0 of each node if False first means process of rank 0 of node rank 0 In multi-node environment with a shared filesystem you most likely will want to use local=False so that only the main process of the first node will do the processing. If however, the filesystem is not shared, then the main process of each node will need to do the processing, which is the default behavior.
desc (str, optional, defaults to “work”) – a work description to be used in debug logs
- property n_gpu
The number of GPUs used by this process.
Note
This will only be greater than one when you have multiple GPUs available but are not using distributed training. For distributed training, it will always be 1.
- property parallel_mode
The current mode used for parallelism if multiple GPUs/TPU cores are available. One of:
ParallelMode.NOT_PARALLEL: no parallelism (CPU or one GPU).
ParallelMode.NOT_DISTRIBUTED: several GPUs in one single process (uses torch.nn.DataParallel).
ParallelMode.DISTRIBUTED: several GPUs, each having its own process (uses torch.nn.DistributedDataParallel).
ParallelMode.TPU: several TPU cores.
- property place_model_on_device
Can be subclassed and overridden for some specific integrations.
- property process_index
The index of the current process used.
- property should_log
Whether or not the current process should produce log.
- property should_save
Whether or not the current process should write to disk, e.g., to save models and checkpoints.
- to_sanitized_dict() dict[str, Any][source]
Sanitized serialization to use with TensorBoard’s hparams
- property train_batch_size: int
The actual batch size for training (may differ from per_gpu_train_batch_size in distributed training).
- property world_size
The number of processes used in parallel.