Skip to content

fix: FSDP initialization for set-valued wrap class names#1187

Open
Wangxiaoxiaoa wants to merge 3 commits intoinclusionAI:mainfrom
Wangxiaoxiaoa:fix-fsdp-wrap-set
Open

fix: FSDP initialization for set-valued wrap class names#1187
Wangxiaoxiaoa wants to merge 3 commits intoinclusionAI:mainfrom
Wangxiaoxiaoa:fix-fsdp-wrap-set

Conversation

@Wangxiaoxiaoa
Copy link
Copy Markdown
Contributor

Description

Normalize FSDP transformer wrap class names before using them during
initialization.

In some cases, these names may be provided as a set rather than a list or
tuple. The previous implementation assumed the value was indexable and could
fail with:

TypeError: 'set' object is not subscriptable

This change normalizes the value before validation and wrapping logic.

Related Issue

Fixes #1186

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • ♻️ Refactoring
  • ⚡ Performance improvement
  • ✅ Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • Pre-commit hooks pass (pre-commit run --all-files)
  • Relevant tests pass; new tests added for new functionality
  • Documentation updated (if applicable; built with ./docs/build_all.sh)
  • Branch is up to date with main
  • Self-reviewed via /review-pr command
  • This PR was created by a coding agent via /create-pr
  • This PR is a breaking change

Breaking Change Details (if applicable):

N/A

Additional Context

This is a minimal compatibility fix. It does not change behavior for existing
str or list inputs.

@Wangxiaoxiaoa Wangxiaoxiaoa requested a review from rchardx as a code owner April 15, 2026 07:08
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a _normalize_wrap_class_names helper function within apply_fsdp2 to standardize the handling of transformer class names, ensuring they are consistently treated as lists regardless of whether the input is a string, None, or an iterable. The review feedback suggests an optimization for this helper function to avoid creating a shallow copy when the input is already a list, thereby reducing unnecessary allocations.

Comment thread areal/engine/fsdp_utils/__init__.py Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Wangxiaoxiaoa Wangxiaoxiaoa changed the title Fix FSDP initialization for set-valued wrap class names Fix: FSDP initialization for set-valued wrap class names Apr 16, 2026
@Wangxiaoxiaoa Wangxiaoxiaoa changed the title Fix: FSDP initialization for set-valued wrap class names fix: FSDP initialization for set-valued wrap class names Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]FSDP initialization fails when transformer layer wrap names are stored as a set

1 participant