Communitygithub.com

Ray 분산 컴퓨팅 에이전트 스킬

Ray Core(액터, 태스크), Ray Train, Ray Tune, Ray Serve를 아우르는 전문 Ray 분산 컴퓨팅 도움을 제공합니다. Python 컴퓨팅과 ML 학습을 멀티 노드 클러스터로 확장할 때 사용하세요.

Ray 분산 컴퓨팅 에이전트 스킬란 무엇인가요?

이 스킬은 Ray 분산 컴퓨팅 프레임워크에 대한 포괄적인 지원을 제공합니다. Ray Core의 분산 태스크와 상태 저장 액터를 사용하여 Python 애플리케이션을 확장하고, Ray Train으로 다중 노드 ML 학습( PyTorch, XGBoost, LightGBM)을 오케스트레이션하며, Ray Serve로 프로덕션 등급 모델 서빙을 위한 확장 가능한 REST 엔드포인트를 배포하고, Ray Tune을 사용한 하이퍼파라미터 최적화를 지원합니다. Ray 3.0(2025)의 효율성 개선 사항과 MCP 서버를 활용하여 에이전트 통합을 간소화합니다. 또한 Ray Dashboard를 통한 모니터링, 대용량 데이터를 위한 플라즈마 객체 저장소 사용, 명시적 리소스 요청 등의 모범 사례를 포함하며, 객체 저장소 가득 참, 액터 비정상 종료, 리소스 요청 실패 등의 일반적인 문제에 대한 문제 해결 가이드를 제공합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/G1Joshi/Agent-Skills/tree/HEAD/skills/ai-ml/ray

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Ray

Ray는 AI를 위한 컴퓨팅 레이어입니다. ChatGPT 학습과 대규모 워크로드를 지원합니다. v3.0(2025)은 효율성을 개선하고 에이전트를 위한 MCP 서버를 추가했습니다.

사용 시기

  • 분산 Python 애플리케이션: 단일 랩탑에서 대규모 클라우드 클러스터까지 컴퓨팅 집약적 Python 작업을 원활하게 확장합니다.
  • Ray Train을 사용한 분산 ML 학습: 다중 노드 PyTorch, XGBoost, LightGBM 학습 작업을 오케스트레이션합니다.
  • Ray Serve를 사용한 프로덕션 모델 서빙: 동적 자동 확장 기능으로 LLM 및 다중 모델 마이크로서비스 파이프라인을 서빙합니다.
  • Ray Tune을 사용한 하이퍼파라미터 최적화: 수백 개의 워커에서 베이지안, Optuna, PBT(인구 기반 학습) 스윕을 실행합니다.

빠른 시작

import ray

ray.init()

# 원격 분산 태스크
@ray.remote
def square(x):
    return x * x

# 클러스터 전체에서 태스크를 병렬로 실행
futures = [square.remote(i) for i in range(10)]
results = ray.get(futures)
print("Computed squares:", results)

핵심 개념

#분산 태스크 및 상태 저장 액터

클러스터 워커 전체에서 함수와 클래스를 확장합니다:

import ray
import time

# 로컬 초기화 또는 원격 Ray 클러스터에 연결
ray.init(ignore_reinit_error=True)

# 1. 무상태 원격 함수 (분산 태스크)
@ray.remote
def process_data_chunk(chunk_id: int) -> dict:
    time.sleep(0.5) # CPU/IO 집약적 연산 시뮬레이션
    return {"chunk_id": chunk_id, "processed_items": 1000 * chunk_id}

# 클러스터 전체에서 태스크를 동시에 실행
futures = [process_data_chunk.remote(i) for i in range(8)]
results = ray.get(futures) # 결과 수집
print("Processed Chunks:", results)

# 2. 상태 저장 원격 클래스 (분산 액터)
@ray.remote
class GlobalCounter:
    def __init__(self):
        self.count = 0

    def increment(self) -> int:
        self.count += 1
        return self.count

counter_actor = GlobalCounter.remote()
inc_futures = [counter_actor.increment.remote() for _ in range(5)]
print("Final actor count:", ray.get(inc_futures[-1]))

#Ray Serve를 사용한 프로덕션 모델 서빙

동적 요청 배치 기능으로 확장 가능한 REST 엔드포인트 배포:

from ray import serve
import torch
from transformers import pipeline

@serve.deployment(num_replicas=2, ray_actor_options={"num_cpus": 1, "num_gpus": 0})
class SentimentClassifier:
    def __init__(self):
        self.classifier = pipeline("sentiment-analysis")

    async def __call__(self, request):
        json_data = await request.json()
        text = json_data.get("text", "")
        return self.classifier(text)

app = SentimentClassifier.bind()
# serve.run(app)

#Ray Tune을 사용한 분산 하이퍼파라미터 튜닝

병렬 하이퍼파라미터 실험 실행:

from ray import tune

def training_function(config):
    # 시뮬레이션된 모델 학습
    for step in range(10):
        intermediate_score = config["alpha"] * step + config["beta"]
        tune.report(loss=1.0 / (intermediate_score + 0.1))

search_space = {
    "alpha": tune.uniform(0.1, 1.0),
    "beta": tune.choice([1, 2, 5])
}

tuner = tune.Tuner(
    training_function,
    param_space=search_space,
    tune_config=tune.TuneConfig(num_samples=10, metric="loss", mode="min")
)
results = tuner.fit()
print("Best hyperparameters:", results.get_best_result().config)

