mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-16 06:30:41 +00:00
html refactor (#555)
This commit is contained in:
@@ -21,21 +21,22 @@ class AsyncMemoryMonitor:
|
||||
:type power: int
|
||||
|
||||
Usage:
|
||||
::
|
||||
|
||||
```python
|
||||
async_mem_monitor = AsyncMemoryMonitor()
|
||||
input = torch.randn(2, 20).cuda()
|
||||
OP1 = torch.nn.Linear(20, 30).cuda()
|
||||
OP2 = torch.nn.Linear(30, 40).cuda()
|
||||
```python
|
||||
async_mem_monitor = AsyncMemoryMonitor()
|
||||
input = torch.randn(2, 20).cuda()
|
||||
OP1 = torch.nn.Linear(20, 30).cuda()
|
||||
OP2 = torch.nn.Linear(30, 40).cuda()
|
||||
|
||||
async_mem_monitor.start()
|
||||
output = OP1(input)
|
||||
async_mem_monitor.finish()
|
||||
async_mem_monitor.start()
|
||||
output = OP2(output)
|
||||
async_mem_monitor.finish()
|
||||
async_mem_monitor.save('log.pkl')
|
||||
```
|
||||
async_mem_monitor.start()
|
||||
output = OP1(input)
|
||||
async_mem_monitor.finish()
|
||||
async_mem_monitor.start()
|
||||
output = OP2(output)
|
||||
async_mem_monitor.finish()
|
||||
async_mem_monitor.save('log.pkl')
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(self, power: int = 10):
|
||||
|
@@ -73,25 +73,26 @@ class ProfilerContext(object):
|
||||
"""
|
||||
Profiler context manager
|
||||
Usage:
|
||||
::
|
||||
|
||||
```python
|
||||
world_size = 4
|
||||
inputs = torch.randn(10, 10, dtype=torch.float32, device=get_current_device())
|
||||
outputs = torch.empty(world_size, 10, 10, dtype=torch.float32, device=get_current_device())
|
||||
outputs_list = list(torch.chunk(outputs, chunks=world_size, dim=0))
|
||||
```python
|
||||
world_size = 4
|
||||
inputs = torch.randn(10, 10, dtype=torch.float32, device=get_current_device())
|
||||
outputs = torch.empty(world_size, 10, 10, dtype=torch.float32, device=get_current_device())
|
||||
outputs_list = list(torch.chunk(outputs, chunks=world_size, dim=0))
|
||||
|
||||
cc_prof = CommProfiler()
|
||||
cc_prof = CommProfiler()
|
||||
|
||||
with ProfilerContext([cc_prof]) as prof:
|
||||
op = dist.all_reduce(inputs, async_op=True)
|
||||
dist.all_gather(outputs_list, inputs)
|
||||
op.wait()
|
||||
dist.reduce_scatter(inputs, outputs_list)
|
||||
dist.broadcast(inputs, 0)
|
||||
dist.reduce(inputs, 0)
|
||||
with ProfilerContext([cc_prof]) as prof:
|
||||
op = dist.all_reduce(inputs, async_op=True)
|
||||
dist.all_gather(outputs_list, inputs)
|
||||
op.wait()
|
||||
dist.reduce_scatter(inputs, outputs_list)
|
||||
dist.broadcast(inputs, 0)
|
||||
dist.reduce(inputs, 0)
|
||||
|
||||
prof.show()
|
||||
```
|
||||
prof.show()
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(self, profilers: List[BaseProfiler] = None, enable: bool = True):
|
||||
|
Reference in New Issue
Block a user