panther.tuner.SkAutoTuner.Configs package#
Submodules#
panther.tuner.SkAutoTuner.Configs.LayerConfig module#
- class panther.tuner.SkAutoTuner.Configs.LayerConfig.LayerConfig(layer_names, params, separate=True, copy_weights=True)[source]#
Bases:
objectConfiguration for a single layer or group of layers to tune.
- layer_names#
Layer selector (string, list, or dict with criteria)
- params#
Dictionary of parameter names to ParamSpec or list of values
- separate#
Whether to tune each layer independently
- copy_weights#
Whether to copy weights when replacing layers
- __init__(layer_names, params, separate=True, copy_weights=True)[source]#
Initialize a layer configuration.
- Parameters:
layer_names – Layer selector, can be: - A string: Regex pattern or substring - A list of strings: Multiple patterns or exact names - A dictionary with selection criteria (pattern, type, contains, indices, range)
params – Dictionary of parameter names and their possible values
separate – Whether to tune layers separately or jointly
copy_weights – Whether to copy weights when replacing layers
panther.tuner.SkAutoTuner.Configs.LayerNameResolver module#
- class panther.tuner.SkAutoTuner.Configs.LayerNameResolver.LayerNameResolver(model, layer_map=None)[source]#
Bases:
objectProvides intuitive ways to select layers for tuning in large models.
This resolver allows users to specify layers using patterns, types, or indices rather than requiring exact layer names.
- __init__(model, layer_map=None)[source]#
Initialize the resolver with a model.
- Parameters:
model – The neural network model to analyze
- resolve(selectors)[source]#
Resolve layer name selectors to actual layer names in the model.
- Parameters:
selectors –
One or more selectors to match layers. Can be:
A single string pattern (e.g., “encoder.*attention”)
A list of string patterns
A dictionary with keys:
’pattern’: String or list of regex patterns
’type’: Layer type or list of types (e.g., ‘Linear’, ‘Conv2d’)
’contains’: String that layer name must contain
’indices’: Indices to select from matched layers (e.g., [0, 2, 4] for first, third, fifth)
’range’: Range of indices as [start, end, step]
- Returns:
List of resolved layer names that match the selectors
panther.tuner.SkAutoTuner.Configs.ParamSpec module#
First-class parameter distribution specifications for modern HPO.
Enables expressing categorical, integer, and float distributions explicitly, which can be mapped to Optuna distributions or other HPO frameworks.
- class panther.tuner.SkAutoTuner.Configs.ParamSpec.Categorical(choices)[source]#
Bases:
objectA categorical parameter that takes values from a fixed set of choices.
Examples
Categorical([1, 2, 3]) # Integer choices Categorical([“relu”, “gelu”, “silu”]) # String choices Categorical([True, False]) # Boolean choices
- choices#
- __init__(choices)#
- class panther.tuner.SkAutoTuner.Configs.ParamSpec.Int(low, high, step=1, log=False)[source]#
Bases:
objectAn integer parameter within a range [low, high].
- Parameters:
low – Lower bound (inclusive)
high – Upper bound (inclusive)
step – Step size for discrete values (default: 1)
log – Whether to sample in log scale (useful for parameters like learning rate)
Examples
Int(1, 100) # Integer from 1 to 100 Int(8, 512, step=8) # Multiples of 8 from 8 to 512 Int(1, 1000, log=True) # Log-scale integer sampling
- low#
- high#
- step = 1#
- log = False#
- __init__(low, high, step=1, log=False)#
- class panther.tuner.SkAutoTuner.Configs.ParamSpec.Float(low, high, step=None, log=False)[source]#
Bases:
objectA floating-point parameter within a range [low, high].
- Parameters:
low – Lower bound (inclusive)
high – Upper bound (inclusive)
step – Step size for discrete values (None for continuous)
log – Whether to sample in log scale
Examples
Float(0.0, 1.0) # Continuous float from 0 to 1 Float(1e-5, 1e-1, log=True) # Log-scale float (e.g., learning rate) Float(0.1, 1.0, step=0.1) # Discrete float values
- low#
- high#
- step = None#
- log = False#
- __init__(low, high, step=None, log=False)#
- panther.tuner.SkAutoTuner.Configs.ParamSpec.is_param_spec(value)[source]#
Check if a value is a ParamSpec type.
panther.tuner.SkAutoTuner.Configs.ParamsResolver module#
- class panther.tuner.SkAutoTuner.Configs.ParamsResolver.ParamsResolver(model, layer_map=None, verbose=False)[source]#
Bases:
objectA class to resolve parameters for the SkAutoTuner.
- __init__(model, layer_map=None, verbose=False)[source]#
Initialize the resolver with a model.
- Parameters:
model – The neural network model to analyze
verbose – Whether to print verbose logs
- resolve(config)[source]#
Resolves and returns the parameters.
If config.params is a dictionary, it’s returned as is, wrapped in TuningConfigs. If config.params is “auto”, it automatically determines parameters based on layer types and sizes. Otherwise, raises a ValueError.
- Returns:
The resolved parameters as TuningConfigs.
panther.tuner.SkAutoTuner.Configs.TuningConfigs module#
Module contents#
- class panther.tuner.SkAutoTuner.Configs.LayerConfig(layer_names, params, separate=True, copy_weights=True)[source]#
Bases:
objectConfiguration for a single layer or group of layers to tune.
- layer_names#
Layer selector (string, list, or dict with criteria)
- params#
Dictionary of parameter names to ParamSpec or list of values
- separate#
Whether to tune each layer independently
- copy_weights#
Whether to copy weights when replacing layers
- __init__(layer_names, params, separate=True, copy_weights=True)[source]#
Initialize a layer configuration.
- Parameters:
layer_names – Layer selector, can be: - A string: Regex pattern or substring - A list of strings: Multiple patterns or exact names - A dictionary with selection criteria (pattern, type, contains, indices, range)
params – Dictionary of parameter names and their possible values
separate – Whether to tune layers separately or jointly
copy_weights – Whether to copy weights when replacing layers
- class panther.tuner.SkAutoTuner.Configs.TuningConfigs(configs)[source]#
Bases:
objectCollection of LayerConfig objects for tuning multiple layer groups.
- class panther.tuner.SkAutoTuner.Configs.LayerNameResolver(model, layer_map=None)[source]#
Bases:
objectProvides intuitive ways to select layers for tuning in large models.
This resolver allows users to specify layers using patterns, types, or indices rather than requiring exact layer names.
- __init__(model, layer_map=None)[source]#
Initialize the resolver with a model.
- Parameters:
model – The neural network model to analyze
- resolve(selectors)[source]#
Resolve layer name selectors to actual layer names in the model.
- Parameters:
selectors –
One or more selectors to match layers. Can be:
A single string pattern (e.g., “encoder.*attention”)
A list of string patterns
A dictionary with keys:
’pattern’: String or list of regex patterns
’type’: Layer type or list of types (e.g., ‘Linear’, ‘Conv2d’)
’contains’: String that layer name must contain
’indices’: Indices to select from matched layers (e.g., [0, 2, 4] for first, third, fifth)
’range’: Range of indices as [start, end, step]
- Returns:
List of resolved layer names that match the selectors
- class panther.tuner.SkAutoTuner.Configs.ParamsResolver(model, layer_map=None, verbose=False)[source]#
Bases:
objectA class to resolve parameters for the SkAutoTuner.
- __init__(model, layer_map=None, verbose=False)[source]#
Initialize the resolver with a model.
- Parameters:
model – The neural network model to analyze
verbose – Whether to print verbose logs
- resolve(config)[source]#
Resolves and returns the parameters.
If config.params is a dictionary, it’s returned as is, wrapped in TuningConfigs. If config.params is “auto”, it automatically determines parameters based on layer types and sizes. Otherwise, raises a ValueError.
- Returns:
The resolved parameters as TuningConfigs.
- class panther.tuner.SkAutoTuner.Configs.Categorical(choices)[source]#
Bases:
objectA categorical parameter that takes values from a fixed set of choices.
Examples
Categorical([1, 2, 3]) # Integer choices Categorical([“relu”, “gelu”, “silu”]) # String choices Categorical([True, False]) # Boolean choices
- choices#
- __init__(choices)#
- class panther.tuner.SkAutoTuner.Configs.Int(low, high, step=1, log=False)[source]#
Bases:
objectAn integer parameter within a range [low, high].
- Parameters:
low – Lower bound (inclusive)
high – Upper bound (inclusive)
step – Step size for discrete values (default: 1)
log – Whether to sample in log scale (useful for parameters like learning rate)
Examples
Int(1, 100) # Integer from 1 to 100 Int(8, 512, step=8) # Multiples of 8 from 8 to 512 Int(1, 1000, log=True) # Log-scale integer sampling
- low#
- high#
- step = 1#
- log = False#
- __init__(low, high, step=1, log=False)#
- class panther.tuner.SkAutoTuner.Configs.Float(low, high, step=None, log=False)[source]#
Bases:
objectA floating-point parameter within a range [low, high].
- Parameters:
low – Lower bound (inclusive)
high – Upper bound (inclusive)
step – Step size for discrete values (None for continuous)
log – Whether to sample in log scale
Examples
Float(0.0, 1.0) # Continuous float from 0 to 1 Float(1e-5, 1e-1, log=True) # Log-scale float (e.g., learning rate) Float(0.1, 1.0, step=0.1) # Discrete float values
- low#
- high#
- step = None#
- log = False#
- __init__(low, high, step=None, log=False)#