Commit Graph

1173 Commits

Author SHA1 Message Date
lyskov-ai
39671441e6 refactor(mypy): clear 8 easy rfd3 modules off the ignore ratchet (#298)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore metrics/metric module

Fix the 11 type errors in foundry.metrics.metric and remove it from the
[tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain).

- str(name) coercion of DictConfig.items() keys (str|bytes|int|... union)
- exists() -> 'is not None' narrowing; drop orphaned atomworks import
- widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None
  to match the actual returns / documented contract (callers already handle them)
- three type: ignore[arg-type] on nested_dict.get/getitem for an upstream
  atomworks annotation bug (param typed dict[tuple,...] but navigated as nested
  dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed

No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore utils/{ddp,rigid,datasets}

Clear the three remaining foundry.utils.* modules off the mypy ignore_errors list (47 errors: ddp 12, rigid 16, datasets 19). Type-honesty and annotation fixes only, no behavior change: narrow DictConfig|dict params to DictConfig where attribute access requires it (item access kept where a plain-dict default is real), honest int|None / Tensor|None widenings, variable renames to avoid type-reuse, str() coercion of DictConfig keys, the file's own if/elif/else narrowing pattern, and documented type: ignore / cast for genuine torch and atomworks stub limitations. Two hard-tier modules remain (callbacks/health_logging, trainers/fabric).

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore callbacks/health_logging

Clear foundry.callbacks.health_logging off the mypy ignore_errors list
by fixing its 23 type errors (annotation / type-honesty only, no
behavior change):

- import the stdlib 'types' module directly instead of relying on
  'from typing import types' (worked at runtime but fragile/untyped)
- replace 'callable'-used-as-a-type with Mapping[str, Callable[..., Any]]
  on the stat/histogram dict params and Callable[..., bool] | None on the
  filter params; annotate the two MappingProxyType default constants to
  match
- annotate the _hooks / _temp_cache / _cache instance vars
- make implicit-Optional defaults explicit (... | None) on the two
  plot_tensor_* helpers, matching their is-not-None guards
- in plot_tensor_hist, replace two type-changing param reassignments with
  equivalent always-set locals (display_values, step_labels)

Only trainers/fabric remains on the ignore list.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore trainers/fabric (ratchet complete)

Clear foundry.trainers.fabric (the last and largest module) off the
mypy ignore_errors list and remove the now-empty override block. The
ratchet ignore list is now empty: all of src/foundry + src/foundry_cli
type-checks with no per-module exemptions.

Fixes are annotation / type-honesty only, no behavior change:

- annotate self.state as dict[str, Any] (a heterogeneous, dynamically-
  keyed training-state bag, also merged with arbitrary checkpoint keys);
  this collapses ~69 union-attr/operator/arg-type errors. Also annotate
  default_state and declare _current_train_return (set by subclass
  training_step implementations).
- dataloader types: Fabric.setup_dataloaders is stub-typed to return
  DataLoader | list[DataLoader], so cast its single-loader results to
  DataLoader and change train_loop/validation_loop params from
  _FabricDataLoader to DataLoader (drop the now-unused import).
- precision: widen the param to str | int | None (the body sets it None
  when an XPU plugin takes over), cast to the guarded Literal at the
  XPUMixedPrecision call, and add one documented type: ignore[arg-type]
  where our public API is wider than Fabric's precision Literal.
- narrow the parameter-freezing guard to direct attribute access; type
  get_latest_checkpoint as Path | None (matching its returns) with a
  cast at the single caller; drop a stale type: ignore.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* chore(mypy): bring models/rfd3 into scope behind an ignore_errors ratchet

Add models/rfd3/src/rfd3 to [tool.mypy].files so the rfd3 model package
is type-checked by the standard gate (mypy now covers 99 files: foundry +
rfd3). Seed a fresh [[tool.mypy.overrides]] ignore_errors ratchet listing
the 32 rfd3 modules with pre-existing type errors (194 total), mirroring
the original src/foundry bootstrap; the 26 already-clean rfd3 modules are
type-checked immediately. Modules are cleared from the ratchet one slice
at a time in follow-up work.

Config only, no code changes. rfd3 is an editable install, so imports
resolve without an added mypy_path.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): clear 8 easy rfd3 modules off the ignore ratchet

First slice of clearing the models/rfd3 mypy ratchet: the 8 modules with
a single error each (32 -> 24 remaining on the ignore_errors list). mypy
now type-checks 34 rfd3 modules.

Annotation / type-honesty only, no behavior change:
- block_utils: -> torch.LongTensor -> torch.Tensor (.long() is stub-typed
  Tensor; sibling helpers already return Tensor)
- hbonds_hbplus: corrected calculate_hbonds's stale return annotation to
  match the actual (AtomArray, list[dict], int) return
- inference/parsing: malformed pydantic np.ndarray[np.bool_] ->
  np.ndarray[Any, np.dtype[np.bool_]]
- chunked_pairwise: assert _sm_cached is not None in the cache fast path
  (populated together with the already-narrowed _sl_cached)
- rasa: documented type: ignore[list-item] (atomworks Transform types
  requires_previous_transforms as list[str]; class refs are accepted)
- ncaa_transforms / design_metrics / testing_utils: var-annotated dicts
  (+ a missing 'from typing import Any')

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-03 16:13:41 -05:00
lyskov-ai
3ae4ee81e6 chore(mypy): bring models/rfd3 into scope behind an ignore_errors ratchet (#297)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore metrics/metric module

Fix the 11 type errors in foundry.metrics.metric and remove it from the
[tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain).

- str(name) coercion of DictConfig.items() keys (str|bytes|int|... union)
- exists() -> 'is not None' narrowing; drop orphaned atomworks import
- widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None
  to match the actual returns / documented contract (callers already handle them)
- three type: ignore[arg-type] on nested_dict.get/getitem for an upstream
  atomworks annotation bug (param typed dict[tuple,...] but navigated as nested
  dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed

No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore utils/{ddp,rigid,datasets}

Clear the three remaining foundry.utils.* modules off the mypy ignore_errors list (47 errors: ddp 12, rigid 16, datasets 19). Type-honesty and annotation fixes only, no behavior change: narrow DictConfig|dict params to DictConfig where attribute access requires it (item access kept where a plain-dict default is real), honest int|None / Tensor|None widenings, variable renames to avoid type-reuse, str() coercion of DictConfig keys, the file's own if/elif/else narrowing pattern, and documented type: ignore / cast for genuine torch and atomworks stub limitations. Two hard-tier modules remain (callbacks/health_logging, trainers/fabric).

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore callbacks/health_logging

Clear foundry.callbacks.health_logging off the mypy ignore_errors list
by fixing its 23 type errors (annotation / type-honesty only, no
behavior change):

- import the stdlib 'types' module directly instead of relying on
  'from typing import types' (worked at runtime but fragile/untyped)
- replace 'callable'-used-as-a-type with Mapping[str, Callable[..., Any]]
  on the stat/histogram dict params and Callable[..., bool] | None on the
  filter params; annotate the two MappingProxyType default constants to
  match
- annotate the _hooks / _temp_cache / _cache instance vars
- make implicit-Optional defaults explicit (... | None) on the two
  plot_tensor_* helpers, matching their is-not-None guards
- in plot_tensor_hist, replace two type-changing param reassignments with
  equivalent always-set locals (display_values, step_labels)

Only trainers/fabric remains on the ignore list.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore trainers/fabric (ratchet complete)

Clear foundry.trainers.fabric (the last and largest module) off the
mypy ignore_errors list and remove the now-empty override block. The
ratchet ignore list is now empty: all of src/foundry + src/foundry_cli
type-checks with no per-module exemptions.

Fixes are annotation / type-honesty only, no behavior change:

- annotate self.state as dict[str, Any] (a heterogeneous, dynamically-
  keyed training-state bag, also merged with arbitrary checkpoint keys);
  this collapses ~69 union-attr/operator/arg-type errors. Also annotate
  default_state and declare _current_train_return (set by subclass
  training_step implementations).
- dataloader types: Fabric.setup_dataloaders is stub-typed to return
  DataLoader | list[DataLoader], so cast its single-loader results to
  DataLoader and change train_loop/validation_loop params from
  _FabricDataLoader to DataLoader (drop the now-unused import).
- precision: widen the param to str | int | None (the body sets it None
  when an XPU plugin takes over), cast to the guarded Literal at the
  XPUMixedPrecision call, and add one documented type: ignore[arg-type]
  where our public API is wider than Fabric's precision Literal.
- narrow the parameter-freezing guard to direct attribute access; type
  get_latest_checkpoint as Path | None (matching its returns) with a
  cast at the single caller; drop a stale type: ignore.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* chore(mypy): bring models/rfd3 into scope behind an ignore_errors ratchet

Add models/rfd3/src/rfd3 to [tool.mypy].files so the rfd3 model package
is type-checked by the standard gate (mypy now covers 99 files: foundry +
rfd3). Seed a fresh [[tool.mypy.overrides]] ignore_errors ratchet listing
the 32 rfd3 modules with pre-existing type errors (194 total), mirroring
the original src/foundry bootstrap; the 26 already-clean rfd3 modules are
type-checked immediately. Modules are cleared from the ratchet one slice
at a time in follow-up work.

Config only, no code changes. rfd3 is an editable install, so imports
resolve without an added mypy_path.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-03 15:48:39 -05:00
lyskov-ai
3fdf9f4c78 refactor(mypy): un-ignore trainers/fabric (ratchet complete) (#296)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore metrics/metric module

Fix the 11 type errors in foundry.metrics.metric and remove it from the
[tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain).

- str(name) coercion of DictConfig.items() keys (str|bytes|int|... union)
- exists() -> 'is not None' narrowing; drop orphaned atomworks import
- widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None
  to match the actual returns / documented contract (callers already handle them)
- three type: ignore[arg-type] on nested_dict.get/getitem for an upstream
  atomworks annotation bug (param typed dict[tuple,...] but navigated as nested
  dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed

No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore utils/{ddp,rigid,datasets}

Clear the three remaining foundry.utils.* modules off the mypy ignore_errors list (47 errors: ddp 12, rigid 16, datasets 19). Type-honesty and annotation fixes only, no behavior change: narrow DictConfig|dict params to DictConfig where attribute access requires it (item access kept where a plain-dict default is real), honest int|None / Tensor|None widenings, variable renames to avoid type-reuse, str() coercion of DictConfig keys, the file's own if/elif/else narrowing pattern, and documented type: ignore / cast for genuine torch and atomworks stub limitations. Two hard-tier modules remain (callbacks/health_logging, trainers/fabric).

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore callbacks/health_logging

Clear foundry.callbacks.health_logging off the mypy ignore_errors list
by fixing its 23 type errors (annotation / type-honesty only, no
behavior change):

- import the stdlib 'types' module directly instead of relying on
  'from typing import types' (worked at runtime but fragile/untyped)
- replace 'callable'-used-as-a-type with Mapping[str, Callable[..., Any]]
  on the stat/histogram dict params and Callable[..., bool] | None on the
  filter params; annotate the two MappingProxyType default constants to
  match
- annotate the _hooks / _temp_cache / _cache instance vars
- make implicit-Optional defaults explicit (... | None) on the two
  plot_tensor_* helpers, matching their is-not-None guards
- in plot_tensor_hist, replace two type-changing param reassignments with
  equivalent always-set locals (display_values, step_labels)

Only trainers/fabric remains on the ignore list.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore trainers/fabric (ratchet complete)

Clear foundry.trainers.fabric (the last and largest module) off the
mypy ignore_errors list and remove the now-empty override block. The
ratchet ignore list is now empty: all of src/foundry + src/foundry_cli
type-checks with no per-module exemptions.

Fixes are annotation / type-honesty only, no behavior change:

- annotate self.state as dict[str, Any] (a heterogeneous, dynamically-
  keyed training-state bag, also merged with arbitrary checkpoint keys);
  this collapses ~69 union-attr/operator/arg-type errors. Also annotate
  default_state and declare _current_train_return (set by subclass
  training_step implementations).
- dataloader types: Fabric.setup_dataloaders is stub-typed to return
  DataLoader | list[DataLoader], so cast its single-loader results to
  DataLoader and change train_loop/validation_loop params from
  _FabricDataLoader to DataLoader (drop the now-unused import).
- precision: widen the param to str | int | None (the body sets it None
  when an XPU plugin takes over), cast to the guarded Literal at the
  XPUMixedPrecision call, and add one documented type: ignore[arg-type]
  where our public API is wider than Fabric's precision Literal.
- narrow the parameter-freezing guard to direct attribute access; type
  get_latest_checkpoint as Path | None (matching its returns) with a
  cast at the single caller; drop a stale type: ignore.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-03 15:13:37 -05:00
lyskov-ai
5200cfb363 refactor(mypy): un-ignore callbacks/health_logging (#295)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore metrics/metric module

Fix the 11 type errors in foundry.metrics.metric and remove it from the
[tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain).

- str(name) coercion of DictConfig.items() keys (str|bytes|int|... union)
- exists() -> 'is not None' narrowing; drop orphaned atomworks import
- widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None
  to match the actual returns / documented contract (callers already handle them)
- three type: ignore[arg-type] on nested_dict.get/getitem for an upstream
  atomworks annotation bug (param typed dict[tuple,...] but navigated as nested
  dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed

No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore utils/{ddp,rigid,datasets}

Clear the three remaining foundry.utils.* modules off the mypy ignore_errors list (47 errors: ddp 12, rigid 16, datasets 19). Type-honesty and annotation fixes only, no behavior change: narrow DictConfig|dict params to DictConfig where attribute access requires it (item access kept where a plain-dict default is real), honest int|None / Tensor|None widenings, variable renames to avoid type-reuse, str() coercion of DictConfig keys, the file's own if/elif/else narrowing pattern, and documented type: ignore / cast for genuine torch and atomworks stub limitations. Two hard-tier modules remain (callbacks/health_logging, trainers/fabric).

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

* refactor(mypy): un-ignore callbacks/health_logging

Clear foundry.callbacks.health_logging off the mypy ignore_errors list
by fixing its 23 type errors (annotation / type-honesty only, no
behavior change):

- import the stdlib 'types' module directly instead of relying on
  'from typing import types' (worked at runtime but fragile/untyped)
- replace 'callable'-used-as-a-type with Mapping[str, Callable[..., Any]]
  on the stat/histogram dict params and Callable[..., bool] | None on the
  filter params; annotate the two MappingProxyType default constants to
  match
- annotate the _hooks / _temp_cache / _cache instance vars
- make implicit-Optional defaults explicit (... | None) on the two
  plot_tensor_* helpers, matching their is-not-None guards
- in plot_tensor_hist, replace two type-changing param reassignments with
  equivalent always-set locals (display_values, step_labels)

Only trainers/fabric remains on the ignore list.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-03 14:54:33 -05:00
lyskov-ai
7d70c32abb refactor(mypy): un-ignore utils/{ddp,rigid,datasets} (#294)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore metrics/metric module

Fix the 11 type errors in foundry.metrics.metric and remove it from the
[tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain).

- str(name) coercion of DictConfig.items() keys (str|bytes|int|... union)
- exists() -> 'is not None' narrowing; drop orphaned atomworks import
- widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None
  to match the actual returns / documented contract (callers already handle them)
- three type: ignore[arg-type] on nested_dict.get/getitem for an upstream
  atomworks annotation bug (param typed dict[tuple,...] but navigated as nested
  dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed

No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore utils/{ddp,rigid,datasets}

Clear the three remaining foundry.utils.* modules off the mypy ignore_errors list (47 errors: ddp 12, rigid 16, datasets 19). Type-honesty and annotation fixes only, no behavior change: narrow DictConfig|dict params to DictConfig where attribute access requires it (item access kept where a plain-dict default is real), honest int|None / Tensor|None widenings, variable renames to avoid type-reuse, str() coercion of DictConfig keys, the file's own if/elif/else narrowing pattern, and documented type: ignore / cast for genuine torch and atomworks stub limitations. Two hard-tier modules remain (callbacks/health_logging, trainers/fabric).

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-03 14:12:46 -05:00
lyskov-ai
497307e81f refactor(mypy): un-ignore metrics/metric module (#288)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore metrics/metric module

Fix the 11 type errors in foundry.metrics.metric and remove it from the
[tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain).

- str(name) coercion of DictConfig.items() keys (str|bytes|int|... union)
- exists() -> 'is not None' narrowing; drop orphaned atomworks import
- widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None
  to match the actual returns / documented contract (callers already handle them)
- three type: ignore[arg-type] on nested_dict.get/getitem for an upstream
  atomworks annotation bug (param typed dict[tuple,...] but navigated as nested
  dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed

No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-03 12:00:47 -05:00
lyskov-ai
1def4e2ee2 refactor(mypy): un-ignore 7 medium-tier modules (#287)
* refactor(mypy): un-ignore 5 easy-tier modules

Fix each module's single pre-existing type error with a pure annotation
or setattr change (no behavior change) and remove it from the
[[tool.mypy.overrides]] ignore_errors list:

- callbacks/train_logging: loss_trackers: dict[str, MeanMetric]
- callbacks/metrics_logging: seen_examples: set[str]
- common: setattr(wrapper, "_has_run", True) for the @wraps wrapper
- hydra/resolvers: attribute_path: str | None (body already guards)
- inference_engines/base: base_overrides: dict[str, Any]

13 modules remain on the ignore list. mypy now type-checks the 5
newly-included modules cleanly.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* refactor(mypy): un-ignore 7 medium-tier modules

Resolve the type errors in and remove from the [[tool.mypy.overrides]]
ignore_errors list. Mostly narrowing / annotation fixes; two deliberate
type-honesty fixes flagged below.

- utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x);
  assert-narrow fallback_policy at the call site (matches get_policy idiom)
- model/layers/blocks: class-level w/b: torch.Tensor for the registered
  buffers (avoids nn.Module's Tensor | Module __getattr__ fallback)
- utils/components: is-None narrowing + tip_names local in get_name_mask's
  TIP branch (exists() can't narrow for mypy); drop orphaned exists import
- utils/logging: str(field) for the tree key; assign to a new hparams local
  rather than reassigning the typed cfg param
- foundry_cli/download_checkpoints: guard on `hasher is not None`;
  total_size = 0.0 for the float accumulation
- training/schedulers: SchedulerConfig.scheduler is now a required field
  (was = None, but documented required and assumed non-None everywhere)
- utils/xpu/xpu_accelerator: name @property -> @staticmethod to match
  lightning's Accelerator ABC

6 hard-tier modules remain on the ignore list.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
2026-06-03 11:49:53 -05:00
lyskov-ai
d8b0be6015 fix: make weighted_rigid_align dtype-agnostic (accept float64) (#286)
* test: bootstrap mypy + pytest + coverage CI gates

Wire up the tooling the upcoming test/annotation/refactor work depends on:

- Add mypy>=1.13 to [dev] and a lenient [tool.mypy] config scoped to
  src/foundry + src/foundry_cli (ignore_missing_imports, no
  disallow_untyped_defs). The 14 modules with pre-existing type errors
  are pinned via [[tool.mypy.overrides]] ignore_errors=true and listed
  as the ratchet target — fix and remove, never add.
- Add [tool.pytest.ini_options] (testpaths=["tests"], --strict-markers
  --strict-config) and [tool.coverage.*] (source = src/foundry +
  src/foundry_cli, branch = true) for opt-in gap finding.
- Add .github/workflows/test.yaml with mypy and pytest jobs running on
  the same triggers as lint_production.yaml. Top-level tests/ only;
  per-model tests under models/*/tests/ may require GPU and checkpoints
  and stay out of CI for now.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* test(mypy): extend ignore list with 4 modules CI surfaced

Local sanity-check ran mypy without foundry installed, so torch /
lightning resolved to `Any` and errors that depend on knowing those
types stayed invisible. First CI run installed the full deps and
surfaced 6 errors in 4 additional modules:

  foundry.model.layers.blocks
  foundry.training.schedulers
  foundry.utils.logging
  foundry.utils.xpu.xpu_accelerator

Same ratchet contract as the original 14: do not add, only remove
(after fixing the errors and removing `ignore_errors = true`).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* style: ruff format 2 pre-existing files unrelated to bootstrap

These files have been failing `ruff format --check` on production HEAD
(merged via #275 and #281 without a pre-commit run). They block the
existing `lint_production` workflow on every PR, including this
bootstrap. Strictly out of scope for 0001 — kept in a separate commit
so it can be cherry-picked or reverted cleanly.

  models/rfd3/src/rfd3/inference/input_parsing.py
  models/rfd3/tests/test_partial_diffusion.py

No semantic changes — `ruff format` output only.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* ci: run test workflow on all pull requests

Drop the base-branch filter on the pull_request trigger so PRs targeting
stacked task branches are gated too, not only PRs into the mainline branches.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* test: unit tests for foundry geometry utils (alignment, rotation augmentation)

Pin the numeric behaviour of weighted_rigid_align/get_rmsd and the
rotation/centre/augment helpers used across the diffusion models:
exact recovery of known rigid transforms, mask/weight exclusion from
the fit, proper-rotation invariants, global-centroid centring, and
distance-preserving augmentation. CPU-only, float32, 18 tests.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* fix: make weighted_rigid_align dtype-agnostic (accept float64)

The determinant-correction matrix F was built with torch.eye's default
dtype (float32), so float64 coordinate inputs raised at U @ F @ V. Pass
dtype=X_L.dtype so F follows the input. Add a float64 regression test.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* Add test for float64 coords with float32 weights

Add test for float64 coordinates with float32 weights to ensure correct output dtype and alignment.

* Add additional blank line before functions

Fix formatting by adding blank line before functions in test_alignment

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-02 16:45:33 -05:00
lyskov-ai
2d66d998ce test: unit tests for foundry geometry utils (alignment, rotation augmentation) (#285)
* test: bootstrap mypy + pytest + coverage CI gates

Wire up the tooling the upcoming test/annotation/refactor work depends on:

- Add mypy>=1.13 to [dev] and a lenient [tool.mypy] config scoped to
  src/foundry + src/foundry_cli (ignore_missing_imports, no
  disallow_untyped_defs). The 14 modules with pre-existing type errors
  are pinned via [[tool.mypy.overrides]] ignore_errors=true and listed
  as the ratchet target — fix and remove, never add.
- Add [tool.pytest.ini_options] (testpaths=["tests"], --strict-markers
  --strict-config) and [tool.coverage.*] (source = src/foundry +
  src/foundry_cli, branch = true) for opt-in gap finding.
- Add .github/workflows/test.yaml with mypy and pytest jobs running on
  the same triggers as lint_production.yaml. Top-level tests/ only;
  per-model tests under models/*/tests/ may require GPU and checkpoints
  and stay out of CI for now.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* test(mypy): extend ignore list with 4 modules CI surfaced

Local sanity-check ran mypy without foundry installed, so torch /
lightning resolved to `Any` and errors that depend on knowing those
types stayed invisible. First CI run installed the full deps and
surfaced 6 errors in 4 additional modules:

  foundry.model.layers.blocks
  foundry.training.schedulers
  foundry.utils.logging
  foundry.utils.xpu.xpu_accelerator

Same ratchet contract as the original 14: do not add, only remove
(after fixing the errors and removing `ignore_errors = true`).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* style: ruff format 2 pre-existing files unrelated to bootstrap

These files have been failing `ruff format --check` on production HEAD
(merged via #275 and #281 without a pre-commit run). They block the
existing `lint_production` workflow on every PR, including this
bootstrap. Strictly out of scope for 0001 — kept in a separate commit
so it can be cherry-picked or reverted cleanly.

  models/rfd3/src/rfd3/inference/input_parsing.py
  models/rfd3/tests/test_partial_diffusion.py

No semantic changes — `ruff format` output only.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* ci: run test workflow on all pull requests

Drop the base-branch filter on the pull_request trigger so PRs targeting
stacked task branches are gated too, not only PRs into the mainline branches.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* test: unit tests for foundry geometry utils (alignment, rotation augmentation)

Pin the numeric behaviour of weighted_rigid_align/get_rmsd and the
rotation/centre/augment helpers used across the diffusion models:
exact recovery of known rigid transforms, mask/weight exclusion from
the fit, proper-rotation invariants, global-centroid centring, and
distance-preserving augmentation. CPU-only, float32, 18 tests.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Hope Woods <hope.woods@omsf.io>
2026-06-02 15:26:39 -05:00
lyskov-ai
b69bed5e4c test: bootstrap mypy + pytest + coverage CI gates (#284)
* test: bootstrap mypy + pytest + coverage CI gates

Wire up the tooling the upcoming test/annotation/refactor work depends on:

- Add mypy>=1.13 to [dev] and a lenient [tool.mypy] config scoped to
  src/foundry + src/foundry_cli (ignore_missing_imports, no
  disallow_untyped_defs). The 14 modules with pre-existing type errors
  are pinned via [[tool.mypy.overrides]] ignore_errors=true and listed
  as the ratchet target — fix and remove, never add.
- Add [tool.pytest.ini_options] (testpaths=["tests"], --strict-markers
  --strict-config) and [tool.coverage.*] (source = src/foundry +
  src/foundry_cli, branch = true) for opt-in gap finding.
- Add .github/workflows/test.yaml with mypy and pytest jobs running on
  the same triggers as lint_production.yaml. Top-level tests/ only;
  per-model tests under models/*/tests/ may require GPU and checkpoints
  and stay out of CI for now.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* test(mypy): extend ignore list with 4 modules CI surfaced

Local sanity-check ran mypy without foundry installed, so torch /
lightning resolved to `Any` and errors that depend on knowing those
types stayed invisible. First CI run installed the full deps and
surfaced 6 errors in 4 additional modules:

  foundry.model.layers.blocks
  foundry.training.schedulers
  foundry.utils.logging
  foundry.utils.xpu.xpu_accelerator

Same ratchet contract as the original 14: do not add, only remove
(after fixing the errors and removing `ignore_errors = true`).

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* style: ruff format 2 pre-existing files unrelated to bootstrap

These files have been failing `ruff format --check` on production HEAD
(merged via #275 and #281 without a pre-commit run). They block the
existing `lint_production` workflow on every PR, including this
bootstrap. Strictly out of scope for 0001 — kept in a separate commit
so it can be cherry-picked or reverted cleanly.

  models/rfd3/src/rfd3/inference/input_parsing.py
  models/rfd3/tests/test_partial_diffusion.py

No semantic changes — `ruff format` output only.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* ci: run test workflow on all pull requests

Drop the base-branch filter on the pull_request trigger so PRs targeting
stacked task branches are gated too, not only PRs into the mainline branches.

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>

* Update test.yaml to remove pull_request_target

Removed pull_request_target event from workflow.

---------

Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Co-authored-by: Sergey Lyskov <3302736+lyskov@users.noreply.github.com>
2026-06-02 13:51:28 -05:00
Jonathan Funk
cd4d94fb0c Issue with ORI token in partial diffusion (#275)
fix(rfd3): respect ori_token and center on diffused-region COM in partial diffusion

`_set_origin` for partial diffusion previously hard-coded `ori_token=None`
and `infer_ori_strategy="com"`, with two consequences:

1. The user-supplied `ori_token` (and `infer_ori_strategy`) was silently
   dropped. Documented behavior is that the diffused-region COM ends up
   within ~5 A of the user's ORI token, but in partial diffusion mode any
   value passed by the caller had no effect on the output coordinates.

2. The default centering used the COM of the entire input (motif +
   diffused region) instead of the diffused-region COM. The training
   pipeline uses `center_option=diffuse` (see
   `configs/datasets/design_base.yaml`), so the model expects the
   diffused region's COM at the origin. Joint-COM centering puts the
   diffused region far from origin in a frame the model never saw at
   training, which biases denoising to drag the diffused region toward
   the motif COM. On asymmetric systems (large target, small binder),
   the binder visibly drifts toward the target with increasing
   `partial_t` -- consistent with the "binder winds around target"
   reports.

This change updates partial-diffusion centering to:
  1. Skip centering for symmetric structures (unchanged).
  2. Honor user-supplied `ori_token` / `infer_ori_strategy` if provided.
  3. Otherwise center on the diffused-region COM (matches training).

Empirical verification on a CD3E binder showed the inward pull at
partial_t=15 dropped from -4.46 A (joint-COM centering) to -0.46 A
(diffused-COM centering). On a thelma enzyme run, supplying
`ori_token=[50,0,0]` now shifts the output frame by -50 A in x as
expected (was 0 A before), while fixed-atom RMSD stays at machine
precision (~0.02 A Kabsch).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 20:19:43 -07:00
Raktim Mitra
07e9ace471 Fix: stop dropping nucleic acid residues in partial diffusion (#281)
* stop dropping nucleic acid residues in partial diffusion

* stop dropping nucleic acids in partial diffusion rfd3na

* ruff format

* Update input_parsing.py ruff format
2026-05-23 14:25:13 +02:00
Rafael Brent
cee116dc55 fix: infer ori edge case (#273)
* fix: correct bug when inferring ori from hotspots that occurs when the original hotspot COM is near (0,0,0)

* fix:rafi hotspot fix for inference.py for rfd3na

---------

Co-authored-by: Rafi Brent <rafi.brent@gmail.com>
Co-authored-by: Raktim Mitra <timkartar7879@gmail.com>
2026-04-23 13:31:16 -07:00
Raktim Mitra
2e3f2edde2 rfd3na (#269)
* rfd3na

* ruff check fix

* ruff format

* handle P suffix from fonudry components update

* simplify p suffix handling and fix demo.json (was brokem in foundry due to ligand chain allow issue)

* clean; remove extraneous files

* main doc cleanup; training fix

* rnasep png

* add white background to png

* try jpg as png getting cropped

* atom23 gif

* Update README.md

* foundry install

* no background multipolymer

* Update README.md

* ruff format

---------

Co-authored-by: Raktim Mitra <raktim@localhost>
Co-authored-by: Rohith Krishna <rohith@localhost>
Co-authored-by: Raktim Mitra <raktim@digs>
Co-authored-by: Raktim Mitra <raktim@digs.ipd.uw.edu>
2026-04-16 09:52:02 -07:00
Rachel Clune
b071919caa Docs rfd3 instsallation tutorial (#262)
* Adding the RFD3 installation guide from the Tutorial Hackathon

* Update RFdiffusion3_installation_tutorial.md

Edits based on communications with the original author (Florian) along with minor corrections and formatting changes.
2026-04-08 08:26:11 -07:00
Rachel Clune
4e3feffc12 Docs add analytics (#264)
* Adding Google Analytics to the Foundry documentation

The analytics are under Rachel Clune's OSMF account and will only be used for reporting to the Rosetta Commons Board

* Add simple analytics tracking to the foundry docs

Simple analytics does not collect any personal information.
The page view information will only be used for reporting to the Rosetta board and prioritizing future work.
2026-04-07 10:15:21 -07:00
Jasper Butcher
7dd7b31a0a Improve PTM bond handling in RFdiffusion3 (#256)
* Improve PTM bond handling in RFdiffusion3 input parsing

Replace the old _restore_bonds_for_nonstandard_residues approach with a
more robust bond restoration system that properly handles unindexed
components, backbone-like bonds for non-standard residues (PTMs), and
cross-residue bond preservation from source structures. Adds the legacy
counterpart and regression tests for both code paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Apply ruff formatting to PTM bond handling files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Remove is_motif_atom guards from legacy input parsing

The bare is_motif_atom annotation is being abolished; remove the
guards that were adding it when missing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Gate bond restoration behind nonstandard-residue check

Only run _restore_component_bonds, _add_backbone_bonds_for_nonstandard_residues,
and _sort_bonds when the source structure actually has backbone connections
to nonstandard residues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 22:11:59 -07:00
Jasper Butcher
b5395e43a8 Fix ligand res_id offset to match AF3 convention (#261)
* Fix ligand res_id offset to match AF3 output convention

RFD3 was offsetting ligand res_id values from the protein max, causing
(chain_id, res_id, atom_name) pairing to fail against AF3 predictions
which always start ligand res_id at 1. Replace the offset with dense
rank-based per-chain renumbering (1, 2, ...) and add a chain A
validation with an override option (allow_ligand_on_chain_a).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Generalize chain validation to all existing chains

Rename allow_ligand_on_chain_a → allow_ligand_on_existing_chain and
check against all chains already present in the built atom array,
not just chain A.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Error on multiple ligands per chain; preserve gaps in override mode

When allow_ligand_on_existing_chain is False, raise an error if
multiple ligand residues share the same chain. Reset res_id min to 1
per chain, preserving relative gaps when ligands share a chain
(override mode).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Use legacy res_id offset when allow_ligand_on_existing_chain is True

The override path now matches the old behaviour (offset from protein
max res_id). The default path (separate chains) sets each ligand
chain's res_id to 1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Note in errors that override restores old behaviour

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 21:49:41 -07:00
Rachel Clune
dacd4894ec Docs: Creating a contribution guide for Foundry (#215)
I created a contribution guide for foundry that is meant to live both in the main directory and in the external documentation. Since this file lives outside of the `docs` folder but I still wanted it in the external documentation, the `contributing_link.rst` file is necessary.  The content in the guide is based on the Atomworks contribution guide and some of the information provided in the Foundry README. Since this is mean to be rendered both on GitHub and Sphinx, I had to suppress Sphinx's `xref_missing` warnings because while these references are hidden in the Sphinx-built docs, they are visible in the GitHub rendered docs.

While creating this file I realized that a docs_requirements.txt file needed to be created so that contributors could easily make the necessary docs environment to run Sphinx.
2026-04-04 18:43:12 -07:00
Jasper Butcher
54a8d721c1 Expose n_recycle as inference sampler parameter (#259)
* Expose n_recycle as inference sampler parameter and improve docs

The n_recycle parameter was previously hardcoded in the diffusion module
config and not overridable at inference time. This exposes it through the
inference sampler so users can control recycling iterations via CLI
(e.g. inference_sampler.n_recycle=3). Also adds num_timesteps and
n_recycle to the "Other CLI Options" docs section, and makes the
InputSpecification reference more prominent in the README.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-04 16:37:44 -07:00
Jasper Butcher
9fa9ba2f27 Add MPS (Apple Silicon) support for RFD3, RF3, and ProteinMPNN (#260)
Adds support for running inference on Apple Silicon MPS devices.

Key changes:
- Handle bfloat16 -> float32 fallback on MPS (bfloat16 unsupported)
- Add scatter_mean utility with MPS fallback (index_reduce unsupported)
- Guard masked_scatter_/boolean indexing in block_utils with MPS paths
- Use expand (zero-copy) on CUDA/CPU, repeat (contiguous) on MPS for
  torch.where compatibility
- Add .contiguous() calls for scatter/gather ops that require it on MPS
- Replace hardcoded "cuda" in autocast dtype queries with device_of()
- Store torch.linalg.det result before torch.sign to avoid MPS in-place
  op issues on autograd graph leaves
- Auto-detect MPS accelerator and enforce float32 precision
- Add MPS installation instructions to README

Based on work by @fnachon in PR #257 with additional fixes:
- expand/repeat if-else to avoid O(L^2) allocation on non-MPS backends
- ruff 0.8.3 formatting to pass CI lint checks

Co-Authored-By: fnachon

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:36:44 -07:00
kaistroh
2b938016f4 Optimize attention computation with local window bias (#254)
Refactor attention mechanism to compute pair bias within local windows, avoiding large tensor operations.
2026-04-04 15:04:27 -07:00
Jane
c5a9fbefde Fix broken PPI tutorial link in RFdiffusion3 README (#252)
The tutorial URL was missing the tutorials/ subdirectory. Updated to point to the correct path at models/rfd3/tutorials/ppi_design_tutorial.html
2026-03-26 10:08:05 -07:00
Rachel Clune
257d20ca88 Docs: Intermediate enzyme design tutorial (#250)
* Uploading and editing the first enzyme design tutorial from the Tutorial Hackathon

This tutorial was written by Johannes and Florian and is meant to be an intermediate enzyme design tutorial.

* Updated draft of Intermediate Enzyme Design Tutorial

* Added explanations for the fixed atom and unfixed motif constraints
* Added more detail about the metrics to quickly determine if a design is 'good'

* Adding example input and output files

- Removal of 1mg5.cif and 1mg5_motif.pdb.cif as they are not necessary for the tutorial.
- Creation of an `outputs.zip` that contains example output files for this tutorial
- Edits to the tutorial document to point to these files.

* Updated description of catalytic structure

Updated the description of the catalytic structure to better cite the literature.
2026-03-24 13:37:21 -07:00
Rachel Clune
a94de86df9 Revert "Adding Google Analytics to the Foundry documentation" (#244)
Revert "Adding Google Analytics to the Foundry documentation (#243)"

This reverts commit d746dc56a3.
2026-03-19 09:02:39 -07:00
Rachel Clune
d746dc56a3 Adding Google Analytics to the Foundry documentation (#243)
The analytics are under Rachel Clune's OSMF account and will only be used for reporting to the Rosetta Commons Board
2026-03-18 19:07:18 -07:00
Rachel Clune
6ab4add581 Fixed broken links in tutorials (#242) 2026-03-12 19:50:52 -07:00
Rachel Clune
146c2be7ac Creation of a NA binder tutorial (#232)
* Docs: Installation FAQ space and minor RFD3 docs updates

Installation FAQ: created a document to specify any common installation issues and questions. Should be continuously updated based on logged issues and questions. Not specific to any model.

RFD3:
- changed the checkpoint files specified in the examples to rfd3_latest.ckpt
- updated information in input.md to clarify information based on recent issues that had been submitted

* Docs: Symlinks for RF3 and MPNN docs, RFD3 README minor edits

RF3 and MPNN: folders, index files, and symlinks were created in order to provide space for eventual RF3 and MPNN docs.

Several small changes in the RFD3 README to improve readability and  add a pointer to the PPI tutorial as a starting point for someone new to RFdiffusion tools.

* First draft of enzyme design tutorial. Minor typo fixes in other documents.

* First draft of nucleic acid binder tutorial, minor edits to the other tutorials

* Completed enzyme design tutorial, removal of NA binder tutorial from index

Made changes based on edits from Saman, added images, and created zip file containing sample outputs for an enzyme design tutorial.

I am waiting on edits for the NA binder design tutorial, so for now I have removed it from the documentation index.

* First drafts of content for NA binder design tutorial

This tutorial is being created in collaboration with Raktim Mitra.

* Adding images to NA binder design tutorial

* Final draft of NA binder tutorial

* Create unfix.zip

* Updated images for na binder tutorial
2026-03-12 19:36:36 -07:00
Nathaniel Corley
4686f7300c fix: reference conformers (#235) 2026-03-06 12:56:10 -08:00
David Hyunyoo Jang
75986084a6 fix: restore python version constraint (==3.12) (#227)
* fix: restore exact python version constraint (==3.12)

Commit 49187c3 unintentionally reverted requires-python from ==3.12
back to >=3.12 as a side-effect of the inference fix. This restores
the exact version constraint originally introduced in 8aeacba.

* fix: relax python version constraint to allow 3.12.x

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-03 07:49:50 -08:00
Rachel Clune
38d0989cb7 Docs: RF3 README update and moving RF3 examples (#216)
* RF3 README update and moving RF3 examples

I updated the RF3 README for installation instructions that matched the RFD3 installation instructions. For the first example, I improve the instructions for running and fixed the output file descriptions to match what is now output by running the example. I commented out the 'Templating a Small Molecule' section because many of the files in that section were not present in the repository. The rest of the changes were mostly typo fixes.

 I moved the examples from `foundry/docs/releases` to `foundry/models/rf3/docs` to match the organization of RFD3. The changes made to the JSON files just reflect this change of location.

* Changed paths in example JSON files to point to new RF3 examples location

* Updated the landing page for the RF3 documentation so that it links out to the README
2026-02-27 15:35:02 -08:00
Rachel Clune
2f905c59b4 Delete models/rfd3/docs/enzyme_tutorial_files directory
Accidentally duplicated in the last commit
2026-02-25 21:29:58 -08:00
Aiko
290b2fd0bb fix: weight initialization bug in chunked P_LL (#229)
- Also cache static projections for speedup
2026-02-25 16:29:51 -08:00
Rachel Clune
99a0cb773a Enzyme Design Tutorial (#210)
* Docs: Installation FAQ space and minor RFD3 docs updates

Installation FAQ: created a document to specify any common installation issues and questions. Should be continuously updated based on logged issues and questions. Not specific to any model.

RFD3:
- changed the checkpoint files specified in the examples to rfd3_latest.ckpt
- updated information in input.md to clarify information based on recent issues that had been submitted

* Docs: Symlinks for RF3 and MPNN docs, RFD3 README minor edits

RF3 and MPNN: folders, index files, and symlinks were created in order to provide space for eventual RF3 and MPNN docs.

Several small changes in the RFD3 README to improve readability and  add a pointer to the PPI tutorial as a starting point for someone new to RFdiffusion tools.

* First draft of enzyme design tutorial. Minor typo fixes in other documents.

* First draft of nucleic acid binder tutorial, minor edits to the other tutorials

* Completed enzyme design tutorial, removal of NA binder tutorial from index

Made changes based on edits from Saman, added images, and created zip file containing sample outputs for an enzyme design tutorial.

I am waiting on edits for the NA binder design tutorial, so for now I have removed it from the documentation index.

* Removing file related to in-progress NA binder tutorial

* Removing file related to in-progress NA binder tutorial

* Final version of the enzyme design tutorial

Made small edits, created example files.

* Resolving merge conflicts
2026-02-25 16:13:05 -08:00
David Hyunyoo Jang
9f609e8758 Docs: update repository URL in README (#226)
fix: update repository URL in README
2026-02-25 14:39:22 -08:00
Raktim Mitra
3b262b742b Update na_binder_design.md (#230)
UPdating the same minor change int the complex example in the .md file as did for the .json earlier
2026-02-25 14:34:33 -08:00
Sergey Lyskov
bb97ddfb94 Update author email for Sergey Lyskov (#228) 2026-02-25 14:33:29 -08:00
Rachel Clune
4a70f0ef93 Docs: Designability vs. Diversity (#220)
* Docs: Installation FAQ space and minor RFD3 docs updates

Installation FAQ: created a document to specify any common installation issues and questions. Should be continuously updated based on logged issues and questions. Not specific to any model.

RFD3:
- changed the checkpoint files specified in the examples to rfd3_latest.ckpt
- updated information in input.md to clarify information based on recent issues that had been submitted

* Docs: Symlinks for RF3 and MPNN docs, RFD3 README minor edits

RF3 and MPNN: folders, index files, and symlinks were created in order to provide space for eventual RF3 and MPNN docs.

Several small changes in the RFD3 README to improve readability and  add a pointer to the PPI tutorial as a starting point for someone new to RFdiffusion tools.

* First draft of enzyme design tutorial. Minor typo fixes in other documents.

* First draft of nucleic acid binder tutorial, minor edits to the other tutorials

* Completed enzyme design tutorial, removal of NA binder tutorial from index

Made changes based on edits from Saman, added images, and created zip file containing sample outputs for an enzyme design tutorial.

I am waiting on edits for the NA binder design tutorial, so for now I have removed it from the documentation index.

* Removing file related to in-progress NA binder tutorial

* Removing file related to in-progress NA binder tutorial

* Update ppi_design_tutorial.md

- Added information about useful CLI arguments
- Cleaned up the introduction
- Added section for what one might do with the designs from RFD3
- Added a note about hotspot residues also being in the `contig` (information from Rafi's TTT talk)
- Fixed minor sphinx heading issue

* Reorganizing RFD3 documentation

Reorganized files into an `examples` and a `tutorials` folders to clean up the RFD3 docs folder and align its organization with the RF3 docs folder. Any edits made in the files are related to changing the paths to reflect these changes.

* Docs: Designability vs. Diversity document

Created a document describing the settings that can impact the designability and diversity of structures output by RFdiffusion3, the information is based on the talk Rafi gave at Tech Tea Time in January.

* Minor grammar fixes in designability vs diversity document

* Update models/rfd3/docs/tutorials/ppi_design_tutorial.md

Co-authored-by: Rafael Brent <105883594+RafiBrent@users.noreply.github.com>

* Update models/rfd3/docs/tutorials/enzyme_design_tutorial.md

Co-authored-by: Rafael Brent <105883594+RafiBrent@users.noreply.github.com>

* Update models/rfd3/docs/designability_vs_diversity.md

Co-authored-by: Rafael Brent <105883594+RafiBrent@users.noreply.github.com>

* Update models/rfd3/docs/designability_vs_diversity.md

Co-authored-by: Rafael Brent <105883594+RafiBrent@users.noreply.github.com>

---------

Co-authored-by: Jasper Butcher <66851659+Ubiquinone-dot@users.noreply.github.com>
Co-authored-by: Rafael Brent <105883594+RafiBrent@users.noreply.github.com>
2026-02-24 10:50:29 -08:00
Rachel Clune
b81ccd40d8 Create Issue Templates (#197)
* Create Issue Templates

Created templates for bug reports, feature requests, and usage questions. The main goal is to encourage users to provide files and details required to understand their problem/request/question so that minimal back and forth needs to occur before a solution is reached.

* Revise issue template for clarity and detail

Updated issue template to include a request for images of expected behavior and streamlined the reproduction steps section.
2026-02-21 22:42:28 -08:00
Hope Woods
f4f3597aa8 Upload Dockerfile to examples (#222)
* Upload Dockerfile to examples

* Update Foundry README with Docker information

- There is an image for Foundry on DockerHub
- Example recipe is in `foundry/examples/docker`

---------

Co-authored-by: Rachel Clune <rachel.clune@omsf.io>
2026-02-21 22:40:06 -08:00
Raktim Mitra
3294b06cc6 Update na_binder_design.json (#223) 2026-02-19 09:14:49 -08:00
Jasper Butcher
ea05d5939b Fix ligand annotatitions (#219) 2026-02-17 14:06:42 -08:00
Raktim Mitra
4f26b2d46a fix: switch to tmpdir otherwise hb2 won't be found (#218)
Co-authored-by: Raktim Mitra <raktim@localhost>
2026-02-17 14:03:21 -08:00
Rachel Clune
b100462717 Fix chain break representation in input.md
Updated the documentation for the 'contig' field to correct the representation of chain breaks from '\0' to '/0'.
2026-02-12 09:45:38 -08:00
Rohith Krishna
a814636801 Fix Slack invitation link
Updated Slack invitation link in README.
2026-02-06 10:49:56 -08:00
Rohith Krishna
976018840d remove reliance of rooutils for pip installed case (#200)
Co-authored-by: Rohith Krishna <rohith@digs>
2026-02-04 19:04:54 -08:00
Rachel Clune
38a83a97b1 Docs: PPI tutorial updates, RF3 and MPNN docs placeholders, minor edits (#195)
* Docs: Installation FAQ space and minor RFD3 docs updates

Installation FAQ: created a document to specify any common installation issues and questions. Should be continuously updated based on logged issues and questions. Not specific to any model.

RFD3:
- changed the checkpoint files specified in the examples to rfd3_latest.ckpt
- updated information in input.md to clarify information based on recent issues that had been submitted

* Docs: Symlinks for RF3 and MPNN docs, RFD3 README minor edits

RF3 and MPNN: folders, index files, and symlinks were created in order to provide space for eventual RF3 and MPNN docs.

Several small changes in the RFD3 README to improve readability and  add a pointer to the PPI tutorial as a starting point for someone new to RFdiffusion tools.
v0.1.10
2026-02-02 15:33:04 -08:00
Rafael Brent
f682e8c801 fix: correct typo (#194)
Co-authored-by: Rafi Brent <rafi.brent@gmail.com>
2026-02-02 11:11:58 -08:00
Rafael Brent
857b6fbb51 docs: clarify is_non_loopy defaults (#193)
Co-authored-by: Rafi Brent <rafi.brent@gmail.com>
2026-02-02 10:55:23 -08:00
Aiko
c35837e279 fix: revert symmetry related code to the point that was stable (#179) 2026-01-22 23:50:54 -08:00