Trim PR #2590: revert CP/packing to main, keep R3 minimal (no THD pat…#2
Open
zyzhou5 wants to merge 1 commit into
Open
Trim PR #2590: revert CP/packing to main, keep R3 minimal (no THD pat…#2zyzhou5 wants to merge 1 commit into
zyzhou5 wants to merge 1 commit into
Conversation
…(no THD path, no gating) Deletes the PR's zigzag->Transformer-Engine-THD context-parallel rewrite entirely; CP/packing uses main's original per-sequence zigzag, byte-for-byte. Only minimal R3 (router-replay) plumbing is kept. No second code path, no use_thd_cp gating. Reverted ENTIRELY to main (diff vs main = 0; THD machinery deleted): - distributed/model_utils.py (_get_thd_partitioned_indices, _get_packed_thd_tokens_on_this_cp_rank, allgather_packed_thd_cp_sharded_tensor, AllGatherPackedTHDCPTensor, from_parallel_logits_to_logprobs* edits) - algorithms/loss/utils.py (_pack_input_ids THD), loss/wrapper.py (_packed_cp_cu_seqlens_padded) - tests: test_model_utils.py, test_sequence_packing_fusion.py, test_train.py data.py: - _pack_sequences_for_megatron is BYTE-IDENTICAL to main (5-tuple, unchanged signature/body) -> all main-arity callers (test_sequence_packing_fusion, megatron_data_actors, sequence_packing_gradient_actor) work unchanged. - routed_experts (+ R3-trace token_identity) CP-sharding moved to a SEPARATE additive helper _shard_routed_experts_for_cp, which rides the SAME per-seq _get_tokens_on_this_cp_rank(seq_dim=0) and derives per-seq padded boundaries from the packer's own cu_seqlens_padded (drift-free). arange(K) pad rows (mcore _validate_replay_tensor), no roll. process_microbatch calls the 5-tuple packer then the helper only when routed_experts is present. - Deleted the THD packer trio (_pack_token_aligned_*, _slice_batch_for_megatron_context_parallel). train.py: restored main TopkLogitsPostProcessor per-seq allgather; kept R3 forward plumbing. Kept unchanged (R3): router_replay.py, r3_trace.py, worker R3 orchestration, setup R3 config, vLLM routed_experts recording, dataplane routed_experts schema/codec. Tests: dropped THD-packer tests; re-pointed 2 process_microbatch tests to the 5-tuple packer + the new helper; added real CPU test test_shard_routed_experts_for_cp_matches_input_ids_zigzag (cp1/cp2) asserting routed_experts zigzag selection matches input_ids + arange(K) padding. Regime note: per-seq zigzag == THD for 2*cp-aligned packs (make_sequence_length_divisible_by=2*cp); validated configs (gate0 PP=1; committed PP=2/CP=2/TP=4 recipe) are in-regime. THD CP-correctness for non-2*cp whole-pack tails (PP>1/fp8) belongs in a separate CP PR. Not GPU-validated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1565fe0 to
1e7bb71
Compare
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.
Revert CP change