[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6M0JBJT09HKXPK93ZPXFX42":3,"skill-same:01M6M0JBJT09HKXPK93ZPXFX42":103},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":13,"repositoryHtmlUrl":54,"repositoryHomepageUrl":6,"ownerHtmlUrl":55,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":56,"install":57,"resources":70},"01M6M0JBJT09HKXPK93ZPXFX42","pufferlib",null,"High-performance reinforcement learning framework optimized for speed and scale. Use when you need fast parallel training, vectorized environments, multi-agent systems, or integration with game environments (Atari, Procgen, NetHack). Achieves 2-10x speedups over standard implementations. For quick prototyping or standard algorithm implementations with extensive documentation, use stable-baselines3 instead.","endman100\u002Fskill-router-nexus","endman100","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F31997019?v=4","01M6KPDX17BYDWW4RRB0TNGGMX","01M6KPDX64Y2QBEWVFG5W5PWPF",0,"MIT","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[5,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"parallel","when","for","environments","you","quick","with","prototyping","high-performance","speed","use","performance","multi-agent","10x","game","learning","vectorized","framework","training","documentation","2026-11-10 10:12:30",false,"---\nname: pufferlib\ndescription: High-performance reinforcement learning framework optimized for speed and scale. Use when you need fast parallel training, vectorized environments, multi-agent systems, or integration with game environments (Atari, Procgen, NetHack). Achieves 2-10x speedups over standard implementations. For quick prototyping or standard algorithm implementations with extensive documentation, use stable-baselines3 instead.\nlicense: MIT license\nmetadata:\n    skill-author: K-Dense Inc.\n---\n\n# PufferLib - High-Performance Reinforcement Learning\n\n## Overview\n\nPufferLib is a high-performance reinforcement learning library designed for fast parallel environment simulation and training. It achieves training at millions of steps per second through optimized vectorization, native multi-agent support, and efficient PPO implementation (PuffeRL). The library provides the Ocean suite of 20+ environments and seamless integration with Gymnasium, PettingZoo, and specialized RL frameworks.\n\n## When to Use This Skill\n\nUse this skill when:\n- **Training RL agents** with PPO on any environment (single or multi-agent)\n- **Creating custom environments** using the PufferEnv API\n- **Optimizing performance** for parallel environment simulation (vectorization)\n- **Integrating existing environments** from Gymnasium, PettingZoo, Atari, Procgen, etc.\n- **Developing policies** with CNN, LSTM, or custom architectures\n- **Scaling RL** to millions of steps per second for faster experimentation\n- **Multi-agent RL** with native multi-agent environment support\n\n## Core Capabilities\n\n### 1. High-Performance Training (PuffeRL)\n\nPuffeRL is PufferLib's optimized PPO+LSTM training algorithm achieving 1M-4M steps\u002Fsecond.\n\n**Quick start training:**\n```bash\n# CLI training\npuffer train procgen-coinrun --train.device cuda --train.learning-rate 3e-4\n\n# Distributed training\ntorchrun --nproc_per_node=4 train.py\n```\n\n**Python training loop:**\n```python\nimport pufferlib\nfrom pufferlib import PuffeRL\n\n# Create vectorized environment\nenv = pufferlib.make('procgen-coinrun', num_envs=256)\n\n# Create trainer\ntrainer = PuffeRL(\n    env=env,\n    policy=my_policy,\n    device='cuda',\n    learning_rate=3e-4,\n    batch_size=32768\n)\n\n# Training loop\nfor iteration in range(num_iterations):\n    trainer.evaluate()  # Collect rollouts\n    trainer.train()     # Train on batch\n    trainer.mean_and_log()  # Log results\n```\n\n**For comprehensive training guidance**, read `references\u002Ftraining.md` for:\n- Complete training workflow and CLI options\n- Hyperparameter tuning with Protein\n- Distributed multi-GPU\u002Fmulti-node training\n- Logger integration (Weights & Biases, Neptune)\n- Checkpointing and resume training\n- Performance optimization tips\n- Curriculum learning patterns\n\n### 2. Environment Development (PufferEnv)\n\nCreate custom high-performance environments with the PufferEnv API.\n\n**Basic environment structure:**\n```python\nimport numpy as np\nfrom pufferlib import PufferEnv\n\nclass MyEnvironment(PufferEnv):\n    def __init__(self, buf=None):\n        super().__init__(buf)\n\n        # Define spaces\n        self.observation_space = self.make_space((4,))\n        self.action_space = self.make_discrete(4)\n\n        self.reset()\n\n    def reset(self):\n        # Reset state and return initial observation\n        return np.zeros(4, dtype=np.float32)\n\n    def step(self, action):\n        # Execute action, compute reward, check done\n        obs = self._get_observation()\n        reward = self._compute_reward()\n        done = self._is_done()\n        info = {}\n\n        return obs, reward, done, info\n```\n\n**Use the template script:** `scripts\u002Fenv_template.py` provides complete single-agent and multi-agent environment templates with examples of:\n- Different observation space types (vector, image, dict)\n- Action space variations (discrete, continuous, multi-discrete)\n- Multi-agent environment structure\n- Testing utilities\n\n**For complete environment development**, read `references\u002Fenvironments.md` for:\n- PufferEnv API details and in-place operation patterns\n- Observation and action space definitions\n- Multi-agent environment creation\n- Ocean suite (20+ pre-built environments)\n- Performance optimization (Python to C workflow)\n- Environment wrappers and best practices\n- Debugging and validation techniques\n\n### 3. Vectorization and Performance\n\nAchieve maximum throughput with optimized parallel simulation.\n\n**Vectorization setup:**\n```python\nimport pufferlib\n\n# Automatic vectorization\nenv = pufferlib.make('environment_name', num_envs=256, num_workers=8)\n\n# Performance benchmarks:\n# - Pure Python envs: 100k-500k SPS\n# - C-based envs: 100M+ SPS\n# - With training: 400k-4M total SPS\n```\n\n**Key optimizations:**\n- Shared memory buffers for zero-copy observation passing\n- Busy-wait flags instead of pipes\u002Fqueues\n- Surplus environments for async returns\n- Multiple environments per worker\n\n**For vectorization optimization**, read `references\u002Fvectorization.md` for:\n- Architecture and performance characteristics\n- Worker and batch size configuration\n- Serial vs multiprocessing vs async modes\n- Shared memory and zero-copy patterns\n- Hierarchical vectorization for large scale\n- Multi-agent vectorization strategies\n- Performance profiling and troubleshooting\n\n### 4. Policy Development\n\nBuild policies as standard PyTorch modules with optional utilities.\n\n**Basic policy structure:**\n```python\nimport torch.nn as nn\nfrom pufferlib.pytorch import layer_init\n\nclass Policy(nn.Module):\n    def __init__(self, observation_space, action_space):\n        super().__init__()\n\n        # Encoder\n        self.encoder = nn.Sequential(\n            layer_init(nn.Linear(obs_dim, 256)),\n            nn.ReLU(),\n            layer_init(nn.Linear(256, 256)),\n            nn.ReLU()\n        )\n\n        # Actor and critic heads\n        self.actor = layer_init(nn.Linear(256, num_actions), std=0.01)\n        self.critic = layer_init(nn.Linear(256, 1), std=1.0)\n\n    def forward(self, observations):\n        features = self.encoder(observations)\n        return self.actor(features), self.critic(features)\n```\n\n**For complete policy development**, read `references\u002Fpolicies.md` for:\n- CNN policies for image observations\n- Recurrent policies with optimized LSTM (3x faster inference)\n- Multi-input policies for complex observations\n- Continuous action policies\n- Multi-agent policies (shared vs independent parameters)\n- Advanced architectures (attention, residual)\n- Observation normalization and gradient clipping\n- Policy debugging and testing\n\n### 5. Environment Integration\n\nSeamlessly integrate environments from popular RL frameworks.\n\n**Gymnasium integration:**\n```python\nimport gymnasium as gym\nimport pufferlib\n\n# Wrap Gymnasium environment\ngym_env = gym.make('CartPole-v1')\nenv = pufferlib.emulate(gym_env, num_envs=256)\n\n# Or use make directly\nenv = pufferlib.make('gym-CartPole-v1', num_envs=256)\n```\n\n**PettingZoo multi-agent:**\n```python\n# Multi-agent environment\nenv = pufferlib.make('pettingzoo-knights-archers-zombies', num_envs=128)\n```\n\n**Supported frameworks:**\n- Gymnasium \u002F OpenAI Gym\n- PettingZoo (parallel and AEC)\n- Atari (ALE)\n- Procgen\n- NetHack \u002F MiniHack\n- Minigrid\n- Neural MMO\n- Crafter\n- GPUDrive\n- MicroRTS\n- Griddly\n- And more...\n\n**For integration details**, read `references\u002Fintegration.md` for:\n- Complete integration examples for each framework\n- Custom wrappers (observation, reward, frame stacking, action repeat)\n- Space flattening and unflattening\n- Environment registration\n- Compatibility patterns\n- Performance considerations\n- Integration debugging\n\n## Quick Start Workflow\n\n### For Training Existing Environments\n\n1. Choose environment from Ocean suite or compatible framework\n2. Use `scripts\u002Ftrain_template.py` as starting point\n3. Configure hyperparameters for your task\n4. Run training with CLI or Python script\n5. Monitor with Weights & Biases or Neptune\n6. Refer to `references\u002Ftraining.md` for optimization\n\n### For Creating Custom Environments\n\n1. Start with `scripts\u002Fenv_template.py`\n2. Define observation and action spaces\n3. Implement `reset()` and `step()` methods\n4. Test environment locally\n5. Vectorize with `pufferlib.emulate()` or `make()`\n6. Refer to `references\u002Fenvironments.md` for advanced patterns\n7. Optimize with `references\u002Fvectorization.md` if needed\n\n### For Policy Development\n\n1. Choose architecture based on observations:\n   - Vector observations → MLP policy\n   - Image observations → CNN policy\n   - Sequential tasks → LSTM policy\n   - Complex observations → Multi-input policy\n2. Use `layer_init` for proper weight initialization\n3. Follow patterns in `references\u002Fpolicies.md`\n4. Test with environment before full training\n\n### For Performance Optimization\n\n1. Profile current throughput (steps per second)\n2. Check vectorization configuration (num_envs, num_workers)\n3. Optimize environment code (in-place ops, numpy vectorization)\n4. Consider C implementation for critical paths\n5. Use `references\u002Fvectorization.md` for systematic optimization\n\n## Resources\n\n### scripts\u002F\n\n**train_template.py** - Complete training script template with:\n- Environment creation and configuration\n- Policy initialization\n- Logger integration (WandB, Neptune)\n- Training loop with checkpointing\n- Command-line argument parsing\n- Multi-GPU distributed training setup\n\n**env_template.py** - Environment implementation templates:\n- Single-agent PufferEnv example (grid world)\n- Multi-agent PufferEnv example (cooperative navigation)\n- Multiple observation\u002Faction space patterns\n- Testing utilities\n\n### references\u002F\n\n**training.md** - Comprehensive training guide:\n- Training workflow and CLI options\n- Hyperparameter configuration\n- Distributed training (multi-GPU, multi-node)\n- Monitoring and logging\n- Checkpointing\n- Protein hyperparameter tuning\n- Performance optimization\n- Common training patterns\n- Troubleshooting\n\n**environments.md** - Environment development guide:\n- PufferEnv API and characteristics\n- Observation and action spaces\n- Multi-agent environments\n- Ocean suite environments\n- Custom environment development workflow\n- Python to C optimization path\n- Third-party environment integration\n- Wrappers and best practices\n- Debugging\n\n**vectorization.md** - Vectorization optimization:\n- Architecture and key optimizations\n- Vectorization modes (serial, multiprocessing, async)\n- Worker and batch configuration\n- Shared memory and zero-copy patterns\n- Advanced vectorization (hierarchical, custom)\n- Multi-agent vectorization\n- Performance monitoring and profiling\n- Troubleshooting and best practices\n\n**policies.md** - Policy architecture guide:\n- Basic policy structure\n- CNN policies for images\n- LSTM policies with optimization\n- Multi-input policies\n- Continuous action policies\n- Multi-agent policies\n- Advanced architectures (attention, residual)\n- Observation processing and unflattening\n- Initialization and normalization\n- Debugging and testing\n\n**integration.md** - Framework integration guide:\n- Gymnasium integration\n- PettingZoo integration (parallel and AEC)\n- Third-party environments (Procgen, NetHack, Minigrid, etc.)\n- Custom wrappers (observation, reward, frame stacking, etc.)\n- Space conversion and unflattening\n- Environment registration\n- Compatibility patterns\n- Performance considerations\n- Debugging integration\n\n## Tips for Success\n\n1. **Start simple**: Begin with Ocean environments or Gymnasium integration before creating custom environments\n\n2. **Profile early**: Measure steps per second from the start to identify bottlenecks\n\n3. **Use templates**: `scripts\u002Ftrain_template.py` and `scripts\u002Fenv_template.py` provide solid starting points\n\n4. **Read references as needed**: Each reference file is self-contained and focused on a specific capability\n\n5. **Optimize progressively**: Start with Python, profile, then optimize critical paths with C if needed\n\n6. **Leverage vectorization**: PufferLib's vectorization is key to achieving high throughput\n\n7. **Monitor training**: Use WandB or Neptune to track experiments and identify issues early\n\n8. **Test environments**: Validate environment logic before scaling up training\n\n9. **Check existing environments**: Ocean suite provides 20+ pre-built environments\n\n10. **Use proper initialization**: Always use `layer_init` from `pufferlib.pytorch` for policies\n\n## Common Use Cases\n\n### Training on Standard Benchmarks\n```python\n# Atari\nenv = pufferlib.make('atari-pong', num_envs=256)\n\n# Procgen\nenv = pufferlib.make('procgen-coinrun', num_envs=256)\n\n# Minigrid\nenv = pufferlib.make('minigrid-empty-8x8', num_envs=256)\n```\n\n### Multi-Agent Learning\n```python\n# PettingZoo\nenv = pufferlib.make('pettingzoo-pistonball', num_envs=128)\n\n# Shared policy for all agents\npolicy = create_policy(env.observation_space, env.action_space)\ntrainer = PuffeRL(env=env, policy=policy)\n```\n\n### Custom Task Development\n```python\n# Create custom environment\nclass MyTask(PufferEnv):\n    # ... implement environment ...\n\n# Vectorize and train\nenv = pufferlib.emulate(MyTask, num_envs=256)\ntrainer = PuffeRL(env=env, policy=my_policy)\n```\n\n### High-Performance Optimization\n```python\n# Maximize throughput\nenv = pufferlib.make(\n    'my-env',\n    num_envs=1024,      # Large batch\n    num_workers=16,     # Many workers\n    envs_per_worker=64  # Optimize per worker\n)\n```\n\n## Installation\n\n```bash\nuv pip install pufferlib\n```\n\n## Documentation\n\n- Official docs: https:\u002F\u002Fpuffer.ai\u002Fdocs.html\n- GitHub: https:\u002F\u002Fgithub.com\u002FPufferAI\u002FPufferLib\n- Discord: Community support available\n\n","# PufferLib - High-Performance Reinforcement Learning\n\n## Overview\n\nPufferLib is a high-performance reinforcement learning library designed for fast parallel environment simulation and training. It achieves training at millions of steps per second through optimized vectorization, native multi-agent support, and efficient PPO implementation (PuffeRL). The library provides the Ocean suite of 20+ environments and seamless integration with Gymnasium, PettingZoo, and specialized RL frameworks.\n\n## When to Use This Skill\n\nUse this skill when:\n- **Training RL agents** with PPO on any environment (single or multi-agent)\n- **Creating custom environments** using the PufferEnv API\n- **Optimizing performance** for parallel environment simulation (vectorization)\n- **Integrating existing environments** from Gymnasium, PettingZoo, Atari, Procgen, etc.\n- **Developing policies** with CNN, LSTM, or custom architectures\n- **Scaling RL** to millions of steps per second for faster experimentation\n- **Multi-agent RL** with native multi-agent environment support\n\n## Core Capabilities\n\n### 1. High-Performance Training (PuffeRL)\n\nPuffeRL is PufferLib's optimized PPO+LSTM training algorithm achieving 1M-4M steps\u002Fsecond.\n\n**Quick start training:**\n```bash\n# CLI training\npuffer train procgen-coinrun --train.device cuda --train.learning-rate 3e-4\n\n# Distributed training\ntorchrun --nproc_per_node=4 train.py\n```\n\n**Python training loop:**\n```python\nimport pufferlib\nfrom pufferlib import PuffeRL\n\n# Create vectorized environment\nenv = pufferlib.make('procgen-coinrun', num_envs=256)\n\n# Create trainer\ntrainer = PuffeRL(\n    env=env,\n    policy=my_policy,\n    device='cuda',\n    learning_rate=3e-4,\n    batch_size=32768\n)\n\n# Training loop\nfor iteration in range(num_iterations):\n    trainer.evaluate()  # Collect rollouts\n    trainer.train()     # Train on batch\n    trainer.mean_and_log()  # Log results\n```\n\n**For comprehensive training guidance**, read `references\u002Ftraining.md` for:\n- Complete training workflow and CLI options\n- Hyperparameter tuning with Protein\n- Distributed multi-GPU\u002Fmulti-node training\n- Logger integration (Weights & Biases, Neptune)\n- Checkpointing and resume training\n- Performance optimization tips\n- Curriculum learning patterns\n\n### 2. Environment Development (PufferEnv)\n\nCreate custom high-performance environments with the PufferEnv API.\n\n**Basic environment structure:**\n```python\nimport numpy as np\nfrom pufferlib import PufferEnv\n\nclass MyEnvironment(PufferEnv):\n    def __init__(self, buf=None):\n        super().__init__(buf)\n\n        # Define spaces\n        self.observation_space = self.make_space((4,))\n        self.action_space = self.make_discrete(4)\n\n        self.reset()\n\n    def reset(self):\n        # Reset state and return initial observation\n        return np.zeros(4, dtype=np.float32)\n\n    def step(self, action):\n        # Execute action, compute reward, check done\n        obs = self._get_observation()\n        reward = self._compute_reward()\n        done = self._is_done()\n        info = {}\n\n        return obs, reward, done, info\n```\n\n**Use the template script:** `scripts\u002Fenv_template.py` provides complete single-agent and multi-agent environment templates with examples of:\n- Different observation space types (vector, image, dict)\n- Action space variations (discrete, continuous, multi-discrete)\n- Multi-agent environment structure\n- Testing utilities\n\n**For complete environment development**, read `references\u002Fenvironments.md` for:\n- PufferEnv API details and in-place operation patterns\n- Observation and action space definitions\n- Multi-agent environment creation\n- Ocean suite (20+ pre-built environments)\n- Performance optimization (Python to C workflow)\n- Environment wrappers and best practices\n- Debugging and validation techniques\n\n### 3. Vectorization and Performance\n\nAchieve maximum throughput with optimized parallel simulation.\n\n**Vectorization setup:**\n```python\nimport pufferlib\n\n# Automatic vectorization\nenv = pufferlib.make('environment_name', num_envs=256, num_workers=8)\n\n# Performance benchmarks:\n# - Pure Python envs: 100k-500k SPS\n# - C-based envs: 100M+ SPS\n# - With training: 400k-4M total SPS\n```\n\n**Key optimizations:**\n- Shared memory buffers for zero-copy observation passing\n- Busy-wait flags instead of pipes\u002Fqueues\n- Surplus environments for async returns\n- Multiple environments per worker\n\n**For vectorization optimization**, read `references\u002Fvectorization.md` for:\n- Architecture and performance characteristics\n- Worker and batch size configuration\n- Serial vs multiprocessing vs async modes\n- Shared memory and zero-copy patterns\n- Hierarchical vectorization for large scale\n- Multi-agent vectorization strategies\n- Performance profiling and troubleshooting\n\n### 4. Policy Development\n\nBuild policies as standard PyTorch modules with optional utilities.\n\n**Basic policy structure:**\n```python\nimport torch.nn as nn\nfrom pufferlib.pytorch import layer_init\n\nclass Policy(nn.Module):\n    def __init__(self, observation_space, action_space):\n        super().__init__()\n\n        # Encoder\n        self.encoder = nn.Sequential(\n            layer_init(nn.Linear(obs_dim, 256)),\n            nn.ReLU(),\n            layer_init(nn.Linear(256, 256)),\n            nn.ReLU()\n        )\n\n        # Actor and critic heads\n        self.actor = layer_init(nn.Linear(256, num_actions), std=0.01)\n        self.critic = layer_init(nn.Linear(256, 1), std=1.0)\n\n    def forward(self, observations):\n        features = self.encoder(observations)\n        return self.actor(features), self.critic(features)\n```\n\n**For complete policy development**, read `references\u002Fpolicies.md` for:\n- CNN policies for image observations\n- Recurrent policies with optimized LSTM (3x faster inference)\n- Multi-input policies for complex observations\n- Continuous action policies\n- Multi-agent policies (shared vs independent parameters)\n- Advanced architectures (attention, residual)\n- Observation normalization and gradient clipping\n- Policy debugging and testing\n\n### 5. Environment Integration\n\nSeamlessly integrate environments from popular RL frameworks.\n\n**Gymnasium integration:**\n```python\nimport gymnasium as gym\nimport pufferlib\n\n# Wrap Gymnasium environment\ngym_env = gym.make('CartPole-v1')\nenv = pufferlib.emulate(gym_env, num_envs=256)\n\n# Or use make directly\nenv = pufferlib.make('gym-CartPole-v1', num_envs=256)\n```\n\n**PettingZoo multi-agent:**\n```python\n# Multi-agent environment\nenv = pufferlib.make('pettingzoo-knights-archers-zombies', num_envs=128)\n```\n\n**Supported frameworks:**\n- Gymnasium \u002F OpenAI Gym\n- PettingZoo (parallel and AEC)\n- Atari (ALE)\n- Procgen\n- NetHack \u002F MiniHack\n- Minigrid\n- Neural MMO\n- Crafter\n- GPUDrive\n- MicroRTS\n- Griddly\n- And more...\n\n**For integration details**, read `references\u002Fintegration.md` for:\n- Complete integration examples for each framework\n- Custom wrappers (observation, reward, frame stacking, action repeat)\n- Space flattening and unflattening\n- Environment registration\n- Compatibility patterns\n- Performance considerations\n- Integration debugging\n\n## Quick Start Workflow\n\n### For Training Existing Environments\n\n1. Choose environment from Ocean suite or compatible framework\n2. Use `scripts\u002Ftrain_template.py` as starting point\n3. Configure hyperparameters for your task\n4. Run training with CLI or Python script\n5. Monitor with Weights & Biases or Neptune\n6. Refer to `references\u002Ftraining.md` for optimization\n\n### For Creating Custom Environments\n\n1. Start with `scripts\u002Fenv_template.py`\n2. Define observation and action spaces\n3. Implement `reset()` and `step()` methods\n4. Test environment locally\n5. Vectorize with `pufferlib.emulate()` or `make()`\n6. Refer to `references\u002Fenvironments.md` for advanced patterns\n7. Optimize with `references\u002Fvectorization.md` if needed\n\n### For Policy Development\n\n1. Choose architecture based on observations:\n   - Vector observations → MLP policy\n   - Image observations → CNN policy\n   - Sequential tasks → LSTM policy\n   - Complex observations → Multi-input policy\n2. Use `layer_init` for proper weight initialization\n3. Follow patterns in `references\u002Fpolicies.md`\n4. Test with environment before full training\n\n### For Performance Optimization\n\n1. Profile current throughput (steps per second)\n2. Check vectorization configuration (num_envs, num_workers)\n3. Optimize environment code (in-place ops, numpy vectorization)\n4. Consider C implementation for critical paths\n5. Use `references\u002Fvectorization.md` for systematic optimization\n\n## Resources\n\n### scripts\u002F\n\n**train_template.py** - Complete training script template with:\n- Environment creation and configuration\n- Policy initialization\n- Logger integration (WandB, Neptune)\n- Training loop with checkpointing\n- Command-line argument parsing\n- Multi-GPU distributed training setup\n\n**env_template.py** - Environment implementation templates:\n- Single-agent PufferEnv example (grid world)\n- Multi-agent PufferEnv example (cooperative navigation)\n- Multiple observation\u002Faction space patterns\n- Testing utilities\n\n### references\u002F\n\n**training.md** - Comprehensive training guide:\n- Training workflow and CLI options\n- Hyperparameter configuration\n- Distributed training (multi-GPU, multi-node)\n- Monitoring and logging\n- Checkpointing\n- Protein hyperparameter tuning\n- Performance optimization\n- Common training patterns\n- Troubleshooting\n\n**environments.md** - Environment development guide:\n- PufferEnv API and characteristics\n- Observation and action spaces\n- Multi-agent environments\n- Ocean suite environments\n- Custom environment development workflow\n- Python to C optimization path\n- Third-party environment integration\n- Wrappers and best practices\n- Debugging\n\n**vectorization.md** - Vectorization optimization:\n- Architecture and key optimizations\n- Vectorization modes (serial, multiprocessing, async)\n- Worker and batch configuration\n- Shared memory and zero-copy patterns\n- Advanced vectorization (hierarchical, custom)\n- Multi-agent vectorization\n- Performance monitoring and profiling\n- Troubleshooting and best practices\n\n**policies.md** - Policy architecture guide:\n- Basic policy structure\n- CNN policies for images\n- LSTM policies with optimization\n- Multi-input policies\n- Continuous action policies\n- Multi-agent policies\n- Advanced architectures (attention, residual)\n- Observation processing and unflattening\n- Initialization and normalization\n- Debugging and testing\n\n**integration.md** - Framework integration guide:\n- Gymnasium integration\n- PettingZoo integration (parallel and AEC)\n- Third-party environments (Procgen, NetHack, Minigrid, etc.)\n- Custom wrappers (observation, reward, frame stacking, etc.)\n- Space conversion and unflattening\n- Environment registration\n- Compatibility patterns\n- Performance considerations\n- Debugging integration\n\n## Tips for Success\n\n1. **Start simple**: Begin with Ocean environments or Gymnasium integration before creating custom environments\n\n2. **Profile early**: Measure steps per second from the start to identify bottlenecks\n\n3. **Use templates**: `scripts\u002Ftrain_template.py` and `scripts\u002Fenv_template.py` provide solid starting points\n\n4. **Read references as needed**: Each reference file is self-contained and focused on a specific capability\n\n5. **Optimize progressively**: Start with Python, profile, then optimize critical paths with C if needed\n\n6. **Leverage vectorization**: PufferLib's vectorization is key to achieving high throughput\n\n7. **Monitor training**: Use WandB or Neptune to track experiments and identify issues early\n\n8. **Test environments**: Validate environment logic before scaling up training\n\n9. **Check existing environments**: Ocean suite provides 20+ pre-built environments\n\n10. **Use proper initialization**: Always use `layer_init` from `pufferlib.pytorch` for policies\n\n## Common Use Cases\n\n### Training on Standard Benchmarks\n```python\n# Atari\nenv = pufferlib.make('atari-pong', num_envs=256)\n\n# Procgen\nenv = pufferlib.make('procgen-coinrun', num_envs=256)\n\n# Minigrid\nenv = pufferlib.make('minigrid-empty-8x8', num_envs=256)\n```\n\n### Multi-Agent Learning\n```python\n# PettingZoo\nenv = pufferlib.make('pettingzoo-pistonball', num_envs=128)\n\n# Shared policy for all agents\npolicy = create_policy(env.observation_space, env.action_space)\ntrainer = PuffeRL(env=env, policy=policy)\n```\n\n### Custom Task Development\n```python\n# Create custom environment\nclass MyTask(PufferEnv):\n    # ... implement environment ...\n\n# Vectorize and train\nenv = pufferlib.emulate(MyTask, num_envs=256)\ntrainer = PuffeRL(env=env, policy=my_policy)\n```\n\n### High-Performance Optimization\n```python\n# Maximize throughput\nenv = pufferlib.make(\n    'my-env',\n    num_envs=1024,      # Large batch\n    num_workers=16,     # Many workers\n    envs_per_worker=64  # Optimize per worker\n)\n```\n\n## Installation\n\n```bash\nuv pip install pufferlib\n```\n\n## Documentation\n\n- Official docs: https:\u002F\u002Fpuffer.ai\u002Fdocs.html\n- GitHub: https:\u002F\u002Fgithub.com\u002FPufferAI\u002FPufferLib\n- Discord: Community support available\n\n",{"name":5,"license":48,"metadata":49,"description":7},"MIT license",{"skill-author":50},"K-Dense Inc.","main","f19b254e8975d0bfddb394686706106930d7964d","Science\u002Fscientific-data-and-ml\u002Fpufferlib","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus","https:\u002F\u002Fgithub.com\u002Fendman100","2026-11-12 18:13:37",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add endman100\u002Fskill-router-nexus --skill pufferlib",{"tool":63,"command":64},"bunx","bunx skills add endman100\u002Fskill-router-nexus --skill pufferlib",{"tool":66,"command":67},"pnpm","pnpm dlx skills add endman100\u002Fskill-router-nexus --skill pufferlib","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002FSKILL.md",true,[71,77,81,85,89,93,99],{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fenvironments.md","REFERENCE","参考文档",12489,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Freferences\u002Fenvironments.md",{"path":78,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":79,"sourceHtmlUrl":80},"references\u002Fintegration.md",15165,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Freferences\u002Fintegration.md",{"path":82,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Fpolicies.md",19183,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Freferences\u002Fpolicies.md",{"path":86,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Ftraining.md",8127,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Freferences\u002Ftraining.md",{"path":90,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fvectorization.md",12962,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Freferences\u002Fvectorization.md",{"path":94,"resourceType":95,"resourceTypeDesc":96,"sizeBytes":97,"sourceHtmlUrl":98},"scripts\u002Fenv_template.py","SCRIPT","脚本",10157,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Fscripts\u002Fenv_template.py",{"path":100,"resourceType":95,"resourceTypeDesc":96,"sizeBytes":101,"sourceHtmlUrl":102},"scripts\u002Ftrain_template.py",8027,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FScience\u002Fscientific-data-and-ml\u002Fpufferlib\u002Fscripts\u002Ftrain_template.py",[104,128,160,182,191,215],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":108,"sourceHtmlUrl":109,"categories":110,"keywords":116,"publishedAt":43},"01M6MPCT5BXVER8HQZTW3QE9AS","create-master","基于佛教经典文献，生成特定高僧大德的 AI 教学角色","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FMetaphysics-and-Spirituality\u002FMaster-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FMetaphysics-and-Spirituality\u002FMaster-skill\u002FSKILL.md",[111],{"categoryNo":112,"categoryName":113,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000039","教师与教育","PROFESSION","适用职业",[117,118,119,120,121,122,123,124,125,126,127],"create master","master","create","生成","true","webfetch","edit","write","read","grep","Bash",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":132,"sourceHtmlUrl":133,"categories":134,"keywords":142,"publishedAt":43},"01M6M43AKE95Y64E1JRXEF5QQ3","writing-dna-skill","从至少 20 篇完整文章中蒸馏可复用的写作 DNA，分析语言、文章结构、选题逻辑、素材策略、认知框架和视觉风格，并生成 Writing-DNA.md；按该 DNA 写作时会读取全部蒸馏产物和 5 篇相关原文。用于中英文作者、账号、品牌或出版物的风格分析与一致性写作。 Distill reusable Writing DNA from at least 20 complete articles for Chinese or English authors, publications, brands, and accounts; use for language, structure, topic logic, source strategy, cognitive-frame, and visual-style analysis.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fwriting-dna-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fwriting-dna-skill\u002FSKILL.md",[135,138,139],{"categoryNo":136,"categoryName":137,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":140,"categoryName":141,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000036","内容创作者",[143,144,145,146,147,148,149,150,151,152,33,153,154,120,155,156,157,25,158,159],"writing dna skill","DNA","writing","strategy","english","logic","visual","structure","chinese","reusable","style","distill","analysis","frame","source","at","complete",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":164,"sourceHtmlUrl":165,"categories":166,"keywords":169,"publishedAt":43},"01M6M428TTCGQ4ME3KY99VN037","stop-slop","Remove AI writing patterns from prose. Use when drafting, editing, or reviewing text to eliminate predictable AI tells.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fstop-slop\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fstop-slop\u002FSKILL.md",[167,168],{"categoryNo":136,"categoryName":137,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":140,"categoryName":141,"taxonomyType":114,"taxonomyTypeDesc":115},[170,171,172,173,24,174,175,176,177,33,178,179,180,25,181,145],"slop","stop slop","stop","drafting","drafts","https","patterns","prose","remove","editing","text","content",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":186,"sourceHtmlUrl":187,"categories":188,"keywords":189,"publishedAt":43},"01M6M41X0B7EBX42TK435DMGGR","shuorenhua","检查和清理中英文文本里的 AI 套路，适用于“去 AI 味”“说人话”“自然一点”“别像模板”“先标问题”这类改写和审稿需求；按场景控制力度，同时保留事实、术语、语域和责任主体。","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fshuorenhua\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fshuorenhua\u002FSKILL.md",[],[184,190],"文本",{"skillNo":192,"name":193,"nameZh":6,"description":194,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":195,"sourceHtmlUrl":196,"categories":197,"keywords":198,"publishedAt":43},"01M6M3ZD12WBEW5KXKDM4N6DFG","naming","Name products, SaaS, brands, open source projects, bots, and apps. Use when the user needs to name something, find a brand name, or pick a product name. Metaphor-driven process that produces memorable, meaningful names and avoids AI slop.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fnaming-main\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fnaming-main\u002FSKILL.md",[],[193,199,200,201,202,203,33,204,125,157,205,206,207,208,127,209,210,211,212,24,213,214,170],"repo","websearch","product name","apps","bots","view","brand","pick","gh","projects","open","saas","open source","product","describe","ai slop",{"skillNo":216,"name":217,"nameZh":6,"description":218,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":219,"sourceHtmlUrl":220,"categories":221,"keywords":223,"publishedAt":43},"01M6M3YVXAFAAWJ7F6JMPFREYE","humanizer-zh","去除文本中的 AI 生成痕迹。适用于编辑或审阅文本，使其听起来更自然、更像人类书写。\n基于维基百科的\"AI 写作特征\"综合指南。检测并修复以下模式：夸大的象征意义、\n宣传性语言、以 -ing 结尾的肤浅分析、模糊的归因、破折号过度使用、三段式法则、\nAI 词汇、否定式排比、过多的连接性短语。","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fhumanizer-zh\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fhumanizer-zh\u002FSKILL.md",[222],{"categoryNo":136,"categoryName":137,"taxonomyType":20,"taxonomyTypeDesc":21},[224,225,226,125,124,123,145,120,190,227,170,172],"humanizer","zh","humanizer zh","翻译"]