Add finetune memory instrumentation for issue #61#132
Open
taivu1998 wants to merge 1 commit intoServiceNow:mainfrom
Open
Add finetune memory instrumentation for issue #61#132taivu1998 wants to merge 1 commit intoServiceNow:mainfrom
taivu1998 wants to merge 1 commit intoServiceNow:mainfrom
Conversation
Author
|
Hi @rizar, could you help review this PR? Thank you so much! |
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.
Summary
Related to #61.
This PR adds default-off memory instrumentation to the finetuning loop so we can localize the long-running trainer memory growth reported in issue #61.
This is intentionally not presented as a full fix for the leak by itself. The goal of this change is to make the trainer produce enough evidence to distinguish between:
What Changed
pipelinerl.finetune.memory_debug.MemoryDebuggerto capture per-rank JSONL snapshots./proc/self/smaps_rollupdata.run_data_loader()andrl_finetuning_worker().finetune.memory_debugconfig block inconf/finetune/base.yaml.force_restartcleanup with the actual finetune log directory (log/).Config
The new config surface is intentionally small and default-off:
When enabled, each rank writes:
finetune/log/memory_rank{rank}.jsonlphase_granularity=micro_batchenables the finer loader / RL-step / backward probes.Why This Shape
The issue screenshots suggest node-level host-memory growth, but they do not prove a single Python-RSS leak. This PR keeps the first instrumentation pass practical and low-risk:
Validation
I ran:
python3 -m compileall pipelinerl/finetune/memory_debug.py pipelinerl/finetune_loop.pygit diff --checkFollow-Up
The next step for #61 is to run trainer-only replay with
finetune.memory_debug.enabled=trueon a capturedtraining_datastream and use the emitted snapshots to decide whether the slope tracks: