qbiocode.apps.quvine.reproducibility.seed_manager module#

Centralized Seed Manager for QuVINE

Ensures explicit, auditable seed usage across all experiments for reproducibility.

Summary#

Classes:

SeedManager

Manages canonical and derived random seeds for reproducible experiments.

Reference#

class SeedManager(base_seed=42)[source]#

Bases: object

Manages canonical and derived random seeds for reproducible experiments.

Canonical seed policy required for the PPI benchmark:

canonical_seed = base_seed + repetition_id

The canonical seed is intentionally independent of dataset identity so that all methods for the same repetition operate under the exact same top-level seed policy. Component/task-specific seeds are derived from the canonical seed via fixed offsets to avoid untracked randomness.

COMPONENT_OFFSETS = {'connector_repair': 12, 'dataloader_shuffling': 500, 'filler_node_selection': 11, 'graph_generation': 0, 'link_prediction': 300, 'link_prediction_edge_split': 301, 'model_initialization': 400, 'negative_edge_sampling': 302, 'node_classification': 200, 'node_classification_split': 201, 'node_ranking': 100, 'node_ranking_target_selection': 101, 'ppi_subsampling': 10}#
TASK_TO_COMPONENT = {'link_prediction': 'link_prediction', 'node_classification': 'node_classification', 'node_ranking': 'node_ranking'}#
TASK_TO_SPLIT_COMPONENT = {'link_prediction': 'link_prediction_edge_split', 'node_classification': 'node_classification_split', 'node_ranking': 'node_ranking'}#
__init__(base_seed=42)[source]#

Initialize seed manager.

Parameters:

base_seed (int) – Global base seed for all experiments

get_seed(dataset_name, repetition_id)[source]#

Get canonical seed for a dataset and repetition.

Parameters:
  • dataset_name (str) – Dataset name (retained for API compatibility and auditing)

  • repetition_id (int) – Repetition index (0-based)

Returns:

Canonical seed for this repetition

Return type:

int

get_component_seed(dataset_name, repetition_id, component, extra_offset=0)[source]#

Get a deterministic seed for a specific pipeline component.

Parameters:
  • dataset_name (str) – Dataset name

  • repetition_id (int) – Repetition index

  • component (str) – Named component from COMPONENT_OFFSETS

  • extra_offset (int) – Additional explicit offset for sub-operations

Returns:

Deterministic derived seed

Return type:

int

get_task_seed(dataset_name, repetition_id, task)[source]#

Get task-specific seed derived from canonical seed.

Parameters:
  • dataset_name (str) – Dataset name

  • repetition_id (int) – Repetition index

  • task (str) – Task name

Returns:

Task-specific seed

Return type:

int

get_split_seed(dataset_name, repetition_id, task)[source]#

Get the seed used to draw the train/val/test split for a task.

This is the component SplitGenerator uses when generating the split (e.g. node_classification_split), which differs from the model-run task seed (get_task_seed). Use this to validate a recorded split["seed"].

Return type:

int

describe_seed_plan(dataset_name, repetition_id)[source]#

Return the full seed plan for auditing.

Return type:

Dict[str, int]

save_seed_registry(output_path)[source]#

Save current seed registry to disk for auditing.

Parameters:

output_path (Path) – Path to save seed registry JSON

Return type:

None

load_seed_registry(input_path)[source]#

Load seed registry from disk.

Parameters:

input_path (Path) – Path to seed registry JSON

Return type:

None

validate_seed_consistency(dataset_name, repetition_id, expected_seed)[source]#

Validate that computed canonical seed matches expected value.

Return type:

bool