Skip to content

feat(weight_sync): Raiden weight synchronization with progressive memory reclamation - #1990

Open
SurbhiJainUSC wants to merge 1 commit into
mainfrom
feat/raiden-weight-sync
Open

feat(weight_sync): Raiden weight synchronization with progressive memory reclamation#1990
SurbhiJainUSC wants to merge 1 commit into
mainfrom
feat/raiden-weight-sync

Conversation

@SurbhiJainUSC

Copy link
Copy Markdown
Collaborator

This PR enhances the Raiden weight synchronization system with progressive host memory reclamation during parameter staging (preventing host OOMs on 30B+ MoE models), serializes per-source chunk transfers with retry backoff to prevent controller segfaults, and introduces a canonical dict_to_metadata deserializer for RPC workflows.

Motivation & Problem Statement

  1. Host OOM During Model Staging: Staging 30B+ MoE parameters (e.g. padded MoE MLP weights requiring ~80GB of host-resident bf16 arrays) previously held the entire JAX PyTree and NumPy arrays simultaneously in RAM, causing peak memory to double and triggering host OOMKills.
  2. Multi-Source Transfer Segfaults: Attempting to transfer multiple source work units in a single transfer() call triggered native Raiden controller multi-scheduling crashes at runtime.
  3. RPC Metadata Deserialization: Remote inference samplers (such as RLVllmSampler) emit transport metadata as plain dictionary objects over RPC/IPC, requiring a robust deserializer to convert them into strongly-typed WorkUnitMetadata instances.

Checklist

  • I have added all the necessary unit tests for my change.
  • I have verified that my change does not break existing code and all unit tests pass.
  • I have added all appropriate doc-strings/documentation.
  • My PR is based on the latest changes of the main branch (if unsure, rebase the code).
  • I have signed the Contributor License Agreement.
  • I have followed Contribution Guidelines.

Comment thread tunix/experimental/weight_sync/raiden_synchronizer.py
Comment thread tunix/experimental/weight_sync/weight_sync.py Outdated
@@ -51,16 +61,41 @@ def local_ip() -> str:


def to_host_cpu_state(state: Any) -> Any:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any test results on this ? like some before/after screenshots to show the improvement.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khatwanimohit - do you have any results on this?

Comment thread tunix/experimental/weight_sync/raiden_handler.py Outdated
# exceeded node-level free memory (a kubelet eviction, not a cgroup
# OOM) even though no single container had crossed its own limit.
# Forcing a collection every few leaves keeps that pileup bounded.
if i % 4 == 3:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what much performance impact this has? every 4 leaves seem like a very aggressive gc schedule.
Also are we allocating all RAM (e.g. 960B per node for v7x)? curious why we see kubelet eviction, since RAM pressure should be mild right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gc.collect() takes ~1ms per invocation. For a model tree with ~100–200 tensor leaves, running gc.collect() every 4 leaves results in ~25–50 collections, adding only ~25–50ms across a weight-sync operation. We can relax this frequency of collection, if preferred.

Comment thread tunix/experimental/weight_sync/raiden_synchronizer.py
@datenglin

Copy link
Copy Markdown
Contributor

Is this trying to unblock some urgent testing?

If not, I think we should fix this by using FFI for the Pathways trainer for weights sync, instead of progressively deleting and garbage-collecting leaves one-by-one during staging.

@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from 5132f08 to be8e689 Compare August 27, 2026 18:36
@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from be8e689 to f541b20 Compare August 27, 2026 18:39
@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from f541b20 to 313c9b5 Compare August 27, 2026 18:44
@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from 313c9b5 to 1cc2b25 Compare August 27, 2026 19:09
@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from 1cc2b25 to e028bdd Compare August 27, 2026 19:13
@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from e028bdd to 66025e3 Compare August 27, 2026 19:14
@SurbhiJainUSC
SurbhiJainUSC force-pushed the feat/raiden-weight-sync branch from 66025e3 to 6078487 Compare August 27, 2026 19:15
@SurbhiJainUSC SurbhiJainUSC changed the title feat: enhance Raiden weight sync with memory management and robust transfers feat(weight_sync): Raiden weight synchronization with progressive memory reclamation Aug 27, 2026
src_metadata = [m for per_source in src_meta_lists for m in per_source]
dst_metadata = [m for per_dest in dst_meta_lists for m in per_dest]
src_metadata = [
weight_sync.dict_to_metadata(m)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we changing the obj type? how come we need to do explicit dict to metadata conversion now but not before? also is current unit test covering this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants