sampling

Classes

SparseSampleManifest

SparseSampleRecord

SparseSamplingPolicy

Functions

sample_replacement_candidates

Select at most replacement_cap layer candidates independently per width.

sample_subblock_configs

Select layer-independent teacher, single-axis, and pairwise subblocks.

class SparseSampleManifest

Bases: object

__init__(*, mode, policy, eligible, selected, excluded)
Parameters:
Return type:

None

eligible: tuple[SparseSampleRecord, ...]
excluded: tuple[SparseSampleRecord, ...]
property identity: str
mode: str
policy: SparseSamplingPolicy
selected: tuple[SparseSampleRecord, ...]
to_dict(*, include_identity=True)
Parameters:

include_identity (bool)

Return type:

dict[str, Any]

class SparseSampleRecord

Bases: object

__init__(*, sample_id, candidate_id, layer_idx, hidden_width, subblock_kind, subblock_name, changed_axes, block_config, subblock_config, no_op=False, reason='eligible')
Parameters:
  • sample_id (str)

  • candidate_id (str)

  • layer_idx (int)

  • hidden_width (int | None)

  • subblock_kind (str)

  • subblock_name (str)

  • changed_axes (tuple[str, ...])

  • block_config (dict[str, Any])

  • subblock_config (dict[str, Any] | None)

  • no_op (bool)

  • reason (str)

Return type:

None

block_config: dict[str, Any]
candidate_id: str
changed_axes: tuple[str, ...]
hidden_width: int | None
layer_idx: int
no_op: bool = False
reason: str = 'eligible'
sample_id: str
subblock_config: dict[str, Any] | None
subblock_kind: str
subblock_name: str
to_dict()
Return type:

dict[str, Any]

class SparseSamplingPolicy

Bases: object

__init__(*, max_pairwise_per_family=4, replacement_cap=50, seed=42)
Parameters:
  • max_pairwise_per_family (int)

  • replacement_cap (int)

  • seed (int)

Return type:

None

max_pairwise_per_family: int = 4
replacement_cap: int = 50
seed: int = 42
sample_replacement_candidates(candidates, *, policy=None)

Select at most replacement_cap layer candidates independently per width.

Parameters:
Return type:

SparseSampleManifest

sample_subblock_configs(candidates, *, policy=None)

Select layer-independent teacher, single-axis, and pairwise subblocks.

Parameters:
Return type:

SparseSampleManifest