Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Function inlining] Add flag to enable pruning before function calls are inlined. #67707

Merged
merged 1 commit into from
May 17, 2024

Conversation

copybara-service[bot]
Copy link

[Function inlining] Add flag to enable pruning before function calls are inlined.

Currently, the behavior of lowered functional ("V2") control flow is subtly different from V1 control flow. In V1 control flow, the fetches for a Session::Run() call will determine whether or not operations within the loop will be pruned. However, in V2 control flow, pruning may not always occur for multi-device functions, because the graph is partitioned (inserting stateful Send/Recv nodes) into multiple sub-functions, before the individual sub-functions are pruned.
While this should not affect the correctness of the execution, it may cause unnecessary computations and data transfers.

To address this problem, we introduce a new flag to enable pruning when inlining function calls, including as part of control flow V2 lowering, which inlines the condition and body functions of while loops, and true and false branches of conditionals.

Set TF_FLAG_ENABLE_FUNCTION_PRUNING_BEFORE_INLINING=1 to enable this option.

@copybara-service copybara-service bot force-pushed the exported_pr_634196523 branch 6 times, most recently from 64c62bb to f374dbd Compare May 17, 2024 18:15
…are inlined.

Currently, the behavior of lowered functional ("V2") control flow is subtly different from V1 control flow. In V1 control flow, the fetches for a `Session::Run()` call will determine whether or not  operations within the loop will be pruned. However, in V2 control flow, pruning may not always occur for multi-device functions, because the graph is partitioned (inserting stateful Send/Recv nodes) into multiple sub-functions, before the individual sub-functions are pruned.
While this should not affect the correctness of the execution, it may cause unnecessary computations and data transfers.

To address this problem, we introduce a new flag to enable pruning when inlining function calls, including as part of control flow V2 lowering, which inlines the condition and body functions of while loops, and true and false branches of conditionals.

Set `TF_FLAG_ENABLE_FUNCTION_PRUNING_BEFORE_INLINING=1` to enable this option.

PiperOrigin-RevId: 634842835
@copybara-service copybara-service bot closed this May 17, 2024
@copybara-service copybara-service bot deleted the exported_pr_634196523 branch May 17, 2024 18:59
@copybara-service copybara-service bot merged commit dcb77c5 into master May 17, 2024
2 checks passed
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.

None yet

1 participant