Method adapters¶
Adapters are the stable boundary around paper-specific implementations. Their
class attributes declare feature level and encoder compatibility; inherited
methods follow the lifecycle documented by BaseMethod.
CompositeMethod
¶
Bases: BaseMethod
Adapt the configurable selector/prompt/aggregator composition model.
Source code in methods/composite/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
FOCUSMethod
¶
Bases: BaseMethod
Adapt FOCUS's single high-resolution bag and CONCH soft prompts.
Source code in methods/focus/adapter.py
interpret_step
¶
Expose FOCUS's native class-query compression attention.
Source code in methods/focus/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
ViLaMILMethod
¶
Bases: BaseMethod
Adapt ViLa-MIL's CLIP-RN50 dual-scale patch-bag workflow.
Source code in methods/vila_mil/adapter.py
interpret_step
¶
Expose ViLa-MIL's native class-to-patch context attention.
Source code in methods/vila_mil/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
CoDMILMethod
¶
Bases: BaseMethod
Adapt CoD-MIL's precomputed prompts and cross-scale correspondence.
Source code in methods/base.py
build_scheduler
¶
interpret_step
¶
Expose CoD-MIL's native predicted-class low-scale evidence.
Source code in methods/cod_mil/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
MAPLEMethod
¶
Bases: BaseMethod
Adapt MAPLE's multiscale entity prompts and graph aggregation.
Source code in methods/base.py
build_optimizer
¶
Select the explicitly declared upstream MAPLE optimizer recipe.
The NeurIPS paper specifies AdamW, while the released main.py uses
Adam. Keeping that choice in the run config makes the two upstream
recipes reproducible without conflating their results.
Source code in methods/maple/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
MSCPTMethod
¶
Bases: BaseMethod
Adapt MSCPT's paired deep text/vision prompting implementation.
Source code in methods/base.py
validation_monitor
¶
Match MSCPT's task-dependent val_best_score checkpoint.
Source code in methods/mscpt/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
PathPTMethod
¶
Bases: BaseMethod
Adapt PathPT while preserving its encoder-independent training recipe.
Source code in methods/pathpt/adapter.py
prepare_fold
¶
Select the zero-shot patch classifier from training slides only.
Source code in methods/pathpt/adapter.py
interpret_step
¶
Expose native PathPT patch-class probabilities.
Source code in methods/pathpt/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
on_epoch_end
¶
on_fold_end
¶
TOPMethod
¶
Bases: BaseMethod
Adapt TOP's two-level CLIP-RN50 prompt and pooling objective.
Source code in methods/top/adapter.py
on_train_epoch_start
¶
Start an epoch-wide optimizer-liveness probe.
One saturated slide can legitimately round an otherwise finite FP32 SGD step to zero. The released TOP loop simply proceeds to the next slide, so treating the first such step as fatal was stricter than the upstream executable. We instead require at least one representable parameter update across the complete first epoch.
Source code in methods/top/adapter.py
on_epoch_end
¶
Report an inert first epoch without overriding upstream training.
Source code in methods/top/adapter.py
interpret_step
¶
Expose TOP's native instance-prototype pooling distribution.
Source code in methods/top/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
SLIPMethod
¶
Bases: BaseMethod
Adapt SLIP's tissue-routed prompt learner for supported CLIP families.
Source code in methods/base.py
interpret_step
¶
Expose SLIP's native class-specific tissue-routing evidence.
Source code in methods/slip/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
WSIFiVEMethod
¶
Bases: BaseMethod
Adapt WSI-FiVE patch bags, questions, and answer-bank supervision.
Source code in methods/wsi_five/adapter.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
upstream_classname_mode
property
¶
Whether training uses an exact released task class-text bank.
build_optimizer
¶
Reproduce the released AdamW parameter grouping.
Upstream applies the configured learning rate to its text/other group,
10x to mit/message_/prompts parameters, and removes weight
decay from vectors, biases, and positional embeddings.
Source code in methods/wsi_five/adapter.py
build_scheduler
¶
prepare_fold
¶
Build the answer candidate bank from this training fold only.
Source code in methods/wsi_five/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
MUSEMethod
¶
Bases: BaseMethod
Adapt MUSE with independent offline patch and runtime prompt encoders.
Source code in methods/base.py
build_scheduler
¶
validation_monitor
¶
interpret_step
¶
Expose MUSE's label-free class-semantic patch routing.
Source code in methods/muse/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
ConVLMMethod
¶
Bases: BaseMethod
Run the local patch-bag, attribute-conditioned ConVLM reconstruction.
Source code in methods/base.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
SLDPCMethod
¶
Bases: BaseMethod
Adapt SLDPC's staged prompt refinement over registered slide vectors.
Source code in methods/base.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
validation_monitor
¶
Return the minimized value used for best-checkpoint selection.
The unified loop cannot assume that every released method selects its checkpoint by cross-entropy. Several paper repositories use validation error, while MSCPT uses a task-dependent F1/AUC or F1/ACC composite. Adapters override this hook to preserve that executable recipe. Values are always expressed as a minimization objective so the checkpoint writer has one unambiguous contract.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
HiVEMILMethod
¶
Bases: BaseMethod
Run native CONCH HiVE-MIL on coordinate-aligned 5x/20x features.
Source code in methods/hive_mil/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
MIVisionShotMethod
¶
Bases: BaseMethod
Native PLIP top-K support prototypes with label-free BGAP inference.
Source code in methods/mi_visionshot/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
interpret_step
¶
interpret_step(
batch: Any,
model: Module,
target_class: int | None = None,
) -> "InterpretabilityResult"
Return native, patch-aligned evidence for one evaluation slide.
Adapters must override this hook only when their score semantics and patch ordering are known. The default intentionally refuses to invent a generic "attention" map from hidden activations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Any
|
One loader batch for a single slide. |
required |
model
|
Module
|
Loaded fold checkpoint in evaluation mode. |
required |
target_class
|
int | None
|
Optional class index for class-specific evidence. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method has no audited patch-evidence mapping in PGVL-Gym. |
Source code in methods/base.py
LibraMILMethod
¶
Bases: BaseMethod
Run Libra-MIL's CONCH dual-prototype optimal-transport classifier.
Source code in methods/libra_mil/adapter.py
interpret_step
¶
Expose Libra-MIL's native multimodal SOT pooling attention.
Source code in methods/libra_mil/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
DyKoMethod
¶
Bases: BaseMethod
Run clean-room DyKo on TITAN/CONCH-v1.5 patch features.
Source code in methods/dyko/adapter.py
interpret_step
¶
Expose DyKo's native visual prompt-to-patch attention.
Source code in methods/dyko/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
MGPathMethod
¶
Bases: BaseMethod
Source code in methods/mgpath/adapter.py
interpret_step
¶
Expose MGPATH's native learned-center aggregation weights.
Source code in methods/mgpath/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.
Source code in methods/base.py
on_fold_end
¶
on_checkpoint_loaded
¶
HIPSSMethod
¶
Bases: BaseMethod
Source code in methods/hipss/adapter.py
interpret_step
¶
Expose HIPSS's native hierarchical patch contribution weights.
Source code in methods/hipss/adapter.py
get_backbone_contract
classmethod
¶
get_backbone_contract() -> MethodBackboneContract
Return the encoder/feature contract declared by the adapter.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the adapter omitted its required contract. |
Source code in methods/base.py
load_encoder
¶
load_encoder(
*,
weights_path: Optional[str] = None,
**loader_options: Any,
) -> EncoderBundle
Build and validate the configured encoder in one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights_path
|
Optional[str]
|
Optional local checkpoint or model identifier. When
omitted, |
None
|
**loader_options
|
Any
|
Family-specific options forwarded to the encoder registry, such as a pinned revision or offline-only loading. |
{}
|
Returns:
| Type | Description |
|---|---|
EncoderBundle
|
A validated capability-aware encoder bundle. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has no runtime backbone contract. |
BackboneCompatibilityError
|
If the bundle violates the method contract or declared feature provenance. |
Source code in methods/base.py
build_optimizer
¶
Build Adam over trainable parameters using the configured recipe.
Source code in methods/base.py
prepare_fold
¶
Prepare training-split-only state after model/data construction.
Methods such as PathPT use this boundary to select prompts without seeing validation or test slides. The default is deliberately a no-op.
Source code in methods/base.py
on_train_epoch_start
¶
on_epoch_end
¶
on_validation_end
¶
Handle a completed validation pass, including epoch -1.
The default forwards to the historical on_epoch_end hook. Adapters
which accumulate validation predictions therefore get a clear boundary
for the optional initial evaluation as well as every trained epoch.