일반적인 패턴

모델 서빙을 위한 상태 저장 분산 액터

문제: 함수 호출 시마다 대용량 모델 가중치를 메모리에 다시 로드해야 합니다.

해결책: Ray 액터를 사용하여 요청 간에 인메모리 상태를 유지합니다:

@ray.remote(num_gpus=1)
class ModelServer:
    def __init__(self):
        # GPU VRAM에 가중치를 한 번 로드
        self.model = load_large_model()

    def predict(self, sample):
        return self.model(sample)

server_actor = ModelServer.remote()
prediction = ray.get(server_actor.predict.remote(sample_data))

모범 사례 (2026)

  • 권장: Ray Dashboard(포트 8265)를 확인하여 노드 CPU/GPU 사용률, 액터 배치, 객체 저장소 메모리를 모니터링하세요.
  • 권장: 반복적인 직렬화를 방지하기 위해 Ray 플라즈마 객체 저장소(ray.put(data))를 통해 대용량 읽기 전용 데이터셋을 전달하세요.
  • 권장: 데코레이터(@ray.remote(num_cpus=2, num_gpus=1))에서 리소스 요구 사항을 명시적으로 지정하세요.
  • 권장: Ray Serve를 사용하여 내장된 자동 배치 기능으로 프로덕션 다중 모델 마이크로서비스를 구축하세요.
  • 비권장: 원격 태스크 내부에서 ray.get()을 호출하지 마세요. 파이프라이닝을 유지하기 위해 ObjectRef를 다른 원격 태스크에 직접 전달하세요.
  • 비권장: 수백만 개의 미세 태스크를 생성하지 마세요. 스케줄러 오버헤드를 최소화하기 위해 세분화된 태스크를 함께 배치하세요.
  • 비권장: 데이터베이스 연결이나 열린 파일과 같은 대용량 상태 저장 객체를 원격 인수로 전달하지 마세요.

문제 해결

오류원인해결 방법
RaySystemError: Object store full할당된 공유 메모리 플라즈마 저장소보다 더 많은 데이터를 생성하는 태스크입니다.ray.get()을 사용하여 결과를 소비하거나, 대용량 배열을 디스크 저장소에 저장하세요.
Actor died unexpectedly처리되지 않은 예외 또는 OOM으로 인해 워커 프로세스가 충돌했습니다.Ray Dashboard(http://localhost:8265)에서 로그를 확인하고 워커 RAM을 늘리세요.
Task failed to schedule: Unsatisfiable resource request클러스터에서 사용 가능한 것보다 더 많은 CPU/GPU(num_gpus=2)를 요청했습니다.ray.cluster_resources()를 통해 사용 가능한 리소스를 확인하세요.

참고 자료

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

G1Joshi/Agent-Skills

Expert Dask distributed computing assistance covering Dask DataFrames, Arrays, Futures, and cluster scaling. Use when analyzing datasets too large for pandas on a single machine or multi-node cluster.

G1Joshi/Agent-Skills

Expert dbt (data build tool) assistance covering SQL modeling, Jinja macros, tests, documentation, and semantic layer. Use when building analytics engineering pipelines on BigQuery, Snowflake, or PostgreSQL.

G1Joshi/Agent-Skills

Expert JAX assistance covering Autograd, XLA compilation (`jit`), vectorization (`vmap`), and parallelization (`pmap`). Use when building high-performance numerical computing and cutting-edge deep learning research.

G1Joshi/Agent-Skills

Expert Git version control assistance covering branching, interactive rebase, cherry-pick, submodules, worktrees, and conflict resolution. Use when managing source code history and collaboration workflows.

G1Joshi/Agent-Skills

Expert K9s CLI assistance covering terminal Kubernetes cluster navigation, real-time log streaming, port forwarding, and pod debugging. Use when managing and troubleshooting Kubernetes clusters with speed.

G1Joshi/Agent-Skills

Expert SWC assistance covering high-performance Rust-based JavaScript/TypeScript compilation, .swcrc configuration, Jest testing via @swc/jest, and minification. Use when replacing Babel with SWC for faster builds, accelerating test execution, or compiling modern ECMAScript features.

G1Joshi/Agent-Skills

Expert Tig assistance covering text-mode interface for Git, interactive staging, commit graph visualization, diff exploration, and blame navigation. Use when navigating Git commit history in the terminal, staging hunks interactively, browsing file changes, or reviewing revisions.

G1Joshi/Agent-Skills

Expert Vim assistance covering modal editing, .vimrc configuration, registers, macros, search/replace, and plugin management via vim-plug. Use when editing text efficiently in terminal environments, writing Vimscript, recording macros, or configuring core Vim settings.

G1Joshi/Agent-Skills

Expert Zed editor assistance covering high-performance Rust-based text editing, multi-buffer editing, language server protocols (LSP), and AI assistant integrations. Use when configuring Zed settings.json, setting up language extensions, collaborating in real-time channels, or optimizing editor startup speed.

G1Joshi/Agent-Skills

Expert Zsh assistance covering shell customization, Oh My Zsh plugins, Zinit plugin manager, prompt engineering (Starship/Powerlevel10k), and shell scripting. Use when configuring .zshrc, writing Zsh automation scripts, optimizing shell startup time, or configuring tab-completion.

G1Joshi/Agent-Skills

Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].

관련 스킬