{"library":"pytorch-ranger","title":"PyTorch Ranger Optimizer","description":"Ranger is a synergistic PyTorch optimizer that combines Rectified Adam (RAdam) and LookAhead techniques to improve training stability and convergence in deep learning models. The PyPI package, `pytorch-ranger`, provides an implementation of this optimizer, though its last update was in March 2020. More recent developments and features are primarily found in the original author's GitHub repository or the `Ranger21` project.","language":"python","status":"maintenance","last_verified":"Mon May 18","install":{"commands":["pip install pytorch-ranger"],"cli":null},"imports":["from pytorch_ranger import Ranger"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import torch\nimport torch.nn as nn\nfrom pytorch_ranger import Ranger\n\n# 1. Define a simple PyTorch model\nclass SimpleModel(nn.Module):\n    def __init__(self):\n        super().__init__()\n        self.linear = nn.Linear(10, 1)\n\n    def forward(self, x):\n        return self.linear(x)\n\nmodel = SimpleModel()\n\n# 2. Define dummy data and target\ninputs = torch.randn(32, 10) # Example batch of 32 samples, 10 features\ntargets = torch.randn(32, 1) # Example batch of 32 targets\n\n# 3. Instantiate the Ranger optimizer\n# Pass model.parameters() to the optimizer\noptimizer = Ranger(model.parameters(), lr=0.001)\n\n# 4. Define a loss function\ncriterion = nn.MSELoss()\n\n# 5. Perform a single training step (in a real scenario, this would be in a loop)\noptimizer.zero_grad() # Zero the gradients\noutputs = model(inputs) # Forward pass\nloss = criterion(outputs, targets) # Compute loss\nloss.backward() # Backward pass (compute gradients)\noptimizer.step() # Update model parameters\n\nprint(f\"Loss after one step: {loss.item():.4f}\")","lang":"python","description":"This quickstart demonstrates how to initialize a `Ranger` optimizer with a simple PyTorch model's parameters and perform a single forward and backward pass, followed by an optimization step.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"0.1.1","pypi_latest":"0.1.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":40,"avg_install_s":65.1,"avg_import_s":5.32,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pytorch-ranger","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pytorch-ranger","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":73.6,"import_time_s":3.64,"mem_mb":59.2,"disk_size":"4.6G"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pytorch-ranger","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pytorch-ranger","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":66,"import_time_s":6.15,"mem_mb":64,"disk_size":"4.7G"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pytorch-ranger","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pytorch-ranger","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":63.5,"import_time_s":6.15,"mem_mb":63,"disk_size":"4.7G"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pytorch-ranger","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pytorch-ranger","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":57.2,"import_time_s":5.33,"mem_mb":63.5,"disk_size":"4.7G"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pytorch-ranger","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pytorch-ranger","exit_code":1,"wheel_type":null,"failure_reason":"timeout","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}