Skip to content

fix: Fix fp8 memory fragmentation#2670

Open
ashors1 wants to merge 9 commits into
mainfrom
ashors/fix-fp8-memory
Open

fix: Fix fp8 memory fragmentation#2670
ashors1 wants to merge 9 commits into
mainfrom
ashors/fix-fp8-memory

Conversation

@ashors1
Copy link
Copy Markdown
Contributor

@ashors1 ashors1 commented Jun 2, 2026

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Issues

closes #2003

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

ZhiyuLi-Nvidia and others added 4 commits June 2, 2026 10:53
Signed-off-by: Zhiyu Li <zhiyul@NVIDIA.com>

WIP oom

Signed-off-by: Zhiyu Li <zhiyul@NVIDIA.com>

for test

Signed-off-by: Zhiyu Li <zhiyul@NVIDIA.com>

memory
Signed-off-by: Anna Shors <ashors@nvidia.com>
Signed-off-by: ashors1 <ashors@nvidia.com>
Signed-off-by: ashors1 <ashors@nvidia.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Jun 2, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

…refit

Signed-off-by: Anna Shors <ashors@nvidia.com>
@ashors1 ashors1 marked this pull request as ready for review June 5, 2026 02:53
@ashors1 ashors1 requested review from a team as code owners June 5, 2026 02:53
@ashors1 ashors1 requested a review from ZhiyuLi-Nvidia June 5, 2026 02:53
if hasattr(te, "module") and hasattr(te.module.base, "clear_workspace"):
te.module.base.clear_workspace()
except ImportError:
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @ashors1 might be my issue. I can't find this in TE and I don't think this piece code is helpful to the memory saving, maybe we can simply remove it?

Comment on lines +1269 to +1270
gc.collect()
torch.cuda.empty_cache()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be more efficient to run gc.collect() and torch.cuda.empty_cache() just once after all references are cleared? Calling them frequently might introduce unnecessary overhead to the training pipeline.

Comment on lines +1368 to +1369
gc.collect()
torch.cuda.empty_cache()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same above:
Would it be more efficient to run gc.collect() and torch.cuda.empty_cache() just once after all references are cleared? Calling them frequently might introduce unnecessary overhead to the training pipeline.

ZhiyuLi-Nvidia
ZhiyuLi-Nvidia previously approved these changes Jun 5, 2026
Copy link
Copy Markdown
Contributor

@ZhiyuLi-Nvidia ZhiyuLi-Nvidia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ashors1 for driving the fix!
Just left some nit.
LGTM!

Signed-off-by: Anna Shors <ashors@nvidia.com>
ZhiyuLi-Nvidia
ZhiyuLi-Nvidia previously approved these changes Jun 5, 2026
Signed-off-by: ashors1 <ashors@nvidia.com>
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

Successfully merging this pull request may close these issues.

[FP8] Memory Leak and Fragmentation Investigation

2 participants