Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some typos (eqaution_graph_view, GetValueOfRewritedOps, etc.) #61633

Merged
merged 10 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions paddle/cinn/adt/generate_map_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ hlir::framework::OpPatternKind GetOpPatternKind(const ::pir::Operation* node) {
return hlir::framework::pir::CompatibleInfo::OpKind(*node);
}

bool CollectRewritedReductionOpStmts(const OpStmt& op_stmt, List<OpStmt>* ret) {
bool CollectRewrittenReductionOpStmts(const OpStmt& op_stmt,
List<OpStmt>* ret) {
const auto& [op, inputs, outputs] = op_stmt.tuple();
CHECK(op.Has<const ::pir::Operation*>());
if (GetOpPatternKind(op.Get<const ::pir::Operation*>()) ==
Expand All @@ -178,8 +179,8 @@ bool CollectRewritedReductionOpStmts(const OpStmt& op_stmt, List<OpStmt>* ret) {
}
}

void CollectRewritedOpStmts(const OpStmt& op_stmt, List<OpStmt>* ret) {
if (CollectRewritedReductionOpStmts(op_stmt, ret)) {
void CollectRewrittenOpStmts(const OpStmt& op_stmt, List<OpStmt>* ret) {
if (CollectRewrittenReductionOpStmts(op_stmt, ret)) {
return;
}
(*ret)->emplace_back(op_stmt);
Expand All @@ -190,7 +191,7 @@ List<OpStmt> MakeOpStmts(
List<OpStmt> ret{};

VisitEachOpStmt(group, [&](const auto& op_stmt) {
CollectRewritedOpStmts(op_stmt, &ret);
CollectRewrittenOpStmts(op_stmt, &ret);
});

return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ Equation EraseIndexes(
std::vector<Index> GenerateWriteBroadcastTensorIndexs(
const std::shared_ptr<config::NaiveOpEquationContext>& ctx,
const Equations& in_msg2out_msg_equations) {
const auto& eqaution_graph_view =
const auto& equation_graph_view =
Graph<Variable, Equation>::New(ctx->equations())->GetGraphView();
GraphView graph_view = eqaution_graph_view.Merge(
GraphView graph_view = equation_graph_view.Merge(
Graph<Variable, Equation>::New(in_msg2out_msg_equations)->GetGraphView());
std::vector<Index> ret{};
const auto& fake_op_placeholder = ctx->fake_op_placeholder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool MakeGenerateShapeOpAttribute(
symbol_bindings);
}

std::optional<pir::Value> GetOutOfRewritedGenerateShapeOp(
std::optional<pir::Value> GetOutOfRewrittenGenerateShapeOp(
pir::Value shape,
pir::PatternRewriter* rewriter,
const ShapeOrDataDimExprs4ValueT& ShapeOrDataDimExprs4Value) {
Expand Down Expand Up @@ -154,7 +154,7 @@ bool ReplaceShapeOpsToGenerateShape(
return shape_analysis->GetShapeOrDataForValue(value);
};
std::optional<pir::Value> opt_generated_shape =
GetOutOfRewritedGenerateShapeOp(
GetOutOfRewrittenGenerateShapeOp(
shape_operand, rewriter, ShapeOrDataDimExprs4Value);
if (!opt_generated_shape.has_value()) return false;
shape_analysis->SetShapeOrDataForValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ class SplitGenerateShapeIntoShapeOps
MakeGetterTensorDim4SymbolName(op);
if (!TensorDim4SymbolName) return std::nullopt;
CachedDimExprToValueConverter converter{TensorDim4SymbolName, rewriter};
return GetValueOfRewritedOps(dim_exprs, &converter);
return GetValueOfRewrittenOps(dim_exprs, &converter);
}

TensorDim4SymbolNameT MakeGetterTensorDim4SymbolName(
cinn::dialect::GenerateShapeOp op) const {
std::unordered_map<std::string, TensorDim> symbol_name2tenso_dim{};
std::unordered_map<std::string, TensorDim> symbol_name2tensor_dim{};
const auto& attr_map = op->attributes();
const auto& iter = attr_map.find("symbol_bindings");
PADDLE_ENFORCE((iter != attr_map.end()),
Expand All @@ -262,9 +262,9 @@ class SplitGenerateShapeIntoShapeOps
"not be converted to symbol bindings",
op->name()));
for (const auto& symbol_binding : symbol_bindings.value()) {
InsertSymbolBinding(op, symbol_binding, &symbol_name2tenso_dim);
InsertSymbolBinding(op, symbol_binding, &symbol_name2tensor_dim);
}
return [map = std::move(symbol_name2tenso_dim)](
return [map = std::move(symbol_name2tensor_dim)](
const std::string& symbol_name) -> std::optional<TensorDim> {
auto iter = map.find(symbol_name);
if (iter == map.end()) return std::nullopt;
Expand All @@ -275,28 +275,31 @@ class SplitGenerateShapeIntoShapeOps
void InsertSymbolBinding(
cinn::dialect::GenerateShapeOp op,
const cinn::dialect::GenerateShapeOp::SymbolBinding& symbol_binding,
std::unordered_map<std::string, TensorDim>* symbol_name2tenso_dim) const {
std::unordered_map<std::string, TensorDim>* symbol_name2tensor_dim)
const {
return std::visit(
[&](const auto& impl) {
return InsertSymbolBindingImpl(op, impl, symbol_name2tenso_dim);
return InsertSymbolBindingImpl(op, impl, symbol_name2tensor_dim);
},
symbol_binding);
}

void InsertSymbolBindingImpl(
cinn::dialect::GenerateShapeOp op,
const cinn::dialect::GenerateShapeOp::DataSymbolBinding& symbol_binding,
std::unordered_map<std::string, TensorDim>* symbol_name2tenso_dim) const {
(*symbol_name2tenso_dim)[symbol_binding.symbol_name] = TensorDimInData{
std::unordered_map<std::string, TensorDim>* symbol_name2tensor_dim)
const {
(*symbol_name2tensor_dim)[symbol_binding.symbol_name] = TensorDimInData{
.value = op.operand_source(symbol_binding.input_tensor_idx),
.axis = symbol_binding.input_tensor_dim_idx};
}

void InsertSymbolBindingImpl(
cinn::dialect::GenerateShapeOp op,
const cinn::dialect::GenerateShapeOp::ShapeSymbolBinding& symbol_binding,
std::unordered_map<std::string, TensorDim>* symbol_name2tenso_dim) const {
(*symbol_name2tenso_dim)[symbol_binding.symbol_name] = TensorDimInShape{
std::unordered_map<std::string, TensorDim>* symbol_name2tensor_dim)
const {
(*symbol_name2tensor_dim)[symbol_binding.symbol_name] = TensorDimInShape{
.value = op.operand_source(symbol_binding.input_tensor_idx),
.axis = symbol_binding.input_tensor_dim_idx};
}
Expand Down Expand Up @@ -328,18 +331,18 @@ class SplitGenerateShapeIntoShapeOps
return ret;
}

pir::Value GetValueOfRewritedOps(
pir::Value GetValueOfRewrittenOps(
const std::vector<symbol::DimExpr>& dim_exprs,
CachedDimExprToValueConverter* converter) const {
const std::vector<pir::Value>& values_from_dim_exprs =
GetValuesOfRewritedOps(dim_exprs, converter);
GetValuesOfRewrittenOps(dim_exprs, converter);
if (values_from_dim_exprs.size() == 1) return values_from_dim_exprs.at(0);
pir::Value vec =
converter->rewriter->Build<pir::CombineOp>(values_from_dim_exprs).out();
return converter->rewriter->Build<paddle::dialect::ConcatOp>(vec).out();
}

std::vector<pir::Value> GetValuesOfRewritedOps(
std::vector<pir::Value> GetValuesOfRewrittenOps(
const std::vector<symbol::DimExpr>& dim_exprs,
CachedDimExprToValueConverter* converter) const {
std::vector<pir::Value> ret;
Expand Down
6 changes: 3 additions & 3 deletions python/paddle/distributed/fleet/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _parse_args():
type=str,
default=os.environ.get('PADDLE_DISTRI_BACKEND', 'auto'),
help="Specifize the backend, can be gloo|nccl|bkcl|auto|heter. "
"Default value is auto which perfers nccl or bkcl.",
"Default value is auto which prefers nccl or bkcl.",
)
base_group.add_argument(
"--nproc_per_node",
Expand Down Expand Up @@ -329,7 +329,7 @@ def get_cluster_info(args):
)
trainers_num = cloud_utils.get_trainers_num()
logger.debug(
"parsed from args trainerss_num:{} mode:{} devices:{}".format(
"parsed from args trainers_num:{} mode:{} devices:{}".format(
trainers_num, device_mode, devices_per_proc
)
)
Expand All @@ -346,7 +346,7 @@ def get_cluster_info(args):
if args.enable_auto_mapping:
assert (
args.cluster_topo_path is not None
), "The cluster topology must be provied when enabling auto mapping."
), "The cluster topology must be provided when enabling auto mapping."
rank_mapping_path = args.rank_mapping_path or os.getenv(
"PADDLE_RANK_MAPPING_PATH"
)
Expand Down
14 changes: 7 additions & 7 deletions python/paddle/distributed/fleet/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __str__(self):
return f"{self.endpoint}"

def __eq__(self, j):
return self.endpint == j.endpoint
return self.endpoint == j.endpoint

def __ne__(self, j):
return not self == j
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def get_mapped_cluster_from_args_with_rank_mapping(args, device_mode):

assert (
len(node_ranks[node_rank]) <= gpus_num
), "number of ranks mapped to one node should not exceed the avaiable ones."
), "number of ranks mapped to one node should not exceed the available ones."
assert len(node_ranks) == len(
node_ips
), "ranks length should be equal to ips length."
Expand Down Expand Up @@ -1164,7 +1164,7 @@ def get_role_endpoints(self, args):
if args.servers:
assert (
len(args.servers.split(",")) == self.server_num
), "The server_num and servers doesn't match. Expect servers endpoints num epual to server_num, but received servers enpoint num: {} and server_num {}".format(
), "The server_num and servers doesn't match. Expect servers endpoints num equal to server_num, but received servers endpoint num: {} and server_num {}".format(
len(args.servers.split(",")), self.server_num
)
self.server_endpoints = args.servers
Expand All @@ -1186,7 +1186,7 @@ def get_role_endpoints(self, args):
if args.workers:
assert (
len(args.workers.split(",")) == self.worker_num
), "The worker_num and workers doesn't match. Expect workers endpoints num epual to worker_num, but received workers enpoint num: {} and worker_num {}".format(
), "The worker_num and workers doesn't match. Expect workers endpoints num equal to worker_num, but received workers endpoint num: {} and worker_num {}".format(
len(args.workers.split(",")), self.worker_num
)

Expand Down Expand Up @@ -1238,7 +1238,7 @@ def get_role_endpoints(self, args):
if args.coordinators:
assert (
len(args.coordinators.split(",")) == self.coordinator_num
), "The coordinator_num and coordinators doesn't match. Expect coordinators endpoints num epual to coordinator_num, but received coordinator enpoint num: {} and coordinator_num {}".format(
), "The coordinator_num and coordinators doesn't match. Expect coordinators endpoints num equal to coordinator_num, but received coordinator endpoint num: {} and coordinator_num {}".format(
len(args.coordinators.split(",")), self.coordinator_num
)

Expand Down Expand Up @@ -1271,7 +1271,7 @@ def get_role_endpoints(self, args):
if args.heter_workers:
assert len(args.heter_workers.split(";")) == len(
self.stage_heter_trainer_num
), "The stage_num and heter_workers doesn't match. Expect heter_workers endpoints stage num epual to heter_worker_num stage, but received heter_workers enpoint stage num: {} and heter_worker_num stage {}".format(
), "The stage_num and heter_workers doesn't match. Expect heter_workers endpoints stage num equal to heter_worker_num stage, but received heter_workers endpoint stage num: {} and heter_worker_num stage {}".format(
len(args.heter_workers.split(";")),
len(self.stage_heter_trainer_num),
)
Expand Down Expand Up @@ -1537,7 +1537,7 @@ def start_ps(self):
pod = cluster.pods[self.node_rank]
self.gloo_rendezvous_dir = tempfile.mkdtemp()

# 3. subproces start
# 3. subprocess start
self.procs = {
"worker": [],
"coordinator": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_action(is_dp, shard_split_param=False):
return HOOK_ACTION.REDUCE


# assume only the first stage and last stage need data, and data consumption is ordred
# assume only the first stage and last stage need data, and data consumption is ordered
# to be replaced by real micro dataset from reader
class FakeMicroDataset:
def __init__(
Expand Down Expand Up @@ -198,7 +198,7 @@ def __init__(self, layers, hcg, strategy):
"pp_configs"
].delay_scale_loss
# TODO(PP Dev): support dp_comm_overlap without use_main_grad training.
# This combination will trigger inplace check error during `reshape_` in funct `_split_tensors`.
# This combination will trigger inplace check error during `reshape_` in function `_split_tensors`.
self._dp_comm_overlap = self._strategy.hybrid_configs[
"pp_configs"
].dp_comm_overlap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def _update_opt_status(self):
# func 1
self._integration_params()

# Segement helpers
# Segment helpers

def _segment_params(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def _build_grad_storages(self):
for dtype in self._grad_storages.keys():
for dst_rank, grad_storage in self._grad_storages[dtype].items():
if self._offload or dst_rank != self._rank:
grad_storage.manumal_relase()
grad_storage.manual_release()
grad_storage.rebuild()

def _rank_buffer_size(self, buffer_max_size, model_size):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ def _clear_gradients(self):
tmp_var._share_buffer_to(param)
del tmp_var
for grad_storage in self._grad_storages.values():
grad_storage.manumal_relase()
grad_storage.manual_release()
grad_storage.rebuild()

# Update param memery slice
# Update param memory slice
def _update_params_slice(self):
update_list = self._update_params()

Expand Down Expand Up @@ -385,7 +385,7 @@ def _handle_unslice_params(self):
buffer_size[Type.fp32.value] = 0
buffer_size[Type.fp16.value] = 0
for param in self._unslice_params:
# Updata optimizer master weights
# Update optimizer master weights
if (
param.dtype == Type.fp16.value or param.dtype == Type.bf16.value
) and not self._offload:
Expand Down Expand Up @@ -537,7 +537,7 @@ def _param_storage(self, param, buffer_size):
)
param.status = "part"

# Updata optimizer master weights
# Update optimizer master weights
if (
param.trainable
and (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def add_grad(self, param, align):
self._param_ids.append(id(param))

@paddle.autograd.no_grad()
def manumal_relase(self):
def manual_release(self):
"""
Release the buffer from InternalStorage. The InternalStorage will need to be rebuilt before use.
"""
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distributed/fleet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def distributed_model(model):
Return distributed data parallel model (Only work in dygraph mode)

Args:
model (Layer): the user-defind model which inherits Layer.
model (Layer): the user-defined model which inherits Layer.

Returns:
distributed data parallel model which inherits Layer.
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/distributed/sharding/group_sharded.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def group_sharded_parallel(
]
or device in paddle.device.get_all_custom_device_type()
), "group_sharded_parallel only support gpu, xpu and custom_device now"
# check optition type
# check option type
assert isinstance(
model, paddle.nn.Layer
), "The model must be the instance of paddle.nn.Layer."
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/distributed/utils/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_gpus(selected_gpus):
for x in selected_gpus.split(',')
]
logger.info(
f"Change selected_gpus into reletive values. --ips:{selected_gpus} "
f"Change selected_gpus into relative values. --ips:{selected_gpus} "
f"will change into relative_ips:{gpus} according to your "
f"CUDA_VISIBLE_DEVICES:{cuda_visible_devices_list}"
)
Expand Down Expand Up @@ -200,7 +200,7 @@ def __str__(self):
return f"{self.endpoint}"

def __eq__(self, j):
return self.endpint == j.endpoint
return self.endpoint == j.endpoint

def __ne__(self, j):
return not self == j
Expand Down