Skip to content

Commit

Permalink
Make IR private (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwen2501 authored May 2, 2024
1 parent f018a52 commit 6b19ff5
Show file tree
Hide file tree
Showing 43 changed files with 45 additions and 46 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ mn = MyNetwork(in_dim, layer_dims).to(device)

This network is written as free-form Python code; it has not been modified for any specific parallelism technique.

Let us see our first usage of the `pippy.IR.Pipe` interface:
Let us see our first usage of the `pippy.Pipe` interface:

```python
from pippy import pipeline
from pippy.IR import annotate_split_points, Pipe, SplitPoint
from pippy import pipeline, annotate_split_points, Pipe, SplitPoint

annotate_split_points(mn, {'layer0': SplitPoint.END,
'layer1': SplitPoint.END})
Expand Down
2 changes: 1 addition & 1 deletion examples/checkpoint/toy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pippy.compile import compile_stage

from pippy.SaveModule import save_checkpoint
from pippy.IR import pipe_split
from pippy import pipe_split
from torch.utils.data import Dataset, random_split


Expand Down
2 changes: 1 addition & 1 deletion examples/cpu_init/gpt2_cpu_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_albert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_bart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_blenderbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_camemBert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_convBert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_deberta.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_debertaV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_distilBert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_fnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_gpt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_gptNeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_layoutLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_m2m100.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_mbart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_megatronBert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_mobileBert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_mt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_pegasus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_plBart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_t5.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_trOCR.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/huggingface/pippy_xlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import SplitPoint, annotate_split_points
from pippy import SplitPoint, annotate_split_points
from pippy.PipelineSchedule import ScheduleGPipe
from pippy.PipelineStage import PipelineStage

Expand Down
2 changes: 1 addition & 1 deletion examples/profiling/mlp_profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from torch.profiler import profile, ProfilerActivity

from pippy.compile import compile_stage
from pippy.IR import pipe_split
from pippy import pipe_split


d_hid = 1024
Expand Down
2 changes: 1 addition & 1 deletion examples/tp+pp/pippy_tp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pippy
import pippy.fx
from pippy.IR import pipe_split
from pippy import pipe_split
from pippy.compile import compile_stage

import torch.distributed as dist
Expand Down
2 changes: 1 addition & 1 deletion examples/unrolling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ iteration block:
# Add a split point after each iter_block
annotate_split_points(
model,
{"iter_block": PipeSplitWrapper.SplitPoint.END},
{"iter_block": SplitPoint.END},
)
```

Expand Down
4 changes: 2 additions & 2 deletions examples/unrolling/pippy_unroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch.distributed as dist

from pippy import pipeline
from pippy.IR import annotate_split_points, PipeSplitWrapper, pipeline
from pippy import annotate_split_points, SplitPoint, pipeline
from pippy.PipelineStage import PipelineStage


Expand Down Expand Up @@ -57,7 +57,7 @@ def forward(self, x):
# Add a split point after each iter_block
annotate_split_points(
model,
{"iter_block": PipeSplitWrapper.SplitPoint.END},
{"iter_block": SplitPoint.END},
)

batch_size = 32
Expand Down
2 changes: 1 addition & 1 deletion pippy/ModelSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import torch.fx as fx

from .IR import aten_pipe_split_alias
from ._IR import aten_pipe_split_alias


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion pippy/PipelineSchedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import torch.distributed as dist
from torch.profiler import record_function

from .IR import Pipe
from ._IR import Pipe
from .microbatch import merge_chunks, split_args_kwargs_into_chunks
from .PipelineStage import PipelineStageBase

Expand Down
2 changes: 1 addition & 1 deletion pippy/PipelineStage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from ._backward import stage_backward
from ._debug import map_debug_info
from ._IR import Pipe
from ._utils import flatten_args, modify_graph_op_device
from .IR import Pipe

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pippy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
from .IR import (
from ._IR import (
annotate_split_points,
ArgsChunkSpec,
KwargsChunkSpec,
Expand Down
2 changes: 1 addition & 1 deletion test/hf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import torch

import transformers.utils.fx as fx
from pippy.IR import (
from pippy._IR import (
annotate_split_points,
MultiUseParameterConfig,
pipeline,
Expand Down
2 changes: 1 addition & 1 deletion test/local_test_c10d_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import torch
import torch.distributed as dist
from pippy.IR import pipe_split
from pippy._IR import pipe_split
from torch.nn.parallel import DistributedDataParallel


Expand Down
4 changes: 2 additions & 2 deletions test/local_test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import torch.distributed as dist
import torch.optim as optim
from pippy.compile import compile_stage

from pippy.IR import pipe_split, TrivialLossWrapper
from pippy._IR import pipe_split, TrivialLossWrapper
from pippy.compile import compile_stage
from pippy.utilities.hf_checkpoint import load_checkpoint, save_checkpoint


Expand Down
2 changes: 1 addition & 1 deletion test/local_test_null_coalesce_accumulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import torch
from pippy import run_pippy
from pippy.IR import (
from pippy._IR import (
_null_coalesce_accumulate,
pipe_split,
pipeline,
Expand Down
2 changes: 1 addition & 1 deletion test/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import torch

from pippy.IR import (
from pippy._IR import (
_null_coalesce_accumulate,
annotate_split_points,
MultiUseParameterConfig,
Expand Down

0 comments on commit 6b19ff5

Please sign in to comment.