Lightning-AI / Lightning-AI/lightning-thunder
Fused amax and scale update for TEv2
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🚀 Feature
As in TE, there is performance to be gained if we were to use fused amax and scale updates when using the delayed scaling recipe.
This could be achieved two ways, one would be to use TE's function [`tex.fused_amax_and_scale_update_after_reduction`](https://github.com/NVIDIA/TransformerEngine/blob/cae1c436027cc028ee49c83463141ba67f0adca0/transformer_engine/pytorch/fp8.py#L407-L414). The other way to achieve this would be to trace through `_amax_and_scale_update`, therefore also [`_default_get_amax_and_update_history`](https://github.com/NVIDIA/TransformerEngine/blob/cae1c436027cc028ee49c83463141ba67f0adca0/transformer_engine/pytorch/fp8.py#L675-L687) and [`_default_sf_compute`](https://github.com/NVIDIA/TransformerEngine/blob/cae1c436027cc028ee49c83463141ba67f0adca0/transformer_engine/pytorch/fp8.py#L690-L715). The second option might be challenging because of all the `torch.where` used.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading transformer_engine/pytorch/fp8.py, especially tex.fused_amax_and_scale_update_after_reduction, _amax_and_scale_update, _default_get_amax_and_update_history, and _default_sf_compute. Compare the two proposed implementation paths and determine how delayed scaling could use a fused update. Done means TEv2 uses fused amax and scale updates without changing the intended scaling behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100