Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a VRAM memory leak during weight conversion in the WeightConverter (issue #1497), where CUDA memory was accumulating across layers because intermediate tensors and original layer data were not being freed. It also refines memory monitoring by moving per-module logging into the unfuse function and adjusting a decorator message.
Changes:
- Added
del dq_weightandlayer.to("meta")in all fourconvert_layerimplementations (FP8, MXFP4, MXFP8, NVFP4) to release intermediate CUDA tensors and original layer data after dequantization. - Moved memory monitoring from the
@dump_mem_usagedecorator on_handle_moe_modulesinto_unfuse_experts_weights_inplacefor per-module VRAM tracking. - Changed the capitalization of the
dump_mem_usagemessage for_apply_custom_replacements.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| auto_round/utils/weight_handler.py | Added del dq_weight and layer.to("meta") in all four handler convert_layer methods to free CUDA memory after weight dequantization. |
| auto_round/modeling/fused_moe/replace_modules.py | Removed @dump_mem_usage decorator from _handle_moe_modules; changed capitalization on _apply_custom_replacements decorator message. |
| auto_round/modeling/fused_moe/moe_experts_interface.py | Added memory_monitor.update() and log_summary() calls before/after the unfusing logic in _unfuse_experts_weights_inplace. |
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
release CUDA memory in WeightConverter and avoid meaningless print
Type of Change
Related Issues
Fixes or relates to #1497
Checklist Before Submitting