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

[bug] Constevaluating trainable nn.Parameter #929

Open
pmarkovicTT opened this issue Dec 18, 2024 · 0 comments
Open

[bug] Constevaluating trainable nn.Parameter #929

pmarkovicTT opened this issue Dec 18, 2024 · 0 comments

Comments

@pmarkovicTT
Copy link
Contributor

Description:
Hitting KeyError: 'gradient_lora1.b.consteval_graph.output' when implementing LoRA layer with nn.Parameters.

Repro branch:
https://github.com/tenstorrent/tt-forge-fe/tree/pmarkovic/parameter-consteval-issue

pmarkovicTT added a commit that referenced this issue Dec 18, 2024
Add test to make sure LoRA layer can be implemented and used in a full
training pipeline.

Problem encountered
Hitting `KeyError: 'gradient_lora1.b.consteval_graph.output'` when
implementing LoRA layer with nn.Parameters.
```
class LoraLayer(nn.Module):
    def __init__(self, input_size, output_size, rank=8, alpha=4, dtype=torch.float32):
        super(LoraLayer, self).__init__()
        self.a = nn.Parameter(torch.empty(input_size, rank, dtype=dtype), requires_grad=True)
        self.b = nn.Parameter(torch.zeros(rank, output_size, dtype=dtype), requires_grad=True)
        self.alpha = alpha / rank

        nn.init.normal_(self.a, mean=0, std=1)

    def forward(self, x):
        return self.alpha * (x @ self.a @ self.b)
```

Raised issue: #929
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

1 participant