fix: make FSDP2 executor work with ABC+Generic model hierarchy

- Wrap each child module individually, skip root (CPython layout
  conflict between ABC+Generic and FSDP2 __class__ assignment)
- Remove manual unshard in clip_grad_norm (DTensor compatible)
- Fix _no_sync to iterate modules() instead of checking root
- Add reshard after unwrap_model
- Guard __init_subclass__ type resolution against dynamic subclasses
- Add fsdp2 to --parallel_mode CLI choices
This commit is contained in:
2026-07-23 16:11:02 +08:00
parent 4eeb23e2b3
commit 4e38183e86
3 changed files with 40 additions and 18 deletions
+4 -1
View File
@@ -67,7 +67,10 @@ class BaseFactory(ABC, Generic[T]):
if _get_origin(orig_base) is BaseFactory:
(arg,) = _get_args(orig_base)
cls._entries = {}
cls._component_base = _resolve_type(arg, cls)
try:
cls._component_base = _resolve_type(arg, cls)
except Exception:
cls._component_base = None
return
@classmethod