Lightning-AI / Lightning-AI/lightning-thunder

Implement max_norm argument for torch.nn.functional.embedding

Open
#1,699 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement in-place operators
Dominant language
Python
Stars
1.5k
Forks
121
PR merge metrics
No merged PRs in 30d

Description

## 🚀 Feature

At the moment, the `max_norm` argument raises a NotImplementedError in Thunder:
https://github.com/Lightning-AI/lightning-thunder/blob/52ee541073ddf6dce78b77ddb272621f712e3c6a/thunder/core/prims.py#L4082-L4088

According to the [documentation](https://pytorch.org/docs/stable/generated/torch.nn.functional.embedding.html) when this argument is active the `weight` argument is modified inplace. Once we improve general support for inplace operators in Thunder we need to come back to this op and support this variant.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in thunder/core/prims.py around the NotImplementedError for embedding's max_norm argument, then read the linked PyTorch embedding documentation to confirm the in-place weight behavior. The work is done when Thunder supports this variant after general in-place operator support is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.