You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Root cause: DataParallelEmbeddingCollection.forward() called KJT.split() and KJT.to_dict(), both of which internally invoke length_per_key() → .tolist() → D2H sync. This sync on the side stream blocked the CPU thread and serialized DP/MP embedding.
Fix (3 changes):
Replace split() with permute() — permute filters to DP-only features without triggering length_per_key() D2H. Always keep _features_order (no longer optimize to empty list).
Replace KJT(...).to_dict() with manual dict build — _build_output_dict() slices lengths using Python-int stride arithmetic (all_lengths[i*stride : (i+1)*stride]) and splits values via torch.split(embeddings, length_per_key). JaggedTensor.__init__ is sync-free (pure reference assignment).
compute_dp_length_per_key() — extracts per-DP-feature value counts from the input KJT's already-cachedlength_per_key (built by from_lengths_sync). Pure Python list indexing — zero GPU work, zero D2H.
DP/MP overlap: ShardedEmbedding.forward() now launches DP on side stream first, then MP on default stream. The two run concurrently on GPU. wait_stream (stream-level sync, not CPU sync) ensures correctness before downstream consumption.
Activity
shijieliu commentedon Feb 25, 2026
we need to remove d2h from critical path in embedding
JacoCheung commentedon Mar 16, 2026
New foundings:
The DP forward poses a D2H sync here
Good news is that in dynamic mp embedding, there is no any sync yet, and the overlap is eligible.
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
JacoCheung commentedon Apr 2, 2026
Fix: eliminate D2H sync in DP embedding forward
PR: #340 (commit
c1356f2c)Root cause:
DataParallelEmbeddingCollection.forward()calledKJT.split()andKJT.to_dict(), both of which internally invokelength_per_key()→.tolist()→ D2H sync. This sync on the side stream blocked the CPU thread and serialized DP/MP embedding.Fix (3 changes):
Replace
split()withpermute()—permutefilters to DP-only features without triggeringlength_per_key()D2H. Always keep_features_order(no longer optimize to empty list).Replace
KJT(...).to_dict()with manual dict build —_build_output_dict()slices lengths using Python-int stride arithmetic (all_lengths[i*stride : (i+1)*stride]) and splits values viatorch.split(embeddings, length_per_key).JaggedTensor.__init__is sync-free (pure reference assignment).compute_dp_length_per_key()— extracts per-DP-feature value counts from the input KJT's already-cachedlength_per_key(built byfrom_lengths_sync). Pure Python list indexing — zero GPU work, zero D2H.DP/MP overlap:
ShardedEmbedding.forward()now launches DP on side stream first, then MP on default stream. The two run concurrently on GPU.wait_stream(stream-level sync, not CPU sync) ensures correctness before downstream consumption.JacoCheung commentedon Apr 2, 2026
See timeline diff (
sync-free dp+dp firstvsmp fisrt).The sharded embedding forward lantency diff:
11.266ms vs 13.867ms
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…
perf: eliminate D2H sync in DP embedding forward and enable DP/MP ove…