RamTorch 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,306 @@
1
+ Metadata-Version: 2.4
2
+ Name: RamTorch
3
+ Version: 0.2.2
4
+ Summary: RAM is All You Need
5
+ Author-email: Lodestone <lodestone.rock@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/lodestone-rock/RamTorch
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: license-file
14
+
15
+ # RamTorch
16
+
17
+ **RAM is All You Need** - A PyTorch library for memory-efficient deep learning that enables training and inference of large models that don't fit in GPU memory.
18
+
19
+ ## Overview
20
+
21
+ RamTorch provides CPU-GPU hybrid implementations of neural network components that keep parameters in CPU memory and transfer them to GPU on-demand. This approach dramatically reduces GPU memory usage while maintaining computational efficiency through asynchronous CUDA streams and intelligent batching.
22
+
23
+ ## Key Features
24
+
25
+ - **Memory-Efficient Linear Layers**: Parameters stored on CPU with on-demand GPU transfer
26
+ - **Asynchronous CUDA Streams**: Overlaps computation with data transfer for minimal latency
27
+ - **ZeRO-Style Distributed Training**:
28
+ - **ZeRO-1**: Optimizer state sharding across multiple GPUs
29
+ - **ZeRO-2**: Gradient sharding with automatic reduction
30
+ - **Shared CPU Memory**: Multi-GPU workers share the same CPU tensor storage
31
+ - **Drop-in Replacement**: Compatible with existing PyTorch code
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install ramtorch
37
+ ```
38
+
39
+ Or install from source:
40
+
41
+ ```bash
42
+ git clone https://github.com/lodestone-rock/RamTorch.git
43
+ cd RamTorch
44
+ pip install -e .
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ### Basic Usage
50
+
51
+ Replace `torch.nn.Linear` with `ramtorch.Linear` for automatic memory optimization:
52
+
53
+ ```python
54
+ import torch
55
+ from ramtorch import Linear
56
+
57
+ # Standard PyTorch approach (high GPU memory usage)
58
+ # linear = torch.nn.Linear(1000, 1000)
59
+
60
+ # RamTorch approach (low GPU memory usage)
61
+ linear = Linear(1000, 1000, device="cuda")
62
+
63
+ # Use exactly like a normal PyTorch layer
64
+ x = torch.randn(32, 1000, device="cuda")
65
+ output = linear(x) # Parameters automatically transferred from CPU to GPU
66
+ ```
67
+
68
+ ### Building Models
69
+
70
+ ```python
71
+ import torch.nn as nn
72
+ from ramtorch import Linear
73
+
74
+ class MemoryEfficientModel(nn.Module):
75
+ def __init__(self):
76
+ super().__init__()
77
+ self.layers = nn.Sequential(
78
+ Linear(1000, 2000),
79
+ nn.ReLU(),
80
+ Linear(2000, 2000),
81
+ nn.ReLU(),
82
+ Linear(2000, 100)
83
+ )
84
+
85
+ def forward(self, x):
86
+ return self.layers(x)
87
+
88
+ model = MemoryEfficientModel()
89
+ ```
90
+
91
+ ### Converting Existing Models
92
+
93
+ Use the helper function to automatically replace all Linear layers:
94
+
95
+ ```python
96
+ from ramtorch.helpers import replace_linear_with_ramtorch
97
+
98
+ # Your existing PyTorch model
99
+ model = YourExistingModel()
100
+
101
+ # Replace all nn.Linear layers with RamTorch Linear layers
102
+ model = replace_linear_with_ramtorch(model, rank=0)
103
+ model = model.to("cuda:0")
104
+ ```
105
+
106
+ ### Multi-GPU Training with ZeRO-1 and ZeRO-2
107
+
108
+ RamTorch implements ZeRO-style optimizations where multiple GPU workers share the same CPU parameter storage, dramatically reducing memory usage:
109
+
110
+ ```python
111
+ import torch
112
+ import torch.distributed as dist
113
+ import torch.multiprocessing as mp
114
+ from torch.utils.data import DataLoader, DistributedSampler
115
+
116
+ from ramtorch import AdamW
117
+ from ramtorch.helpers import replace_linear_with_ramtorch
118
+ from ramtorch.zero1 import create_zero_param_groups, broadcast_zero_params
119
+ from ramtorch.zero2 import setup_grad_sharding_hooks
120
+
121
+ def train(rank, world_size, model):
122
+ # Setup distributed process group
123
+ dist.init_process_group(backend='nccl', rank=rank, world_size=world_size)
124
+ torch.cuda.set_device(rank)
125
+
126
+ # Replace Linear layers with RamTorch (shares CPU memory across workers)
127
+ model = replace_linear_with_ramtorch(model, rank)
128
+ model.to(rank)
129
+
130
+ # Setup ZeRO-1: Shard optimizer states across workers
131
+ # Each worker only maintains optimizer states for a subset of parameters
132
+ all_params = list(model.parameters())
133
+ param_groups = [{'params': all_params, 'lr': 1e-3, 'weight_decay': 0.01}]
134
+ rank_param_groups = create_zero_param_groups(param_groups, world_size)
135
+
136
+ # Setup ZeRO-2: Shard gradients across workers
137
+ # Gradients are partitioned and only linked on the worker responsible for them
138
+ setup_grad_sharding_hooks(rank_param_groups, rank)
139
+
140
+ # Each worker's optimizer only handles its shard
141
+ optimizer = AdamW(rank_param_groups[rank])
142
+
143
+ # Scheduler works normally
144
+ scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=10, gamma=0.1)
145
+
146
+ # Setup distributed data loading
147
+ dataset = YourDataset()
148
+ sampler = DistributedSampler(dataset, num_replicas=world_size, rank=rank)
149
+ loader = DataLoader(dataset, batch_size=32, sampler=sampler)
150
+
151
+ # Training loop
152
+ for epoch in range(num_epochs):
153
+ sampler.set_epoch(epoch) # Important for proper shuffling
154
+
155
+ for batch in loader:
156
+ inputs, targets = batch
157
+ inputs = inputs.to(rank)
158
+ targets = targets.to(rank)
159
+
160
+ # Forward and backward pass
161
+ outputs = model(inputs)
162
+ loss = criterion(outputs, targets) / world_size # Scale loss
163
+
164
+ # Synchronize before backward to ensure all workers are ready
165
+ torch.cuda.synchronize()
166
+ loss.backward()
167
+ torch.cuda.synchronize()
168
+
169
+ # Update parameters (each worker updates only its shard)
170
+ optimizer.step()
171
+
172
+ # Broadcast updated parameters to all workers
173
+ # RamTorch parameters are already shared via CPU memory,
174
+ # but standard PyTorch parameters need explicit broadcasting
175
+ broadcast_zero_params(rank_param_groups)
176
+
177
+ scheduler.step()
178
+
179
+ # IMPORTANT: Use model.zero_grad(), not optimizer.zero_grad()
180
+ # Each worker handles partial gradients, so we need to zero
181
+ # gradients at the model level to properly clear all workers' buffers
182
+ model.zero_grad()
183
+
184
+ torch.cuda.synchronize()
185
+
186
+ dist.destroy_process_group()
187
+
188
+ if __name__ == "__main__":
189
+ world_size = torch.cuda.device_count()
190
+
191
+ # Model must be instantiated BEFORE spawning GPU workers
192
+ # RamTorch shares CPU tensors across workers, so the model needs to exist
193
+ # in the parent process before forking to enable proper memory sharing
194
+ model = YourModel()
195
+
196
+ mp.spawn(train, args=(world_size, model), nprocs=world_size)
197
+ ```
198
+
199
+ ## Performance Considerations
200
+
201
+ ### When to Use RamTorch
202
+
203
+ **Best suited for:**
204
+ - Large models that don't fit in GPU memory
205
+ - Multi-GPU training where memory is the bottleneck
206
+ - Inference scenarios with memory constraints
207
+ - Training with limited GPU memory but abundant CPU memory and bandwidth
208
+ - Distributed training with many parameters
209
+
210
+ **Less suitable for:**
211
+ - Small models that fit comfortably in GPU memory
212
+ - Scenarios where CPU-GPU bandwidth is the bottleneck
213
+ - Real-time applications requiring minimal latency
214
+ - Single-batch inference where transfer overhead dominates
215
+
216
+ ### Optimization Tips
217
+
218
+ 1. **Use Larger Batch Sizes**: Helps amortize transfer costs across more computation
219
+ 2. **Mixed Precision Training**: Combine with `torch.cuda.amp` for additional memory savings
220
+ 3. **Strategic Placement**: Use RamTorch layers for the largest components only
221
+ 4. **Gradient Checkpointing**: Combine with activation checkpointing to further reduce memory
222
+ 5. **Multi-GPU Setup**: RamTorch's shared CPU memory makes multi-GPU training particularly efficient
223
+
224
+ ## Architecture
225
+
226
+ ### CPU-Offloaded Linear Layer
227
+
228
+ The core innovation of RamTorch:
229
+
230
+ 1. Stores parameters on CPU memory with `share_memory_()` for zero-copy sharing across processes
231
+ 2. Asynchronously transfers weights to GPU during forward pass using dedicated CUDA streams
232
+ 3. Uses CUDA events for proper stream synchronization
233
+ 4. Automatically cleans up GPU memory after computation
234
+
235
+ ### Memory Flow
236
+
237
+ ```
238
+ ┌─────────────────────────┐
239
+ │ CPU Memory (Shared) │
240
+ │ Parameters stored once │
241
+ └────────────┬────────────┘
242
+ │
243
+ ┌────────────┴────────────┐
244
+ │ │
245
+ ┌───────▼────────┐ ┌────────▼────────┐
246
+ │ GPU Worker 0 │ │ GPU Worker 1 │
247
+ │ (Async Stream) │ │ (Async Stream) │
248
+ └───────┬────────┘ └────────┬────────┘
249
+ │ │
250
+ │ Compute on GPU │
251
+ │ │
252
+ ┌───────▼────────┐ ┌───────▼─────────┐
253
+ │ Result 0 │ │ Result 1 │
254
+ └────────────────┘ └─────────────────┘
255
+ │ │
256
+ └────────────┬────────────┘
257
+ │
258
+ ┌────────────▼────────────┐
259
+ │ Cleanup GPU Memory │
260
+ └─────────────────────────┘
261
+ ```
262
+
263
+ ### ZeRO-Style Sharding
264
+
265
+ ```
266
+ ┌─────────────────────────────────────────────────────┐
267
+ │ Model Parameters (CPU Shared) │
268
+ │ [P₀, P₁, P₂, P₃, P₄, P₅, P₆, P₇, P₈, P₉, ...] │
269
+ └─────────────────────────────────────────────────────┘
270
+ │
271
+ ┌────────────────┼────────────────┐
272
+ │ │ │
273
+ ┌───────▼────────┐ ┌─────▼────────┐ ┌─────▼────────┐
274
+ │ GPU Worker 0 │ │ GPU Worker 1 │ │ GPU Worker 2 │
275
+ │ (CPU mem map) │ │(CPU mem map) │ │(CPU mem map) │
276
+ │ Optimizer for: │ │ Optimizer for│ │ Optimizer for│
277
+ │ P₀, P₁, P₂ │ │ P₃, P₄, P₅ │ │ P₆, P₇, P₈ │
278
+ │ │ │ │ │ │
279
+ │ Gradients for: │ │ Gradients for│ │ Gradients for│
280
+ │ P₀, P₁, P₂ │ │ P₃, P₄, P₅ │ │ P₆, P₇, P₈ │
281
+ └────────────────┘ └──────────────┘ └──────────────┘
282
+ ```
283
+ ## Contributing
284
+
285
+ We welcome contributions! Please see our contributing guidelines for details.
286
+
287
+ ## License
288
+
289
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
290
+
291
+ ## Citation
292
+
293
+ If you use RamTorch in your research, please cite:
294
+
295
+ ```bibtex
296
+ @software{ramtorch2025,
297
+ author = {Lodestone},
298
+ title = {RamTorch: Memory-Efficient Deep Learning with CPU-GPU Hybrid Architecture},
299
+ url = {https://github.com/lodestone-rock/RamTorch},
300
+ year = {2025}
301
+ }
302
+ ```
303
+
304
+ ## Acknowledgments
305
+
306
+ Built on top of PyTorch's excellent automatic differentiation and CUDA stream management capabilities. Inspired by Microsoft's ZeRO optimizer and DeepSpeed library.
@@ -0,0 +1,292 @@
1
+ # RamTorch
2
+
3
+ **RAM is All You Need** - A PyTorch library for memory-efficient deep learning that enables training and inference of large models that don't fit in GPU memory.
4
+
5
+ ## Overview
6
+
7
+ RamTorch provides CPU-GPU hybrid implementations of neural network components that keep parameters in CPU memory and transfer them to GPU on-demand. This approach dramatically reduces GPU memory usage while maintaining computational efficiency through asynchronous CUDA streams and intelligent batching.
8
+
9
+ ## Key Features
10
+
11
+ - **Memory-Efficient Linear Layers**: Parameters stored on CPU with on-demand GPU transfer
12
+ - **Asynchronous CUDA Streams**: Overlaps computation with data transfer for minimal latency
13
+ - **ZeRO-Style Distributed Training**:
14
+ - **ZeRO-1**: Optimizer state sharding across multiple GPUs
15
+ - **ZeRO-2**: Gradient sharding with automatic reduction
16
+ - **Shared CPU Memory**: Multi-GPU workers share the same CPU tensor storage
17
+ - **Drop-in Replacement**: Compatible with existing PyTorch code
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install ramtorch
23
+ ```
24
+
25
+ Or install from source:
26
+
27
+ ```bash
28
+ git clone https://github.com/lodestone-rock/RamTorch.git
29
+ cd RamTorch
30
+ pip install -e .
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### Basic Usage
36
+
37
+ Replace `torch.nn.Linear` with `ramtorch.Linear` for automatic memory optimization:
38
+
39
+ ```python
40
+ import torch
41
+ from ramtorch import Linear
42
+
43
+ # Standard PyTorch approach (high GPU memory usage)
44
+ # linear = torch.nn.Linear(1000, 1000)
45
+
46
+ # RamTorch approach (low GPU memory usage)
47
+ linear = Linear(1000, 1000, device="cuda")
48
+
49
+ # Use exactly like a normal PyTorch layer
50
+ x = torch.randn(32, 1000, device="cuda")
51
+ output = linear(x) # Parameters automatically transferred from CPU to GPU
52
+ ```
53
+
54
+ ### Building Models
55
+
56
+ ```python
57
+ import torch.nn as nn
58
+ from ramtorch import Linear
59
+
60
+ class MemoryEfficientModel(nn.Module):
61
+ def __init__(self):
62
+ super().__init__()
63
+ self.layers = nn.Sequential(
64
+ Linear(1000, 2000),
65
+ nn.ReLU(),
66
+ Linear(2000, 2000),
67
+ nn.ReLU(),
68
+ Linear(2000, 100)
69
+ )
70
+
71
+ def forward(self, x):
72
+ return self.layers(x)
73
+
74
+ model = MemoryEfficientModel()
75
+ ```
76
+
77
+ ### Converting Existing Models
78
+
79
+ Use the helper function to automatically replace all Linear layers:
80
+
81
+ ```python
82
+ from ramtorch.helpers import replace_linear_with_ramtorch
83
+
84
+ # Your existing PyTorch model
85
+ model = YourExistingModel()
86
+
87
+ # Replace all nn.Linear layers with RamTorch Linear layers
88
+ model = replace_linear_with_ramtorch(model, rank=0)
89
+ model = model.to("cuda:0")
90
+ ```
91
+
92
+ ### Multi-GPU Training with ZeRO-1 and ZeRO-2
93
+
94
+ RamTorch implements ZeRO-style optimizations where multiple GPU workers share the same CPU parameter storage, dramatically reducing memory usage:
95
+
96
+ ```python
97
+ import torch
98
+ import torch.distributed as dist
99
+ import torch.multiprocessing as mp
100
+ from torch.utils.data import DataLoader, DistributedSampler
101
+
102
+ from ramtorch import AdamW
103
+ from ramtorch.helpers import replace_linear_with_ramtorch
104
+ from ramtorch.zero1 import create_zero_param_groups, broadcast_zero_params
105
+ from ramtorch.zero2 import setup_grad_sharding_hooks
106
+
107
+ def train(rank, world_size, model):
108
+ # Setup distributed process group
109
+ dist.init_process_group(backend='nccl', rank=rank, world_size=world_size)
110
+ torch.cuda.set_device(rank)
111
+
112
+ # Replace Linear layers with RamTorch (shares CPU memory across workers)
113
+ model = replace_linear_with_ramtorch(model, rank)
114
+ model.to(rank)
115
+
116
+ # Setup ZeRO-1: Shard optimizer states across workers
117
+ # Each worker only maintains optimizer states for a subset of parameters
118
+ all_params = list(model.parameters())
119
+ param_groups = [{'params': all_params, 'lr': 1e-3, 'weight_decay': 0.01}]
120
+ rank_param_groups = create_zero_param_groups(param_groups, world_size)
121
+
122
+ # Setup ZeRO-2: Shard gradients across workers
123
+ # Gradients are partitioned and only linked on the worker responsible for them
124
+ setup_grad_sharding_hooks(rank_param_groups, rank)
125
+
126
+ # Each worker's optimizer only handles its shard
127
+ optimizer = AdamW(rank_param_groups[rank])
128
+
129
+ # Scheduler works normally
130
+ scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=10, gamma=0.1)
131
+
132
+ # Setup distributed data loading
133
+ dataset = YourDataset()
134
+ sampler = DistributedSampler(dataset, num_replicas=world_size, rank=rank)
135
+ loader = DataLoader(dataset, batch_size=32, sampler=sampler)
136
+
137
+ # Training loop
138
+ for epoch in range(num_epochs):
139
+ sampler.set_epoch(epoch) # Important for proper shuffling
140
+
141
+ for batch in loader:
142
+ inputs, targets = batch
143
+ inputs = inputs.to(rank)
144
+ targets = targets.to(rank)
145
+
146
+ # Forward and backward pass
147
+ outputs = model(inputs)
148
+ loss = criterion(outputs, targets) / world_size # Scale loss
149
+
150
+ # Synchronize before backward to ensure all workers are ready
151
+ torch.cuda.synchronize()
152
+ loss.backward()
153
+ torch.cuda.synchronize()
154
+
155
+ # Update parameters (each worker updates only its shard)
156
+ optimizer.step()
157
+
158
+ # Broadcast updated parameters to all workers
159
+ # RamTorch parameters are already shared via CPU memory,
160
+ # but standard PyTorch parameters need explicit broadcasting
161
+ broadcast_zero_params(rank_param_groups)
162
+
163
+ scheduler.step()
164
+
165
+ # IMPORTANT: Use model.zero_grad(), not optimizer.zero_grad()
166
+ # Each worker handles partial gradients, so we need to zero
167
+ # gradients at the model level to properly clear all workers' buffers
168
+ model.zero_grad()
169
+
170
+ torch.cuda.synchronize()
171
+
172
+ dist.destroy_process_group()
173
+
174
+ if __name__ == "__main__":
175
+ world_size = torch.cuda.device_count()
176
+
177
+ # Model must be instantiated BEFORE spawning GPU workers
178
+ # RamTorch shares CPU tensors across workers, so the model needs to exist
179
+ # in the parent process before forking to enable proper memory sharing
180
+ model = YourModel()
181
+
182
+ mp.spawn(train, args=(world_size, model), nprocs=world_size)
183
+ ```
184
+
185
+ ## Performance Considerations
186
+
187
+ ### When to Use RamTorch
188
+
189
+ **Best suited for:**
190
+ - Large models that don't fit in GPU memory
191
+ - Multi-GPU training where memory is the bottleneck
192
+ - Inference scenarios with memory constraints
193
+ - Training with limited GPU memory but abundant CPU memory and bandwidth
194
+ - Distributed training with many parameters
195
+
196
+ **Less suitable for:**
197
+ - Small models that fit comfortably in GPU memory
198
+ - Scenarios where CPU-GPU bandwidth is the bottleneck
199
+ - Real-time applications requiring minimal latency
200
+ - Single-batch inference where transfer overhead dominates
201
+
202
+ ### Optimization Tips
203
+
204
+ 1. **Use Larger Batch Sizes**: Helps amortize transfer costs across more computation
205
+ 2. **Mixed Precision Training**: Combine with `torch.cuda.amp` for additional memory savings
206
+ 3. **Strategic Placement**: Use RamTorch layers for the largest components only
207
+ 4. **Gradient Checkpointing**: Combine with activation checkpointing to further reduce memory
208
+ 5. **Multi-GPU Setup**: RamTorch's shared CPU memory makes multi-GPU training particularly efficient
209
+
210
+ ## Architecture
211
+
212
+ ### CPU-Offloaded Linear Layer
213
+
214
+ The core innovation of RamTorch:
215
+
216
+ 1. Stores parameters on CPU memory with `share_memory_()` for zero-copy sharing across processes
217
+ 2. Asynchronously transfers weights to GPU during forward pass using dedicated CUDA streams
218
+ 3. Uses CUDA events for proper stream synchronization
219
+ 4. Automatically cleans up GPU memory after computation
220
+
221
+ ### Memory Flow
222
+
223
+ ```
224
+ ┌─────────────────────────┐
225
+ │ CPU Memory (Shared) │
226
+ │ Parameters stored once │
227
+ └────────────┬────────────┘
228
+ │
229
+ ┌────────────┴────────────┐
230
+ │ │
231
+ ┌───────▼────────┐ ┌────────▼────────┐
232
+ │ GPU Worker 0 │ │ GPU Worker 1 │
233
+ │ (Async Stream) │ │ (Async Stream) │
234
+ └───────┬────────┘ └────────┬────────┘
235
+ │ │
236
+ │ Compute on GPU │
237
+ │ │
238
+ ┌───────▼────────┐ ┌───────▼─────────┐
239
+ │ Result 0 │ │ Result 1 │
240
+ └────────────────┘ └─────────────────┘
241
+ │ │
242
+ └────────────┬────────────┘
243
+ │
244
+ ┌────────────▼────────────┐
245
+ │ Cleanup GPU Memory │
246
+ └─────────────────────────┘
247
+ ```
248
+
249
+ ### ZeRO-Style Sharding
250
+
251
+ ```
252
+ ┌─────────────────────────────────────────────────────┐
253
+ │ Model Parameters (CPU Shared) │
254
+ │ [P₀, P₁, P₂, P₃, P₄, P₅, P₆, P₇, P₈, P₉, ...] │
255
+ └─────────────────────────────────────────────────────┘
256
+ │
257
+ ┌────────────────┼────────────────┐
258
+ │ │ │
259
+ ┌───────▼────────┐ ┌─────▼────────┐ ┌─────▼────────┐
260
+ │ GPU Worker 0 │ │ GPU Worker 1 │ │ GPU Worker 2 │
261
+ │ (CPU mem map) │ │(CPU mem map) │ │(CPU mem map) │
262
+ │ Optimizer for: │ │ Optimizer for│ │ Optimizer for│
263
+ │ P₀, P₁, P₂ │ │ P₃, P₄, P₅ │ │ P₆, P₇, P₈ │
264
+ │ │ │ │ │ │
265
+ │ Gradients for: │ │ Gradients for│ │ Gradients for│
266
+ │ P₀, P₁, P₂ │ │ P₃, P₄, P₅ │ │ P₆, P₇, P₈ │
267
+ └────────────────┘ └──────────────┘ └──────────────┘
268
+ ```
269
+ ## Contributing
270
+
271
+ We welcome contributions! Please see our contributing guidelines for details.
272
+
273
+ ## License
274
+
275
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
276
+
277
+ ## Citation
278
+
279
+ If you use RamTorch in your research, please cite:
280
+
281
+ ```bibtex
282
+ @software{ramtorch2025,
283
+ author = {Lodestone},
284
+ title = {RamTorch: Memory-Efficient Deep Learning with CPU-GPU Hybrid Architecture},
285
+ url = {https://github.com/lodestone-rock/RamTorch},
286
+ year = {2025}
287
+ }
288
+ ```
289
+
290
+ ## Acknowledgments
291
+
292
+ Built on top of PyTorch's excellent automatic differentiation and CUDA stream management capabilities. Inspired by Microsoft's ZeRO optimizer and DeepSpeed library.