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

Refactor LXU cache logic in TBE fwd training #1295

Closed
wants to merge 1 commit into from

Conversation

sryap
Copy link
Contributor

@sryap sryap commented Sep 10, 2022

Summary:
The LXU cache logic is in the critical path of the forward TBE kernel.
Even when the LXU cache is not used, the kernel still checks whether a
row should be fetched from the cache or HBM at runtime. The branching
logic should be harmless for the memory (subsystem) bound case.
However, it could add significant overhead if TBE is conditional
bound. (We have observed that FP16 weight type is generally compute
or conditional bound, while FP32 weight type is memory bound.)

This diff adds a static conditional in the forward TBE kernel to
enable/disable the LXU cache code path at compile time. At runtime,
the host selects the kernel with/without cache enabled based on
whether the LXU cache is present.

This diff also moves the conditional outside the D loop. It should
add a small benefit for the large D cases when cache is used.

Differential Revision: D39353035

@netlify
Copy link

netlify bot commented Sep 10, 2022

Deploy Preview for eclectic-stroopwafel-199537 canceled.

Name Link
🔨 Latest commit 9aff411
🔍 Latest deploy log https://app.netlify.com/sites/eclectic-stroopwafel-199537/deploys/631cd88f9e30fd0008360dee

@facebook-github-bot
Copy link
Contributor

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

Summary:
Pull Request resolved: pytorch#1295

The LXU cache logic is in the critical path of the forward TBE kernel.
Even when the LXU cache is not used, the kernel still checks whether a
row should be fetched from the cache or HBM at runtime.  The branching
logic should be harmless for the memory (subsystem) bound case.
However, it could add significant overhead if TBE is conditional
bound.  (We have observed that FP16 weight type is generally compute
or conditional bound, while FP32 weight type is memory bound.)

This diff adds a static conditional in the forward TBE kernel to
enable/disable the LXU cache code path at compile time.  At runtime,
the host selects the kernel with/without cache enabled based on
whether the LXU cache is present.

This diff also moves the conditional outside the D loop.  It should
add a small benefit for the large D cases when cache is used.

Reviewed By: jspark1105

Differential Revision: D39353035

fbshipit-source-id: bfd3d842971091e954e49c6c8fad034db1fcbc9b
@facebook-github-bot
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants