[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74ZDA57K108QS792RYCZ3F9":3,"skill-same:01M74ZDA57K108QS792RYCZ3F9":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":37,"ownerDescription":38,"updatedAt":39,"install":40,"resources":53},"01M74ZDA57K108QS792RYCZ3F9","ray-train",null,"Distributed training orchestration across clusters. Scales PyTorch\u002FTensorFlow\u002FHuggingFace from laptop to 1000s of nodes. Built-in hyperparameter tuning with Ray Tune, fault tolerance, elastic scaling. Use when training massive models across multiple machines or running distributed hyperparameter sweeps.","KalarisLabs\u002Fresearch-agent-skills","KalarisLabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F300878568?v=4","01M74Y7MT23GXXC56VM6TVSXZY","Kalarislabs","01M74Y7MTQM9REXZX4SNXWX95C",132,"MIT","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fray-train\u002FSKILL.md",[],[],"2026-11-11 17:47:46",false,"---\nname: ray-train\ndescription: Distributed training orchestration across clusters. Scales PyTorch\u002FTensorFlow\u002FHuggingFace from laptop to 1000s of nodes. Built-in hyperparameter tuning with Ray Tune, fault tolerance, elastic scaling. Use when training massive models across multiple machines or running distributed hyperparameter sweeps.\nlicense: MIT\nmetadata:\n  version: 1.0.0\n  category: ml-training\n  maintainer: Kalaris Labs\n  tags: Ray Train, Distributed Training, Orchestration, Ray, Hyperparameter Tuning, Fault Tolerance, Elastic Scaling, Multi-Node, PyTorch, TensorFlow\n  dependencies: ray[train], torch, transformers\n---\n\n# Ray Train - Distributed Training Orchestration\n\n## Quick start\n\nRay Train scales machine learning training from single GPU to multi-node clusters with minimal code changes.\n\n**Installation**:\n```bash\npip install -U \"ray[train]\"\n```\n\n**Basic PyTorch training** (single node):\n\n```python\nimport ray\nfrom ray import train\nfrom ray.train import ScalingConfig\nfrom ray.train.torch import TorchTrainer\nimport torch\nimport torch.nn as nn\n\n# Define training function\ndef train_func(config):\n    # Your normal PyTorch code\n    model = nn.Linear(10, 1)\n    optimizer = torch.optim.SGD(model.parameters(), lr=0.01)\n\n    # Prepare for distributed (Ray handles device placement)\n    model = train.torch.prepare_model(model)\n\n    for epoch in range(10):\n        # Your training loop\n        output = model(torch.randn(32, 10))\n        loss = output.sum()\n        loss.backward()\n        optimizer.step()\n        optimizer.zero_grad()\n\n        # Report metrics (logged automatically)\n        train.report({\"loss\": loss.item(), \"epoch\": epoch})\n\n# Run distributed training\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(\n        num_workers=4,  # 4 GPUs\u002Fworkers\n        use_gpu=True\n    )\n)\n\nresult = trainer.fit()\nprint(f\"Final loss: {result.metrics['loss']}\")\n```\n\n**That's it!** Ray handles:\n- Distributed coordination\n- GPU allocation\n- Fault tolerance\n- Checkpointing\n- Metric aggregation\n\n## Common workflows\n\n### Workflow 1: Scale existing PyTorch code\n\n**Original single-GPU code**:\n```python\nmodel = MyModel().cuda()\noptimizer = torch.optim.Adam(model.parameters())\n\nfor epoch in range(epochs):\n    for batch in dataloader:\n        loss = model(batch)\n        loss.backward()\n        optimizer.step()\n```\n\n**Ray Train version** (scales to multi-GPU\u002Fmulti-node):\n```python\nfrom ray.train.torch import TorchTrainer\nfrom ray import train\n\ndef train_func(config):\n    model = MyModel()\n    optimizer = torch.optim.Adam(model.parameters())\n\n    # Prepare for distributed (automatic device placement)\n    model = train.torch.prepare_model(model)\n    dataloader = train.torch.prepare_data_loader(dataloader)\n\n    for epoch in range(epochs):\n        for batch in dataloader:\n            loss = model(batch)\n            loss.backward()\n            optimizer.step()\n\n            # Report metrics\n            train.report({\"loss\": loss.item()})\n\n# Scale to 8 GPUs\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(num_workers=8, use_gpu=True)\n)\ntrainer.fit()\n```\n\n**Benefits**: Same code runs on 1 GPU or 1000 GPUs\n\n### Workflow 2: HuggingFace Transformers integration\n\n```python\nfrom ray.train.huggingface import TransformersTrainer\nfrom transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments\n\ndef train_func(config):\n    # Load model and tokenizer\n    model = AutoModelForCausalLM.from_pretrained(\"gpt2\")\n    tokenizer = AutoTokenizer.from_pretrained(\"gpt2\")\n\n    # Training arguments (HuggingFace API)\n    training_args = TrainingArguments(\n        output_dir=\".\u002Foutput\",\n        num_train_epochs=3,\n        per_device_train_batch_size=8,\n        learning_rate=2e-5,\n    )\n\n    # Ray automatically handles distributed training\n    from transformers import Trainer\n    trainer = Trainer(\n        model=model,\n        args=training_args,\n        train_dataset=train_dataset,\n    )\n\n    trainer.train()\n\n# Scale to multi-node (2 nodes × 8 GPUs = 16 workers)\ntrainer = TransformersTrainer(\n    train_func,\n    scaling_config=ScalingConfig(\n        num_workers=16,\n        use_gpu=True,\n        resources_per_worker={\"GPU\": 1}\n    )\n)\n\nresult = trainer.fit()\n```\n\n### Workflow 3: Hyperparameter tuning with Ray Tune\n\n```python\nfrom ray import tune\nfrom ray.train.torch import TorchTrainer\nfrom ray.tune.schedulers import ASHAScheduler\n\ndef train_func(config):\n    # Use hyperparameters from config\n    lr = config[\"lr\"]\n    batch_size = config[\"batch_size\"]\n\n    model = MyModel()\n    optimizer = torch.optim.Adam(model.parameters(), lr=lr)\n\n    model = train.torch.prepare_model(model)\n\n    for epoch in range(10):\n        # Training loop\n        loss = train_epoch(model, optimizer, batch_size)\n        train.report({\"loss\": loss, \"epoch\": epoch})\n\n# Define search space\nparam_space = {\n    \"lr\": tune.loguniform(1e-5, 1e-2),\n    \"batch_size\": tune.choice([16, 32, 64, 128])\n}\n\n# Run 20 trials with early stopping\ntuner = tune.Tuner(\n    TorchTrainer(\n        train_func,\n        scaling_config=ScalingConfig(num_workers=4, use_gpu=True)\n    ),\n    param_space=param_space,\n    tune_config=tune.TuneConfig(\n        num_samples=20,\n        scheduler=ASHAScheduler(metric=\"loss\", mode=\"min\")\n    )\n)\n\nresults = tuner.fit()\nbest = results.get_best_result(metric=\"loss\", mode=\"min\")\nprint(f\"Best hyperparameters: {best.config}\")\n```\n\n**Result**: Distributed hyperparameter search across cluster\n\n### Workflow 4: Checkpointing and fault tolerance\n\n```python\nfrom ray import train\nfrom ray.train import Checkpoint\n\ndef train_func(config):\n    model = MyModel()\n    optimizer = torch.optim.Adam(model.parameters())\n\n    # Try to resume from checkpoint\n    checkpoint = train.get_checkpoint()\n    if checkpoint:\n        with checkpoint.as_directory() as checkpoint_dir:\n            state = torch.load(f\"{checkpoint_dir}\u002Fmodel.pt\")\n            model.load_state_dict(state[\"model\"])\n            optimizer.load_state_dict(state[\"optimizer\"])\n            start_epoch = state[\"epoch\"]\n    else:\n        start_epoch = 0\n\n    model = train.torch.prepare_model(model)\n\n    for epoch in range(start_epoch, 100):\n        loss = train_epoch(model, optimizer)\n\n        # Save checkpoint every 10 epochs\n        if epoch % 10 == 0:\n            checkpoint = Checkpoint.from_directory(\n                train.get_context().get_trial_dir()\n            )\n            torch.save({\n                \"model\": model.state_dict(),\n                \"optimizer\": optimizer.state_dict(),\n                \"epoch\": epoch\n            }, checkpoint.path \u002F \"model.pt\")\n\n            train.report({\"loss\": loss}, checkpoint=checkpoint)\n\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(num_workers=8, use_gpu=True)\n)\n\n# Automatically resumes from checkpoint if training fails\nresult = trainer.fit()\n```\n\n### Workflow 5: Multi-node training\n\n```python\nfrom ray.train import ScalingConfig\n\n# Connect to Ray cluster\nray.init(address=\"auto\")  # Or ray.init(\"ray:\u002F\u002Fhead-node:10001\")\n\n# Train across 4 nodes × 8 GPUs = 32 workers\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(\n        num_workers=32,\n        use_gpu=True,\n        resources_per_worker={\"GPU\": 1, \"CPU\": 4},\n        placement_strategy=\"SPREAD\"  # Spread across nodes\n    )\n)\n\nresult = trainer.fit()\n```\n\n**Launch Ray cluster**:\n```bash\n# On head node\nray start --head --port=6379\n\n# On worker nodes\nray start --address=\u003Chead-node-ip>:6379\n```\n\n## When to use vs alternatives\n\n**Use Ray Train when**:\n- Training across multiple machines (multi-node)\n- Need hyperparameter tuning at scale\n- Want fault tolerance (auto-restart failed workers)\n- Elastic scaling (add\u002Fremove nodes during training)\n- Unified framework (same code for PyTorch\u002FTF\u002FHF)\n\n**Key advantages**:\n- **Multi-node orchestration**: Easiest multi-node setup\n- **Ray Tune integration**: Best-in-class hyperparameter tuning\n- **Fault tolerance**: Automatic recovery from failures\n- **Elastic**: Add\u002Fremove nodes without restarting\n- **Framework agnostic**: PyTorch, TensorFlow, HuggingFace, XGBoost\n\n**Use alternatives instead**:\n- **Accelerate**: Single-node multi-GPU, simpler\n- **PyTorch Lightning**: High-level abstractions, callbacks\n- **DeepSpeed**: Maximum performance, complex setup\n- **Raw DDP**: Maximum control, minimal overhead\n\n## Common issues\n\n**Issue: Ray cluster not connecting**\n\nCheck ray status:\n```bash\nray status\n\n# Should show:\n# - Nodes: 4\n# - GPUs: 32\n# - Workers: Ready\n```\n\nIf not connected:\n```bash\n# Restart head node\nray stop\nray start --head --port=6379 --dashboard-host=0.0.0.0\n\n# Restart worker nodes\nray stop\nray start --address=\u003Chead-ip>:6379\n```\n\n**Issue: Out of memory**\n\nReduce workers or use gradient accumulation:\n```python\nscaling_config=ScalingConfig(\n    num_workers=4,  # Reduce from 8\n    use_gpu=True\n)\n\n# In train_func, accumulate gradients\nfor i, batch in enumerate(dataloader):\n    loss = model(batch) \u002F accumulation_steps\n    loss.backward()\n\n    if (i + 1) % accumulation_steps == 0:\n        optimizer.step()\n        optimizer.zero_grad()\n```\n\n**Issue: Slow training**\n\nCheck if data loading is bottleneck:\n```python\nimport time\n\ndef train_func(config):\n    for epoch in range(epochs):\n        start = time.time()\n        for batch in dataloader:\n            data_time = time.time() - start\n            # Train...\n            start = time.time()\n            print(f\"Data loading: {data_time:.3f}s\")\n```\n\nIf data loading is slow, increase workers:\n```python\ndataloader = DataLoader(dataset, num_workers=8)\n```\n\n## Advanced topics\n\n**Multi-node setup**: See [references\u002Fmulti-node.md](references\u002Fmulti-node.md) for Ray cluster deployment on AWS, GCP, Kubernetes, and SLURM.\n\n**Hyperparameter tuning**: See references\u002Fhyperparameter-tuning.md for Ray Tune integration, search algorithms (Optuna, HyperOpt), and population-based training.\n\n**Custom training loops**: See references\u002Fcustom-loops.md for advanced Ray Train usage, custom backends, and integration with other frameworks.\n\n## Hardware requirements\n\n- **Single node**: 1+ GPUs (or CPUs)\n- **Multi-node**: 2+ machines with network connectivity\n- **Cloud**: AWS, GCP, Azure (Ray autoscaling)\n- **On-prem**: Kubernetes, SLURM clusters\n\n**Supported accelerators**:\n- NVIDIA GPUs (CUDA)\n- AMD GPUs (ROCm)\n- TPUs (Google Cloud)\n- CPUs\n\n## Resources\n\n- Docs: https:\u002F\u002Fdocs.ray.io\u002Fen\u002Flatest\u002Ftrain\u002Ftrain.html\n- GitHub: https:\u002F\u002Fgithub.com\u002Fray-project\u002Fray ⭐ 36,000+\n- Version: 2.40.0+\n- Examples: https:\u002F\u002Fdocs.ray.io\u002Fen\u002Flatest\u002Ftrain\u002Fexamples.html\n- Slack: https:\u002F\u002Fforms.gle\u002F9TSdDYUgxYs8SA9e8\n- Used by: OpenAI, Uber, Spotify, Shopify, Instacart\n\n## Agent operating procedure\n\n1. **Check the environment.** Check GPU type, memory and driver\u002FCUDA versions (`nvidia-smi`), framework versions, and dataset location and size.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Do a smoke run: tiny model or subset, few steps, and confirm loss decreases and checkpoints save.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Track metrics on held-out data, compare against a baseline, and record seeds, configs and hardware.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| CUDA out-of-memory | Reduce batch size, enable gradient accumulation\u002Fcheckpointing or mixed precision, or shard the model. |\n| Loss is NaN or diverges | Lower the learning rate, check data for invalid values, and enable gradient clipping. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Never claim training results without logs; estimate compute cost before launching large jobs.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n\n## Related skills\n\n- `ray-data`: Scalable data processing for ML workloads.\n- `pytorch-lightning-distributed`: High-level PyTorch framework with Trainer class, automatic distributed training (DDP\u002FFSDP\u002FDeepSpeed), callbacks system, and minimal boilerp…\n- `weights-and-biases`: Logs and tracks machine learning experiments with Weights & Biases (W&B, wandb): metrics, hyperparameters, checkpoints, sweeps, artifacts w…\n","# Ray Train - Distributed Training Orchestration\n\n## Quick start\n\nRay Train scales machine learning training from single GPU to multi-node clusters with minimal code changes.\n\n**Installation**:\n```bash\npip install -U \"ray[train]\"\n```\n\n**Basic PyTorch training** (single node):\n\n```python\nimport ray\nfrom ray import train\nfrom ray.train import ScalingConfig\nfrom ray.train.torch import TorchTrainer\nimport torch\nimport torch.nn as nn\n\n# Define training function\ndef train_func(config):\n    # Your normal PyTorch code\n    model = nn.Linear(10, 1)\n    optimizer = torch.optim.SGD(model.parameters(), lr=0.01)\n\n    # Prepare for distributed (Ray handles device placement)\n    model = train.torch.prepare_model(model)\n\n    for epoch in range(10):\n        # Your training loop\n        output = model(torch.randn(32, 10))\n        loss = output.sum()\n        loss.backward()\n        optimizer.step()\n        optimizer.zero_grad()\n\n        # Report metrics (logged automatically)\n        train.report({\"loss\": loss.item(), \"epoch\": epoch})\n\n# Run distributed training\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(\n        num_workers=4,  # 4 GPUs\u002Fworkers\n        use_gpu=True\n    )\n)\n\nresult = trainer.fit()\nprint(f\"Final loss: {result.metrics['loss']}\")\n```\n\n**That's it!** Ray handles:\n- Distributed coordination\n- GPU allocation\n- Fault tolerance\n- Checkpointing\n- Metric aggregation\n\n## Common workflows\n\n### Workflow 1: Scale existing PyTorch code\n\n**Original single-GPU code**:\n```python\nmodel = MyModel().cuda()\noptimizer = torch.optim.Adam(model.parameters())\n\nfor epoch in range(epochs):\n    for batch in dataloader:\n        loss = model(batch)\n        loss.backward()\n        optimizer.step()\n```\n\n**Ray Train version** (scales to multi-GPU\u002Fmulti-node):\n```python\nfrom ray.train.torch import TorchTrainer\nfrom ray import train\n\ndef train_func(config):\n    model = MyModel()\n    optimizer = torch.optim.Adam(model.parameters())\n\n    # Prepare for distributed (automatic device placement)\n    model = train.torch.prepare_model(model)\n    dataloader = train.torch.prepare_data_loader(dataloader)\n\n    for epoch in range(epochs):\n        for batch in dataloader:\n            loss = model(batch)\n            loss.backward()\n            optimizer.step()\n\n            # Report metrics\n            train.report({\"loss\": loss.item()})\n\n# Scale to 8 GPUs\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(num_workers=8, use_gpu=True)\n)\ntrainer.fit()\n```\n\n**Benefits**: Same code runs on 1 GPU or 1000 GPUs\n\n### Workflow 2: HuggingFace Transformers integration\n\n```python\nfrom ray.train.huggingface import TransformersTrainer\nfrom transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments\n\ndef train_func(config):\n    # Load model and tokenizer\n    model = AutoModelForCausalLM.from_pretrained(\"gpt2\")\n    tokenizer = AutoTokenizer.from_pretrained(\"gpt2\")\n\n    # Training arguments (HuggingFace API)\n    training_args = TrainingArguments(\n        output_dir=\".\u002Foutput\",\n        num_train_epochs=3,\n        per_device_train_batch_size=8,\n        learning_rate=2e-5,\n    )\n\n    # Ray automatically handles distributed training\n    from transformers import Trainer\n    trainer = Trainer(\n        model=model,\n        args=training_args,\n        train_dataset=train_dataset,\n    )\n\n    trainer.train()\n\n# Scale to multi-node (2 nodes × 8 GPUs = 16 workers)\ntrainer = TransformersTrainer(\n    train_func,\n    scaling_config=ScalingConfig(\n        num_workers=16,\n        use_gpu=True,\n        resources_per_worker={\"GPU\": 1}\n    )\n)\n\nresult = trainer.fit()\n```\n\n### Workflow 3: Hyperparameter tuning with Ray Tune\n\n```python\nfrom ray import tune\nfrom ray.train.torch import TorchTrainer\nfrom ray.tune.schedulers import ASHAScheduler\n\ndef train_func(config):\n    # Use hyperparameters from config\n    lr = config[\"lr\"]\n    batch_size = config[\"batch_size\"]\n\n    model = MyModel()\n    optimizer = torch.optim.Adam(model.parameters(), lr=lr)\n\n    model = train.torch.prepare_model(model)\n\n    for epoch in range(10):\n        # Training loop\n        loss = train_epoch(model, optimizer, batch_size)\n        train.report({\"loss\": loss, \"epoch\": epoch})\n\n# Define search space\nparam_space = {\n    \"lr\": tune.loguniform(1e-5, 1e-2),\n    \"batch_size\": tune.choice([16, 32, 64, 128])\n}\n\n# Run 20 trials with early stopping\ntuner = tune.Tuner(\n    TorchTrainer(\n        train_func,\n        scaling_config=ScalingConfig(num_workers=4, use_gpu=True)\n    ),\n    param_space=param_space,\n    tune_config=tune.TuneConfig(\n        num_samples=20,\n        scheduler=ASHAScheduler(metric=\"loss\", mode=\"min\")\n    )\n)\n\nresults = tuner.fit()\nbest = results.get_best_result(metric=\"loss\", mode=\"min\")\nprint(f\"Best hyperparameters: {best.config}\")\n```\n\n**Result**: Distributed hyperparameter search across cluster\n\n### Workflow 4: Checkpointing and fault tolerance\n\n```python\nfrom ray import train\nfrom ray.train import Checkpoint\n\ndef train_func(config):\n    model = MyModel()\n    optimizer = torch.optim.Adam(model.parameters())\n\n    # Try to resume from checkpoint\n    checkpoint = train.get_checkpoint()\n    if checkpoint:\n        with checkpoint.as_directory() as checkpoint_dir:\n            state = torch.load(f\"{checkpoint_dir}\u002Fmodel.pt\")\n            model.load_state_dict(state[\"model\"])\n            optimizer.load_state_dict(state[\"optimizer\"])\n            start_epoch = state[\"epoch\"]\n    else:\n        start_epoch = 0\n\n    model = train.torch.prepare_model(model)\n\n    for epoch in range(start_epoch, 100):\n        loss = train_epoch(model, optimizer)\n\n        # Save checkpoint every 10 epochs\n        if epoch % 10 == 0:\n            checkpoint = Checkpoint.from_directory(\n                train.get_context().get_trial_dir()\n            )\n            torch.save({\n                \"model\": model.state_dict(),\n                \"optimizer\": optimizer.state_dict(),\n                \"epoch\": epoch\n            }, checkpoint.path \u002F \"model.pt\")\n\n            train.report({\"loss\": loss}, checkpoint=checkpoint)\n\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(num_workers=8, use_gpu=True)\n)\n\n# Automatically resumes from checkpoint if training fails\nresult = trainer.fit()\n```\n\n### Workflow 5: Multi-node training\n\n```python\nfrom ray.train import ScalingConfig\n\n# Connect to Ray cluster\nray.init(address=\"auto\")  # Or ray.init(\"ray:\u002F\u002Fhead-node:10001\")\n\n# Train across 4 nodes × 8 GPUs = 32 workers\ntrainer = TorchTrainer(\n    train_func,\n    scaling_config=ScalingConfig(\n        num_workers=32,\n        use_gpu=True,\n        resources_per_worker={\"GPU\": 1, \"CPU\": 4},\n        placement_strategy=\"SPREAD\"  # Spread across nodes\n    )\n)\n\nresult = trainer.fit()\n```\n\n**Launch Ray cluster**:\n```bash\n# On head node\nray start --head --port=6379\n\n# On worker nodes\nray start --address=\u003Chead-node-ip>:6379\n```\n\n## When to use vs alternatives\n\n**Use Ray Train when**:\n- Training across multiple machines (multi-node)\n- Need hyperparameter tuning at scale\n- Want fault tolerance (auto-restart failed workers)\n- Elastic scaling (add\u002Fremove nodes during training)\n- Unified framework (same code for PyTorch\u002FTF\u002FHF)\n\n**Key advantages**:\n- **Multi-node orchestration**: Easiest multi-node setup\n- **Ray Tune integration**: Best-in-class hyperparameter tuning\n- **Fault tolerance**: Automatic recovery from failures\n- **Elastic**: Add\u002Fremove nodes without restarting\n- **Framework agnostic**: PyTorch, TensorFlow, HuggingFace, XGBoost\n\n**Use alternatives instead**:\n- **Accelerate**: Single-node multi-GPU, simpler\n- **PyTorch Lightning**: High-level abstractions, callbacks\n- **DeepSpeed**: Maximum performance, complex setup\n- **Raw DDP**: Maximum control, minimal overhead\n\n## Common issues\n\n**Issue: Ray cluster not connecting**\n\nCheck ray status:\n```bash\nray status\n\n# Should show:\n# - Nodes: 4\n# - GPUs: 32\n# - Workers: Ready\n```\n\nIf not connected:\n```bash\n# Restart head node\nray stop\nray start --head --port=6379 --dashboard-host=0.0.0.0\n\n# Restart worker nodes\nray stop\nray start --address=\u003Chead-ip>:6379\n```\n\n**Issue: Out of memory**\n\nReduce workers or use gradient accumulation:\n```python\nscaling_config=ScalingConfig(\n    num_workers=4,  # Reduce from 8\n    use_gpu=True\n)\n\n# In train_func, accumulate gradients\nfor i, batch in enumerate(dataloader):\n    loss = model(batch) \u002F accumulation_steps\n    loss.backward()\n\n    if (i + 1) % accumulation_steps == 0:\n        optimizer.step()\n        optimizer.zero_grad()\n```\n\n**Issue: Slow training**\n\nCheck if data loading is bottleneck:\n```python\nimport time\n\ndef train_func(config):\n    for epoch in range(epochs):\n        start = time.time()\n        for batch in dataloader:\n            data_time = time.time() - start\n            # Train...\n            start = time.time()\n            print(f\"Data loading: {data_time:.3f}s\")\n```\n\nIf data loading is slow, increase workers:\n```python\ndataloader = DataLoader(dataset, num_workers=8)\n```\n\n## Advanced topics\n\n**Multi-node setup**: See [references\u002Fmulti-node.md](references\u002Fmulti-node.md) for Ray cluster deployment on AWS, GCP, Kubernetes, and SLURM.\n\n**Hyperparameter tuning**: See references\u002Fhyperparameter-tuning.md for Ray Tune integration, search algorithms (Optuna, HyperOpt), and population-based training.\n\n**Custom training loops**: See references\u002Fcustom-loops.md for advanced Ray Train usage, custom backends, and integration with other frameworks.\n\n## Hardware requirements\n\n- **Single node**: 1+ GPUs (or CPUs)\n- **Multi-node**: 2+ machines with network connectivity\n- **Cloud**: AWS, GCP, Azure (Ray autoscaling)\n- **On-prem**: Kubernetes, SLURM clusters\n\n**Supported accelerators**:\n- NVIDIA GPUs (CUDA)\n- AMD GPUs (ROCm)\n- TPUs (Google Cloud)\n- CPUs\n\n## Resources\n\n- Docs: https:\u002F\u002Fdocs.ray.io\u002Fen\u002Flatest\u002Ftrain\u002Ftrain.html\n- GitHub: https:\u002F\u002Fgithub.com\u002Fray-project\u002Fray ⭐ 36,000+\n- Version: 2.40.0+\n- Examples: https:\u002F\u002Fdocs.ray.io\u002Fen\u002Flatest\u002Ftrain\u002Fexamples.html\n- Slack: https:\u002F\u002Fforms.gle\u002F9TSdDYUgxYs8SA9e8\n- Used by: OpenAI, Uber, Spotify, Shopify, Instacart\n\n## Agent operating procedure\n\n1. **Check the environment.** Check GPU type, memory and driver\u002FCUDA versions (`nvidia-smi`), framework versions, and dataset location and size.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Do a smoke run: tiny model or subset, few steps, and confirm loss decreases and checkpoints save.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Track metrics on held-out data, compare against a baseline, and record seeds, configs and hardware.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| CUDA out-of-memory | Reduce batch size, enable gradient accumulation\u002Fcheckpointing or mixed precision, or shard the model. |\n| Loss is NaN or diverges | Lower the learning rate, check data for invalid values, and enable gradient clipping. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Never claim training results without logs; estimate compute cost before launching large jobs.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n\n## Related skills\n\n- `ray-data`: Scalable data processing for ML workloads.\n- `pytorch-lightning-distributed`: High-level PyTorch framework with Trainer class, automatic distributed training (DDP\u002FFSDP\u002FDeepSpeed), callbacks system, and minimal boilerp…\n- `weights-and-biases`: Logs and tracks machine learning experiments with Weights & Biases (W&B, wandb): metrics, hyperparameters, checkpoints, sweeps, artifacts w…\n",{"name":5,"license":15,"metadata":24,"description":7},{"tags":25,"version":26,"category":27,"maintainer":28,"dependencies":29},"Ray Train, Distributed Training, Orchestration, Ray, Hyperparameter Tuning, Fault Tolerance, Elastic Scaling, Multi-Node, PyTorch, TensorFlow","1.0.0","ml-training","Kalaris Labs","ray[train], torch, transformers","main","29fe36d26127205057d5e0ed8425f6b0e9a8c13a","skills\u002Fray-train",16,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills","https:\u002F\u002Fdocs.kalarislabs.com\u002Fresearch-agent-skills","https:\u002F\u002Fgithub.com\u002FKalarisLabs","kalarislabs.com","Applied AI lab building the infrastructure for the agentic era","2026-11-14 17:49:08",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add KalarisLabs\u002Fresearch-agent-skills --skill ray-train",{"tool":46,"command":47},"bunx","bunx skills add KalarisLabs\u002Fresearch-agent-skills --skill ray-train",{"tool":49,"command":50},"pnpm","pnpm dlx skills add KalarisLabs\u002Fresearch-agent-skills --skill ray-train","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fray-train\u002FSKILL.md",true,[54],{"path":55,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Fmulti-node.md","REFERENCE","参考文档",13526,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fray-train\u002Freferences\u002Fmulti-node.md",[61,69,76,83,90,97],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":68},"01M74Z8MGT305R11SNY5G28QH5","plos","Prepare manuscripts for PLOS journals (PLOS ONE, PLOS Biology, PLOS Computational Biology, PLOS Genetics, PLOS Medicine, PLOS Pathogens, PLOS Neglected Tropical Diseases, PLOS Global Public Health and others), covering structure, abstract and author summary, Vancouver-style references, the mandatory data availability policy, ethics and financial disclosure statements, figure requirements (PACE), the PLOS LaTeX template, reporting guidelines and PLOS ONE's publication criteria. Use when targeting any PLOS journal or checking compliance with PLOS policies.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fplos\u002FSKILL.md",[],[],"2026-11-12 13:55:43",{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":68},"01M74Z8CCN9APXYHNQ95V1EBGT","pkpd-modeling","Pharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK\u002FPD and exposure-response, TMDD, PBPK orientation, bioequivalence, allometric scaling and first-in-human dose, drug interaction prediction, and Bayesian therapeutic drug monitoring. Use when analysing concentration-time data, deriving exposure metrics, fitting PK or PD models, or evaluating dosing regimens. Triggers include \"pharmacokinetics\", \"pharmacodynamics\", \"PK\u002FPD\", \"NCA\", \"non-compartmental\", \"AUC\", \"Cmax\", \"lambda z\", \"half-life\", \"clearance\", \"volume of distribution\", \"compartmental model\", \"population PK\", \"popPK\", \"NONMEM\", \"nlmixr2\", \"Pharmpy\", \"Monolix\", \"exposure-response\", \"Emax\", \"EC50\", \"indirect response\", \"effect compartment\", \"TMDD\", \"PBPK\", \"bioequivalence\", \"RSABE\", \"ABEL\", \"allometric scaling\", \"first-in-human\", \"MABEL\", \"drug-drug interaction\", \"DDI\", \"ICH M12\", \"concentration-QTc\", \"therapeutic drug monitoring\", \"MIPD\", and \"dosing regimen\".","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpkpd-modeling\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":68},"01M74Z86YHJJ1FM3X87BHN76KZ","pinecone","Guides use of Pinecone, a managed serverless vector database, through its Python client and the LangChain and LlamaIndex integrations. Covers creating indexes, upserting and querying vectors, metadata filtering, namespaces, hybrid dense and sparse search, index management, and deleting vectors. Use when building a production RAG system on a hosted vector store, adding semantic search or recommendations without running infrastructure, isolating per-user or per-tenant data with namespaces, combining dense and sparse vectors in one query, or filtering results by metadata. Do not use for self-hosted or local stores (Chroma, Weaviate) or offline similarity search (FAISS).","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpinecone\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":68},"01M74Z80T6E89SAJ8MYDD0767Q","pi-agent","Build with and use Pi, the minimal terminal coding harness. Use for installing Pi, configuring providers\u002Fmodels\u002Fsettings\u002Fenvironment variables, creating Pi skills\u002Fextensions\u002Fpackages\u002Fthemes\u002Fprompt templates, embedding Pi through the SDK, integrating over RPC or JSON event streams, parsing sessions, running local models through the llama.cpp router, developing custom Pi providers and TUI components, or using ecosystem packages such as pi-subagents (delegation\u002Forchestration), pi-mcp-adapter (MCP servers), pi-interview (interactive forms), and pi-web-access (web search, fetching, video understanding).","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpi-agent\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":68},"01M74Z7WF1Y8Q3VFAQPPPRAFMV","phoenix-observability","Open-source AI observability platform for LLM tracing, evaluation, and monitoring. Use when debugging LLM applications with detailed traces, running evaluations on datasets, or monitoring production AI systems with real-time insights.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fphoenix-observability\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":68},"01M74Z7HNEH1A2AVYR3G1X2QV6","peft-fine-tuning","Fine-tunes LLMs with Hugging Face PEFT, using LoRA, QLoRA, IA3, AdaLoRA, prefix tuning, and prompt tuning so that under 1% of parameters are trained. Covers rank, alpha, and target module selection, loading and merging adapters, multi-adapter serving, and integration with TRL SFTTrainer, Axolotl, and vLLM. Use when fine-tuning 7B-70B models on limited GPU memory, when running QLoRA on a single 24GB GPU, when choosing LoRA rank and alpha, when merging or swapping adapters on one base model, or when debugging CUDA OOM or an adapter that does not apply. Not for full fine-tuning of small models under 1B parameters or cases needing all weights updated.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpeft-fine-tuning\u002FSKILL.md",[],[]]