panther.tuner.SkAutoTuner.Configs package

Contents

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: object

Configuration 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

clone()[source]#

Create a deep copy of this LayerConfig.

Returns:

A new LayerConfig instance with the same properties

panther.tuner.SkAutoTuner.Configs.LayerNameResolver module#

class panther.tuner.SkAutoTuner.Configs.LayerNameResolver.LayerNameResolver(model, layer_map=None)[source]#

Bases: object

Provides 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: object

A 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: object

An 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: object

A 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.ParamSpec.to_categorical(value)[source]#

Convert a list to a Categorical spec.

This is useful for backward compatibility with legacy list-based param definitions.

panther.tuner.SkAutoTuner.Configs.ParamSpec.get_param_choices(spec)[source]#

Get discrete choices from a param spec, if applicable.

Returns:

List of choices for Categorical, None for continuous Int/Float ranges.

panther.tuner.SkAutoTuner.Configs.ParamsResolver module#

class panther.tuner.SkAutoTuner.Configs.ParamsResolver.ParamsResolver(model, layer_map=None, verbose=False)[source]#

Bases: object

A 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#

class panther.tuner.SkAutoTuner.Configs.TuningConfigs.TuningConfigs(configs)[source]#

Bases: object

Collection of LayerConfig objects for tuning multiple layer groups.

__init__(configs)[source]#

Initialize with a list of layer configurations.

Parameters:

configs – List of LayerConfig objects

add(config)[source]#

Add a LayerConfig, returning a new TuningConfigs.

remove(index)[source]#

Remove a LayerConfig by index, returning a new TuningConfigs.

replace(index, config)[source]#

Replace a LayerConfig at index, returning a new TuningConfigs.

clone()[source]#

Create a deep copy of this TuningConfigs.

merge(other)[source]#

Merge with another TuningConfigs, returning a new TuningConfigs.

filter(predicate)[source]#

Filter configs by predicate, returning a new TuningConfigs.

map(transform)[source]#

Apply a transformation to each config, returning a new TuningConfigs.

Module contents#

class panther.tuner.SkAutoTuner.Configs.LayerConfig(layer_names, params, separate=True, copy_weights=True)[source]#

Bases: object

Configuration 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

clone()[source]#

Create a deep copy of this LayerConfig.

Returns:

A new LayerConfig instance with the same properties

class panther.tuner.SkAutoTuner.Configs.TuningConfigs(configs)[source]#

Bases: object

Collection of LayerConfig objects for tuning multiple layer groups.

__init__(configs)[source]#

Initialize with a list of layer configurations.

Parameters:

configs – List of LayerConfig objects

add(config)[source]#

Add a LayerConfig, returning a new TuningConfigs.

remove(index)[source]#

Remove a LayerConfig by index, returning a new TuningConfigs.

replace(index, config)[source]#

Replace a LayerConfig at index, returning a new TuningConfigs.

clone()[source]#

Create a deep copy of this TuningConfigs.

merge(other)[source]#

Merge with another TuningConfigs, returning a new TuningConfigs.

filter(predicate)[source]#

Filter configs by predicate, returning a new TuningConfigs.

map(transform)[source]#

Apply a transformation to each config, returning a new TuningConfigs.

class panther.tuner.SkAutoTuner.Configs.LayerNameResolver(model, layer_map=None)[source]#

Bases: object

Provides 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: object

A 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: object

A 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: object

An 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: object

A 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)#