Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Conditional check on accelerator_lowering availability #1631

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeffreyliu3230
Copy link

Summary: This is the first proposed approach to handle missing dependency in new_task.py by using a try block to import the functions defined in accelerator_lowering.py. This requires only changing a few lines of code in new_task.py where the functions lower_modules_to_accelerator and swap_modules_for_accelerator were called. Although swap_modules_for_accelerator doesn't require internal library, the accelerator decorator would be imported as a side effect. By wrapping it by the try block with lower_modules_to_accelerator during importing it would eliminate dependency of accelerator_lowering.py completely when not used.

Differential Revision: D26871262

Summary: This is the first proposed approach to handle missing dependency in new_task.py by using a try block to import the functions defined in accelerator_lowering.py. This requires only changing a few lines of code in new_task.py where the functions lower_modules_to_accelerator and swap_modules_for_accelerator were called. Although swap_modules_for_accelerator doesn't require internal library, the accelerator decorator would be imported as a side effect. By wrapping it by the try block with lower_modules_to_accelerator during importing it would eliminate dependency of accelerator_lowering.py completely when not used.

Differential Revision: D26871262

fbshipit-source-id: 16159de5838820b6d0dd4309b746f3e3814bb830
@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Mar 6, 2021
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D26871262

jeffreyliu3230 pushed a commit to jeffreyliu3230/pytext that referenced this pull request Mar 8, 2021
Summary:
Alternative approach to facebookresearch#1631. Handling ImportError of accelerator in accelerator_lowering.py instead of new_task.py.
accelerator function is both used as a declarator on class AcceleratorTransformerLayers and called directly in lower_modules_to_accelerator. In addition to adding the try block for importing accelerator, accelerator_lowering_supported is used in lower_modules_to_accelerator to avoid ImportError.

Differential Revision: D26885302

fbshipit-source-id: 5b938b3f4535dca9a9fbeaf6ee4c43f42ed5df3c
jeffreyliu3230 pushed a commit to jeffreyliu3230/pytext that referenced this pull request Mar 8, 2021
facebookresearch#1633)

Summary:
Pull Request resolved: facebookresearch#1633

Alternative approach to facebookresearch#1631. Handling ImportError of accelerator in accelerator_lowering.py instead of new_task.py.
accelerator function is both used as a declarator on class AcceleratorTransformerLayers and called directly in lower_modules_to_accelerator. In addition to adding the try block for importing accelerator, accelerator_lowering_supported is used in lower_modules_to_accelerator to avoid ImportError.

Differential Revision: D26885302

fbshipit-source-id: 13f8c9c23fa56db573c1ea32c582fee91a001972
jeffreyliu3230 pushed a commit to jeffreyliu3230/pytext that referenced this pull request Mar 8, 2021
facebookresearch#1633)

Summary:
Pull Request resolved: facebookresearch#1633

Alternative approach to facebookresearch#1631. Handling ImportError of accelerator in accelerator_lowering.py instead of new_task.py.
accelerator function is both used as a declarator on class AcceleratorTransformerLayers and called directly in lower_modules_to_accelerator. In addition to adding the try block for importing accelerator, accelerator_lowering_supported is used in lower_modules_to_accelerator to avoid ImportError.

Differential Revision: D26885302

fbshipit-source-id: 7540b0443678fd5ca0536aafd0a1c0402b044ec0
facebook-github-bot pushed a commit that referenced this pull request Mar 9, 2021
#1633)

Summary:
Pull Request resolved: #1633

Alternative approach to #1631. Handling ImportError of accelerator in accelerator_lowering.py instead of new_task.py.
accelerator function is both used as a declarator on class AcceleratorTransformerLayers and called directly in lower_modules_to_accelerator. In addition to adding the try block for importing accelerator, accelerator_lowering_supported is used in lower_modules_to_accelerator to avoid ImportError.

Reviewed By: mikekgfb

Differential Revision: D26885302

fbshipit-source-id: 0630494f5d44fff9869e8d88e3bb23224fe4826f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants