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

[Improvement] fix ops improting in utils #7865

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 10 additions & 1 deletion llm/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import paddle.distributed.fleet.base.topology as tp
import paddle.incubate.multiprocessing as mp
from paddle.distributed import fleet
from paddlenlp_ops import reset_stop_value
from utils import (
dybatch_preprocess,
get_alibi_slopes,
Expand Down Expand Up @@ -57,6 +56,16 @@
from paddlenlp.utils.import_utils import import_module, is_paddlenlp_ops_available
from paddlenlp.utils.log import logger

try:
from paddlenlp_ops import reset_stop_value
except (ImportError, ModuleNotFoundError):
logger.error(
wj-Mcat marked this conversation as resolved.
Show resolved Hide resolved
"if you run predictor.py with --inference_model argument, please ensure you install "
"the paddlenlp_ops by following the instructions "
"provided at https://github.com/PaddlePaddle/PaddleNLP/blob/develop/csrc/README.md"
)


# Note(@RochardWooSJTU): MAX_BSZ must be the same as definition in get_output / save_output
MAX_BSZ = 512

Expand Down
4 changes: 3 additions & 1 deletion llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import paddle.incubate.multiprocessing as mp
from paddle.distributed import fleet
from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
from paddlenlp_ops import get_output
from sklearn.metrics import accuracy_score

from paddlenlp.datasets import InTokensIterableDataset
Expand Down Expand Up @@ -704,6 +703,9 @@ def read_res(model_name_or_path: str, tensor_queue: mp.Queue, result_queue: mp.Q

logger.info("Start read result message")
logger.info(f"Current path is {os.getcwd()}")

from paddlenlp_ops import get_output

while True:
get_output(output_tensor, 0, True)
if output_tensor[0, 0] == -2: # read none
Expand Down