Skip to content

Conversation

SeungjinYang
Copy link
Collaborator

The two users of get_all_pods_in_kubernetes_cluster does the same postprocessing of the pods

  • filter out pods that are not in PENDING or RUNNING
  • filter out pods according to should_exclude_pod_from_gpu_allocation
    and then postprocesses the pods calculate a collections.defaultdict(int).

By moving the filtering and postprocessing logic into the stream processing, we can reduce the memory needs of executing this call especially in larger k8s contexts with a lot of pods.

Tested (run the relevant ones):

  • Code formatting: install pre-commit (auto-check on commit) or bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: /smoke-test (CI) or pytest tests/test_smoke.py (local)
  • Relevant individual tests: /smoke-test -k test_name (CI) or pytest tests/test_smoke.py::test_name (local)
  • Backward compatibility: /quicktest-core (CI) or pytest tests/smoke_tests/test_backward_compat.py (local)

Base automatically changed from optimize-k8s-list-accelerators to master October 13, 2025 17:31
@SeungjinYang SeungjinYang force-pushed the pod-filter-optimization branch 2 times, most recently from bd50169 to 24a4912 Compare October 13, 2025 17:36
@SeungjinYang SeungjinYang marked this pull request as ready for review October 13, 2025 17:37
@SeungjinYang SeungjinYang force-pushed the pod-filter-optimization branch from b05eb75 to a66ee81 Compare October 14, 2025 00:18
@kevinmingtarja
Copy link
Collaborator

/quicktest-core --kubernetes
/smoke-test --kubernetes

Copy link
Collaborator

@kevinmingtarja kevinmingtarja left a comment

Choose a reason for hiding this comment

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

LGTM overall, thanks @SeungjinYang! Just one question regarding the allocated_qty calculation.

@SeungjinYang SeungjinYang force-pushed the pod-filter-optimization branch from a66ee81 to 4c54079 Compare October 14, 2025 17:57
@SeungjinYang SeungjinYang enabled auto-merge (squash) October 14, 2025 18:11
@SeungjinYang SeungjinYang merged commit f0f90c4 into master Oct 14, 2025
20 checks passed
@SeungjinYang SeungjinYang deleted the pod-filter-optimization branch October 14, 2025 18:19
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.

2 participants