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

Can we only replace part of nn.Linear with te.Linear and others keep unchanged? #1595

Open
zigzagcai opened this issue Mar 20, 2025 · 5 comments

Comments

@zigzagcai
Copy link

No description provided.

@pggPL
Copy link
Collaborator

pggPL commented Mar 20, 2025

I'm not sure what you mean - if you want to run some Linear layers in fp8 and the rest in higher precision, or you want to run for example forward in fp8 and backward in high precision. Both of this scenarios will be possible when this PR will be merged (hopefully this week).

@zigzagcai
Copy link
Author

I'm not sure what you mean - if you want to run some Linear layers in fp8 and the rest in higher precision, or you want to run for example forward in fp8 and backward in high precision. Both of this scenarios will be possible when this PR will be merged (hopefully this week).

Thank you! I mean run some layers in fp8 and other's in high precision.

@ptrendx
Copy link
Member

ptrendx commented Mar 24, 2025

Yes, you can do that. You can either just leave some layers as nn.Linear or you can nest the fp8_autocast context manager, something like this:

with fp8_autocast(enabled=True):
    y = te_linear1(x)  # will compute in FP8
    with fp8_autocast(enabled=False):
        z = te_linear2(y)  # will compute in high precision

@lengerfulluse
Copy link

Both of this scenarios will be possible when this #1441 will be merged (hopefully this week).

Hi @pggPL , looks the original PR has been closed and split into 4 PRs. May i know when can we expected these changes been merged into TE?

@pggPL
Copy link
Collaborator

pggPL commented Mar 31, 2025

I want to merge them as soon as possible, there was temporal shortage of reviewers due to other deadlines with higher priority, but I hope it will be merged soon.

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

No branches or pull requests

4 participants