Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
cli99 committed Oct 27, 2023
1 parent 66e74d6 commit fb7e17c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions llm_analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from enum import Enum
from functools import total_ordering
from pprint import pformat
from typing import Optional, Union, List
from typing import Union

import fire

Expand Down Expand Up @@ -1408,8 +1408,8 @@ def inference(
)

if use_kv_cache:
if (batch_size_per_gpu * (seq_len + num_tokens_to_generate)
< self.get_pivot()):
if (batch_size_per_gpu *
(seq_len + num_tokens_to_generate) < self.get_pivot()):
logger.warning(
"kv_cache is only useful when batch_size *"
" (seq+num_tokens_to_generate)"
Expand Down Expand Up @@ -1629,16 +1629,16 @@ def config_batch_size_and_gradient_accumulation_steps(
gradient_accumulation_steps = global_batch_size // (
batch_size_per_gpu * dp_size)
assert (global_batch_size % (batch_size_per_gpu * dp_size) == 0
and gradient_accumulation_steps
> 0), "no valid gradient_accumulation_steps, {assert_msg}"
and gradient_accumulation_steps > 0
), "no valid gradient_accumulation_steps, {assert_msg}"
elif global_batch_size and gradient_accumulation_steps:
# batch_size_per_gpu is None, the other two are not None
batch_size_per_gpu = global_batch_size // (
gradient_accumulation_steps * dp_size)
assert (global_batch_size %
(gradient_accumulation_steps * dp_size) == 0
and batch_size_per_gpu
> 0), "no valid batch_size_per_gpu, {assert_msg}"
and batch_size_per_gpu > 0
), "no valid batch_size_per_gpu, {assert_msg}"
elif batch_size_per_gpu and gradient_accumulation_steps:
# global_batch_size is None, the other two are not None
global_batch_size = (batch_size_per_gpu *
Expand Down Expand Up @@ -1667,9 +1667,9 @@ def config_batch_size_and_gradient_accumulation_steps(
else:
# (global_batch_size and gradient_accumulation_steps are None) or (global_batch_size and batch_size_per_gpu are None) or (all are None)
batch_size_per_gpu = max_batch_size_per_gpu
gradient_accumulation_steps = (1 if gradient_accumulation_steps
is None else
gradient_accumulation_steps)
gradient_accumulation_steps = (1 if
gradient_accumulation_steps is None
else gradient_accumulation_steps)
global_batch_size = (batch_size_per_gpu *
gradient_accumulation_steps *
self.parallelism_config.dp_size)
Expand Down

0 comments on commit fb7e17c

Please sign in to comment.