MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / __init__

Method __init__

lightx2v/disagg/mooncake.py:130–158  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

128
129 def initialize(
130 self,
131 local_hostname: str,
132 metadata_server: str,
133 protocol: str,
134 device_name: str,
135 ) -> None:
136 """Initialize the mooncake instance."""
137 if self.engine:
138 ret = self.engine.initialize(local_hostname, metadata_server, protocol, device_name)
139 if ret != 0:
140 raise RuntimeError(f"Mooncake initialization failed with code {ret}.")
141
142 def transfer_sync(self, session_id: str, buffer: int, peer_buffer_address: int, length: int) -> int:
143 """Synchronously transfer data to the specified address."""
144 if self.engine:
145 if os.getenv("NETWORK_LATENCY"):
146 latency_prob_raw = os.getenv("NETWORK_LATENCY_PROB", "0.02")
147 latency_sec_raw = os.getenv("NETWORK_LATENCY_SEC", "5")
148 try:
149 latency_prob = float(latency_prob_raw)
150 except ValueError:
151 latency_prob = 0.02
152 # Accept either ratio (0.02) or percentage (2 / 5).
153 if latency_prob > 1.0:
154 latency_prob = latency_prob / 100.0
155 latency_prob = max(0.0, min(1.0, latency_prob))
156
157 try:
158 latency_sec = float(latency_sec_raw)
159 except ValueError:
160 latency_sec = 5.0
161 latency_sec = max(0.0, latency_sec)

Callers

nothing calls this directly

Calls 5

initializeMethod · 0.95
warningMethod · 0.80
load_from_envMethod · 0.80
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected