Repository navigation
Conversation
Signed-off-by: Lin-xs <1833080950@qq.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a buffered/batched optimizer-tensor transfer path to reduce per-tensor communication overhead during resharding, and adds extra runtime instrumentation (timings + per-peer byte stats). It also updates the E2E demo script and checkpoint output path behavior to align with the new logging/measurement workflow.
Changes:
- Batch/pack multiple optimizer tensor slices per peer into a single
uint8buffer and transfer viabatch_isend_irecv, with added timing instrumentation. - Track communication bytes by peer (send/recv breakdown) and print per-rank stage timing + traffic summaries.
- Update demo/run and checkpoint save path behavior (logging layout, SAVE_PATH usage).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| run_e2e_demo.sh | Updates demo launch configuration, logging layout, and adds post-processing. |
| elastic_megatron/transfer/transfer.py | Implements batched/packed P2P transfers and adds detailed timers. |
| elastic_megatron/transfer/communicator.py | Adds per-peer send/recv byte accounting and returns structured comm stats. |
| elastic_megatron/elastic_manager.py | Collects/prints per-rank transfer stage timings and send/recv stats. |
| elastic_megatron/megatron_manager/training_state.py | Adds model_only option to weight sync; changes default checkpoint base directory logic. |
| elastic_megatron/megatron_manager/megatron_state.py | Adds (currently commented) memory/parallel-state debug helpers. |
| elastic_megatron/resharding/virtual_param.py | Adds import and debug comments around reshard-plan generation/caching. |
| elastic_megatron/resharding/util.py | Improves string formatting for range types (but introduces duplicate __str__). |
| elastic_megatron/resharding/resharding_tp.py | Adds illustrative comments for TP scale up/down mapping. |
| elastic_megatron/resharding/resharding_metadata.py | Adds clarifying comments in layer index update. |
| elastic_megatron/resharding/resharding_dp.py | Adds clarifying docstrings/comments for DP bucket distribution helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+7
to
+18
| BASE_PATH=/mnt/public/yuanqwang/flextrain | ||
| MEGATRON_PATH=/mnt/public/yuanqwang/flextrain/Megatron-LM-011 | ||
| export PYTHONPATH="${BASE_PATH}/ElasticMegatron:${MEGATRON_PATH}" | ||
| export TORCH_NCCL_AVOID_RECORD_STREAMS=1 | ||
|
|
||
| export OMP_NUM_THREADS=8 | ||
| export CUDA_DEVICE_MAX_CONNECTIONS=1 | ||
|
|
||
| TP=${TP:-1} | ||
| PP=${PP:-1} | ||
| export CUDA_VISIBLE_DEVICES="0" | ||
| CONFIG_PY=/mnt/public/yuanqwang/flextrain/Megatron-LM-011/megatron/training/set_config.py | ||
| TP=$(python ${CONFIG_PY} tp) | ||
| PP=$(python ${CONFIG_PY} pp) | ||
| # export CUDA_VISIBLE_DEVICES="0" |
Comment on lines
+32
to
+33
| export MODEL_SIZE=${MODEL_SIZE:-"tiny"} | ||
| export MODEL_SIZE=$(python ${CONFIG_PY} model_size) |
Comment on lines
+63
to
+67
| if [ "${NODE_RANK}" -eq 0 ]; then | ||
| time_prefix=$(TZ='UTC-8' date +%Y%m%d-%H%M%S) | ||
| printf '%s\n' "${time_prefix}" > "${rendezvous_file}" | ||
| else | ||
| until [ -s "${rendezvous_file}" ]; do sleep 1; done |
Comment on lines
+211
to
+213
| if [ $NODE_RANK == 0 ]; then | ||
| python /mnt/public/yuanqwang/flextrain/testcode/load_log.py $LOG_PATH | tee -a ${LOG_PATH} | ||
| fi No newline at end of file |
Comment on lines
+653
to
+654
| use_block_and_print = False | ||
|
|
|
|
||
|
|
||
| obj_list = [None] * torch.distributed.get_world_size(group=union_world_group) | ||
| torch.distributed.all_gather_object(obj_list, local_comm_info) |
Comment on lines
+131
to
+141
| def get_communication_bytes(self) -> CommunicationBytes: | ||
| """Get the communication bytes(GB) and reset the communication bytes to 0""" | ||
| communication_bytes = self._communication_bytes | ||
| communication_bytes_send = self._communication_bytes_send | ||
| communication_bytes_recv = self._communication_bytes_recv | ||
| self._communication_bytes = 0 | ||
| return communication_bytes / (1024**3) | ||
| self._communication_bytes_send = defaultdict(int) | ||
| self._communication_bytes_recv = defaultdict(int) | ||
| return CommunicationBytes( | ||
| communication_bytes_send, communication_bytes_recv, communication_bytes | ||
| ) |
Comment on lines
348
to
354
| if save_path is None: | ||
| cwd = pathlib.Path.cwd() | ||
| cwd = pathlib.Path(os.environ["SAVE_PATH"]) | ||
| save_dir = ( | ||
| cwd.parent | ||
| / "ElasticMegatron" | ||
| / "tools" | ||
| cwd | ||
| / "ckpt" | ||
| / ("before_reshard" if is_before_reshard else "after_reshard") | ||
| ) |
| from copy import deepcopy | ||
| from typing import Tuple | ||
| import torch | ||
| from megatron.core import parallel_state |
i-Taozi
self-requested a review
May 11, 2026 03:36
Signed-off-by: Lin-xs <1833080950@qq.com>
Signed-off-by: Lin-xs <1833080950@qq.com>
Signed-off-by: Lin-xs <1833080950@qq.com>
Signed-off-by: Lin-xs <1833080950@qq.com>
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.
No description provided.