Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/ray/dashboard/modules/node/datacenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async def _get_actor_info(actor: Optional[dict]) -> Optional[dict]:
break

for gpu_stats in node_physical_stats.get("gpus", []):
# gpu_stats.get("processes") can be None, an empty list or a
# gpu_stats.get("processesPids") can be None, an empty list or a
Copy link
Contributor

Choose a reason for hiding this comment

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

[1]

# list of dictionaries.
for process in gpu_stats.get("processesPids") or []:
if process["pid"] == pid:
Expand Down
6 changes: 3 additions & 3 deletions python/ray/dashboard/modules/reporter/gpu_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ def _parse_nvsmi_pmon_output(
1 7175 C 86 26 - - - - ray::TorchGPUWo
2 - - - - - - - - -

Returns a dict mapping GPU index to list of ProcessGPUInfo.
Returns a dict mapping GPU index to dict of pid to ProcessGPUInfo.
"""
process_utilizations = defaultdict(list)
process_utilizations = defaultdict(dict)
lines = nvsmi_stdout.splitlines()
# Get the first line that is started with #
table_header = None
Expand Down Expand Up @@ -275,7 +275,7 @@ def _parse_nvsmi_pmon_output(
), # Convert percentage to MB
gpu_utilization=sm,
)
process_utilizations[gpu_id].append(process_info)
process_utilizations[gpu_id][pid] = process_info
return process_utilizations

def _get_pynvml_gpu_usage(self) -> List[GpuUtilizationInfo]:
Expand Down
19 changes: 17 additions & 2 deletions python/ray/dashboard/modules/reporter/reporter_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def _get_agent_proc(self) -> psutil.Process:
def _generate_worker_key(self, proc: psutil.Process) -> Tuple[int, float]:
return (proc.pid, proc.create_time())

def _get_workers(self, gpus: Optional[List[GpuUtilizationInfo]] = None):
def _get_worker_processes(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is for test mocking

raylet_proc = self._get_raylet_proc()
if raylet_proc is None:
return []
Expand All @@ -910,7 +910,13 @@ def _get_workers(self, gpus: Optional[List[GpuUtilizationInfo]] = None):
self._generate_worker_key(proc): proc
for proc in raylet_proc.children()
}
return workers

def _get_workers(self, gpus: Optional[List[GpuUtilizationInfo]] = None):
workers = self._get_worker_processes()
if not workers:
return []
else:
# We should keep `raylet_proc.children()` in `self` because
# when `cpu_percent` is first called, it returns the meaningless 0.
# See more: https://github.com/ray-project/ray/issues/29848
Expand All @@ -937,7 +943,7 @@ def _get_workers(self, gpus: Optional[List[GpuUtilizationInfo]] = None):
processes = gpu.get("processes_pids")
if processes:
for proc in processes.values():
gpu_pid_mapping[proc.pid].append(proc)
gpu_pid_mapping[proc["pid"]].append(proc)
Copy link
Contributor

Choose a reason for hiding this comment

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

qq: is there a test we can add to actually hit this code path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update test_report_per_component_stats_gpu to make sure it fails without my fix


result = []
for w in self._workers.values():
Expand Down Expand Up @@ -1763,6 +1769,15 @@ def _compose_stats_payload(

self._metrics_agent.clean_all_dead_worker_metrics()

# Convert processes_pids back to a list of dictionaries to maintain backwards-compatibility
Copy link
Contributor

Choose a reason for hiding this comment

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

[1] is using processPids as the key while this uses processes_pids so I cannot connect the dots of who is using this field; perhaps add comments to explain what is the consumption of this gpu object (the datacenter in this case? and that it expects this type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment here

for gpu in stats["gpus"]:
if isinstance(gpu.get("processes_pids"), dict):
gpu["processes_pids"] = list(gpu["processes_pids"].values())

# TODO(aguo): Add a pydantic model for this dict to maintain compatibility
# with the Ray Dashboard API and UI code.

# NOTE: This converts keys to "Google style", (e.g: "processes_pids" -> "processesPids")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@can-anyscale added comment here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

look at the implementation of jsonify_asdict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's confusing and unnecessary but it's too late to change. It would be massively backwards-incompatible to remove this conversion.

return jsonify_asdict(stats)

async def run(self, server):
Expand Down
Loading