Skip to content

parameter_scheduler

Adjusts parameter values based on a specified strategy.

Parameters:

Name Type Description Default
strategy str

The scheduling strategy to apply. Supported: 'half'. Default is 'half'.

'half'
parameter_list list

A list of parameters to schedule. Default is None.

None
lower_bound int

The minimum value a parameter can take. Default is 1.

1

Returns:

Type Description
list

The adjusted parameter values.

Raises:

Type Description
ValueError

If parameter_list is not provided or the strategy is unsupported.

Source code in tinybig/util/utility.py
def parameter_scheduler(strategy: str = 'half', parameter_list: list = None, lower_bound: int = 1):
    """
    Adjusts parameter values based on a specified strategy.

    Parameters
    ----------
    strategy : str, optional
        The scheduling strategy to apply. Supported: 'half'. Default is 'half'.
    parameter_list : list, optional
        A list of parameters to schedule. Default is None.
    lower_bound : int, optional
        The minimum value a parameter can take. Default is 1.

    Returns
    -------
    list
        The adjusted parameter values.

    Raises
    ------
    ValueError
        If `parameter_list` is not provided or the strategy is unsupported.
    """
    if parameter_list is None:
        raise ValueError("Parameter list must be provided.")
    if strategy == 'half':
        result = [max(int(parameter/2), lower_bound) if parameter is not None else None for parameter in parameter_list]
        return result
    else:
        raise ValueError("Parameter strategy not supported.")