-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Current File", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${file}", | ||
"console": "integratedTerminal", | ||
"justMyCode": true, | ||
"subProcess": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,54 @@ | ||
import pytest | ||
import torch | ||
from torch import nn | ||
|
||
from pipegoose.nn.pipeline_parallel2._worker import WorkerManager | ||
from pipegoose.nn.pipeline_parallel2.pipeline_engine import PipelineEngine | ||
from pipegoose.nn.pipeline_parallel2.scheduler import GPipeScheduler | ||
from pipegoose.testing.utils import init_parallel_context, spawn | ||
|
||
class FakeParallelContext: | ||
pass | ||
model = nn.Sequential( | ||
nn.Linear(5, 5), | ||
nn.ReLU(), | ||
nn.Linear(5, 5), | ||
) | ||
|
||
|
||
@pytest.mark.skip | ||
def test_pipeline_engine(model): | ||
# BATCH_SIZE = 32 | ||
# parallel_context = FakeParallelContext() | ||
# torch.randn(BATCH_SIZE, 4) | ||
def run_pipeline_engine(rank, world_size, port, tensor_parallel_size, pipeline_parallel_size, data_parallel_size): | ||
BATCH_SIZE = 32 | ||
SEQ_LEN = 10 | ||
HIDDEN_DIM = 5 | ||
|
||
# pipeline_engine = PipelineEngine( | ||
# module=model, | ||
# scheduler=GPipeScheduler(), | ||
# worker_manager=WorkerManager(), | ||
# parallel_context=parallel_context, | ||
# ) | ||
pass | ||
N_MICROBATCHES = 6 | ||
|
||
inputs = torch.randn(BATCH_SIZE, SEQ_LEN, HIDDEN_DIM) | ||
scheduler = GPipeScheduler(N_MICROBATCHES, pipeline_parallel_size) | ||
worker_manager = WorkerManager() | ||
parallel_context = init_parallel_context( | ||
rank, world_size, port, tensor_parallel_size, pipeline_parallel_size, data_parallel_size | ||
) | ||
|
||
pipeline_engine = PipelineEngine( | ||
module=model, | ||
scheduler=scheduler, | ||
worker_manager=worker_manager, | ||
parallel_context=parallel_context, | ||
) | ||
|
||
pipeline_engine.run(inputs) | ||
|
||
# assert torch.allclose(outputs, model(inputs)) | ||
|
||
|
||
@pytest.mark.parametrize("pipeline_parallel_size", [1, 2]) | ||
def test_pipeline_engine(pipeline_parallel_size): | ||
DATA_PARALLEL_SIZE = 1 | ||
TENSOR_PARALLEL_SIZE = 1 | ||
|
||
spawn( | ||
run_pipeline_engine, | ||
world_size=pipeline_parallel_size, | ||
tensor_parallel_size=TENSOR_PARALLEL_SIZE, | ||
pipeline_parallel_size=pipeline_parallel_size, | ||
data_parallel_size=DATA_PARALLEL_SIZE, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters