fix(utils): make external plugins importable in spawned workers - #10126
Open
Excelius-Wang wants to merge 2 commits into
Open
Excelius-Wang wants to merge 2 commits into
Excelius-Wang wants to merge 2 commits into
Conversation
Signed-off-by: zhao.wang <57819425+Excelius-Wang@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR type
PR information
Fix a regression from #9953: custom templates loaded through
--external_pluginsfail withModuleNotFoundError: _swift_external_...when a spawn/forkserver DataLoader unpickles them. The worker-init replay added in #10033 runs after this failure.Import plugins through a private namespace whose module names encode their absolute paths. A small standard-library import finder resolves those names in fresh workers;
importlibhandles caching and failed-import cleanup. This preserves same-filename isolation and retains the old hashed names as aliases for existing pickles after explicit plugin import. Legacy package descendants resolve to the same canonical modules, including nested and delayed imports.Experiment results
SwiftSftruns comparing pre-regression spawn with patched spawn/forkserver. Per-source losses and trained model-weight hashes match exactly.git diff --checkalso pass.Tested on Linux/Python 3.12 with explicit start methods; no native Windows/Python 3.14 or GPU validation claimed. The unrelated existing streaming routing-tag lambda serialization issue is outside this fix.