nvflare.tool.agent.frameworks.pytorch module
PyTorch framework detector.
- class PyTorchDetector[source]
Bases:
FrameworkDetector- evidence_weights: dict[str, int] = {'import': 1, 'pytorch_call': 2, 'pytorch_class': 3}
Evidence-kind -> ranking weight contributed by this framework.
- import_roots: dict[str, str] = {'torch': 'pytorch', 'torchaudio': 'pytorch', 'torchvision': 'pytorch'}
Top-level import module names that map to this framework’s evidence bucket, e.g.
{"torch": "pytorch"}. Used for ranked import evidence.
- is_active_evidence(evidence: dict) bool[source]
Whether an evidence item counts as active (in-use) for this framework.
Used by family disambiguation to distinguish active use from an incidental import. Defaults to non-import evidence.
- name: str = 'pytorch'
Canonical framework name reported in inspector output (e.g.
"pytorch").
- new_file_state() _PyTorchFileState[source]
Return fresh per-file scratch state (import aliases, symbols).
- on_call(call_name: str, lineno: int | None, file_state: _PyTorchFileState, ctx: DetectContext) None[source]
Handle a called name such as
torch.optim.SGDorflare.patch.
- on_class_base(base_name: str, lineno: int | None, file_state: _PyTorchFileState, ctx: DetectContext) None[source]
Handle a base class name in a
class X(Base):definition.
- on_import(alias: alias, file_state: _PyTorchFileState, ctx: DetectContext) None[source]
Handle
import x/import x as yaliases.
- on_import_from(module: str, aliases: list, file_state: _PyTorchFileState, ctx: DetectContext) None[source]
Handle
from module import ...symbols.
- recommended_skill: str | None = 'nvflare-convert-pytorch'
Conversion skill recommended when this framework is primary, or
None.