Skip to content

Commit

Permalink
update by environment
Browse files Browse the repository at this point in the history
  • Loading branch information
iosmers committed May 23, 2024
1 parent 370d2c9 commit 594a050
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions llm/run_pretrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ class ModelArguments:
default=None,
metadata={"help": "num_hidden_layers."},
)
use_casual_mask: Optional[bool] = field(
default=True,
metadata={"help": "whether to use casual mask"},
)


def create_pretrained_dataset(
Expand Down Expand Up @@ -480,7 +476,6 @@ def main():
config.pp_recompute_interval = model_args.pp_recompute_interval
config.recompute_use_reentrant = model_args.recompute_use_reentrant
config.use_recompute = training_args.recompute
config.use_casual_mask = model_args.use_casual_mask

config.tensor_parallel_degree = training_args.tensor_parallel_degree
config.tensor_parallel_rank = training_args.tensor_parallel_rank
Expand Down
10 changes: 7 additions & 3 deletions paddlenlp/transformers/llama/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def _get_interleave_power_of_2(n):
)


def get_use_casual_mask():
"""Get the value of the 'USE_CASUAL_MASK' environment variable."""
return os.getenv("USE_CASUAL_MASK", "False")


def build_alibi_tensor(
bool_attention_mask: Tensor, num_heads: int, dtype: paddle.dtype, tensor_parallel_degree=1
) -> Tensor:
Expand Down Expand Up @@ -1532,9 +1537,8 @@ def forward(
if position_ids is None:
position_ids = paddle.arange(seq_length, dtype="int64").expand((batch_size, seq_length))

use_casual_mask = (
True if hasattr(self.config, "use_casual_mask") and self.config.use_casual_mask is True else False
)
use_casual_mask = get_use_casual_mask()

Check warning on line 1541 in paddlenlp/transformers/llama/modeling.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling.py#L1541

Added line #L1541 was not covered by tests
if use_casual_mask:
attention_mask = None

Check warning on line 1543 in paddlenlp/transformers/llama/modeling.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/transformers/llama/modeling.py#L1543

Added line #L1543 was not covered by tests
else:
Expand Down

0 comments on commit 594a050

Please sign in to comment.