nirs4all.pipeline.dagml.cv_weight_transfer module
Run-scoped CV weight initialization for the closed sklearn SGD profile.
Only public coefficient/intercept arrays cross from a completed, explicitly
selected CV fold to a fresh REFIT estimator. sklearn owns fitting and resets
its optimization counter on fit. This module retains no training rows,
estimator objects, optimizer state, or cross-fold ranking implementation.
- class nirs4all.pipeline.dagml.cv_weight_transfer.CVWeightTransferStore(run_id: str, *, max_entries: int = 64, max_bytes: int = 67108864)[source]
Bases:
objectBounded run-local snapshots, consumed once and cleared by their owner.
- Parameters:
run_id – Native execution scope; another candidate/run cannot use it.
max_entries – Maximum simultaneously retained requested folds.
max_bytes – Bound on retained weights and encoded identity metadata.
- capture(request: WarmStartRequest, identity: TransferIdentity, fold_id: str, model: Any, input_contract: TransferInputContract) bool[source]
Capture only the requested completed CV fold; retain no estimator.
- prepare_refit(request: WarmStartRequest, identity: TransferIdentity, model: Any, input_contract: TransferInputContract) tuple[dict[str, ndarray], dict[str, Any]][source]
Consume an exact snapshot and return detached public fit initializers.
The caller validates actual REFIT inputs, then calls sklearn fit once. The snapshot is released before fit, including when that fit fails.
- class nirs4all.pipeline.dagml.cv_weight_transfer.TransferIdentity(run_id: str, node_id: str, controller_id: str, variant_label: str)[source]
Bases:
objectExact native owner identity; variant_label carries native variant_id.
- class nirs4all.pipeline.dagml.cv_weight_transfer.TransferInputContract(source_names: tuple[str, ...], feature_names: tuple[str, ...], target_names: tuple[str, ...], x_dtype: str, y_dtype: str)[source]
Bases:
objectOrdered, unchanged single-source and single-target representation.
- class nirs4all.pipeline.dagml.cv_weight_transfer.WarmStartRequest(fold_id: str)[source]
Bases:
objectAn opt-in request naming the one completed native CV fold to retain.
- nirs4all.pipeline.dagml.cv_weight_transfer.parse_warm_start_request(refit_params: Mapping[str, Any], *, train_params: Mapping[str, Any] | None = None) WarmStartRequest | None[source]
Validate decoded public controls without changing cold-start behavior.
- Parameters:
refit_params – Decoded per-model REFIT controls.
train_params – Decoded CV controls. Ordinary constructor warm_start is preserved without transfer; transferred CV folds must stay cold.
- Returns:
An explicit fold request, or None when weight transfer is disabled.
- nirs4all.pipeline.dagml.cv_weight_transfer.validate_sgd_profile(model: Any, *, phase: str | None = None) dict[str, Any][source]
Resolve the closed deterministic SGD capability without fitting.
The exact public estimator type is required. Budgets max_iter/tol may change at REFIT; all other effective constructor options are identity.