Skip to content

Handle nested outputs in NoParallel - #4288

Closed
sylvesterkaczmarek wants to merge 1 commit into
pytorch:mainfrom
sylvesterkaczmarek:fix/no-parallel-multi-output
Closed

Handle nested outputs in NoParallel#4288
sylvesterkaczmarek wants to merge 1 commit into
pytorch:mainfrom
sylvesterkaczmarek:fix/no-parallel-multi-output

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Fixes #3374.

Summary

NoParallel._prepare_output_fn currently assumes a module returns a single DTensor and accesses outputs.placements directly. Modules that return tuples or other nested output structures therefore fail.

This change applies the existing layout redistribution and optional to_local() conversion independently to every DTensor leaf using pytree traversal. Non-DTensor leaves are preserved unchanged.

Regression coverage

Added CPU-only coverage for nested tuple/list/dict outputs, redistribution, non-DTensor metadata, and use_local_output=True.

Validation

The branch is based directly on current upstream main at b5bcd76c66d0acb1a08b176d9639425bc55e0b2a and contains one focused commit. Full repository tests were not run locally; upstream CI should run the added unit coverage.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 22, 2026
from torch.utils._pytree import tree_map


class NoParallel(ParallelStyle):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this class will be deprecated soon

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, understood. Given that NoParallel is going to be deprecated and #3374 is now marked wontfix, I don't want to add maintenance work to a path that is being removed. I'm happy to close this PR if that's the preferred direction; otherwise I can keep the narrow compatibility fix.

@tianyu-l tianyu-l closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TensorParallel] NoParallel does not handle multi-output modules

2 participants