-
Notifications
You must be signed in to change notification settings - Fork 8
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
Changes for OAI compatible testing #4
base: master
Are you sure you want to change the base?
Conversation
EkinKarabulut
commented
Jun 18, 2024
- Changed the scripts for OAI-compatible testing (removed tgi_perf.py, vllm_perf.py, triton_perf.py, edited llmperf.py accordingly)
- Updated the requirements.txt
- Made changes in openai_perf.py for the newer version of openai
- Added input examples for llama3 (128 tokens & 2048 tokens)
- Added a token counter script to check out number of tokens for the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to upload that kind of files (.pyc
)
input_examples/token_counter.py
Outdated
from transformers import AutoTokenizer | ||
tokenizer = AutoTokenizer.from_pretrained("NousResearch/Meta-Llama-3-8B") | ||
text = "Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much. They were the last people you'd expect to be involved in anything strange or mysterious, because they just didn't hold with such nonsense. Mr. Dursley was the director of a firm called Grunnings, which made drills. He was a big, beefy man with hardly any neck, although he did have a very large mustache. Mrs. Dursley was thin and blonde and had nearly twice the usual amount of neck, which came in very useful as she spent so much of her time craning over garden fences, spying on the neighbors. The Dursleys had a small son called Dudley and in their opinion there was no finer boy anywhere. The Dursleys had everything they wanted, but they also had a secret, and their greatest fear was that somebody would discover it. They didn't think they could bear it if anyone found out about the Potters. Mrs. Potter was Mrs. Dursley's sister, but they hadn't met for several years; in fact, Mrs. Dursley pretended she didn't have a sister, because her sister and her good-for-nothing husband were as unDursleyish as it was possible to be. The Dursleys shuddered to think what the neighbors would say if the Potters arrived in the street. The Dursleys knew that the Potters had a small son, too, but they had never even seen him. This boy was another good reason for keeping the Potters away; they didn't want Dudley mixing with a child like that. When Mr. and Mrs. Dursley woke up on the dull, gray Tuesday our story starts, there was nothing about the cloudy sky outside to suggest that strange and mysterious things would soon be happening all over the country. Mr. Dursley hummed as he picked out his most boring tie for work, and Mrs. Dursley gossiped away happily as she wrestled a screaming Dudley into his high chair. None of them noticed a large, tawny owl flutter past the window. At half past eight, Mr. Dursley picked up his briefcase, pecked Mrs. Dursley on the cheek, and tried to kiss Dudley good-bye but missed, because Dudley was now having a tantrum and throwing his cereal at the walls. Little tyke,' chortled Mr. Dursley as he left the house. He got into his car and backed out of number four's drive. It was on the corner of the street that he noticed the first sign of something peculiar a cat reading a map. For a second, Mr. Dursley didn't realize what he had seen then he jerked his head around to look again. There was a tabby cat standing on the corner of Privet Drive, but there wasn't a map in sight. What could he have been thinking of? It must have been a trick of the light. Mr. Dursley blinked and stared at the cat. It stared back. As Mr. Dursley drove around the corner and up the road, he watched the cat in his mirror. It was now reading the sign that said Privet Drive no, looking at the sign; cats couldn't read maps or signs. Mr. Dursley gave himself a little shake and put the cat out of his mind. As he drove toward town he thought of nothing except a large order of drills he was hoping to get that day. But on the edge of town, drills were driven out of his mind by something else. As he sat in the usual morning traffic jam, he couldn't help noticing that there seemed to be a lot of strangely dressed people about. People in cloaks. Mr. Dursley couldn't bear people who dressed in funny clothes the getups you saw on young people! He supposed this was some stupid new fashion. He drummed his fingers on the steering wheel and his eyes fell on a huddle of these weirdos standing quite close by. They were whispering excitedly together. Mr. Dursley was enraged to see that a couple of them weren't young at all; why, that man had to be older than he was, and wearing an emerald-green cloak! The nerve of him! But then it struck Mr. Dursley that this was probably some silly stunt these people were obviously collecting for something . . . yes, that would be it. The traffic moved on and a few minutes later, Mr. Dursley arrived in the Grunnings parking lot, his mind back on drills. Mr. Dursley always sat with his back to the window in his office on the ninth floor. If he hadn't, he might have found it harder to concentrate on drills that morning. He didn't see the owls swoop- ing past in broad daylight, though people down in the street did; they pointed and gazed open-mouthed as owl after owl sped overhead. Most of them had never seen an owl even at nighttime. Mr. Dursley, however, had a perfectly normal, owl-free morning. He yelled at five different people. He made several important telephone calls and shouted a bit more. He was in a very good mood until lunchtime, when he thought he'd stretch his legs and walk across the road to buy himself a bun from the bakery. He'd forgotten all about the people in cloaks until he passed a group of them next to the baker's. He eyed them angrily as he passed. He didn't know why, but they made him uneasy. This bunch were whispering excitedly, too, and he couldn't see a single collecting tin. It was on his way back past them, clutching a large doughnut in a bag, that he caught a few words of what they were saying. 'The Potters, that's right, that's what I heard ' ' yes, their son, Harry ' Mr. Dursley stopped dead. Fear flooded him. He looked back at the whisperers as if he wanted to say something to them, but thought better of it. He dashed back across the road, hurried up to his office,snapped at his secretary not to disturb him, seized his telephone,and had almost finished dialing his home number when hechanged his mind. He put the receiver back down and stroked hismustache, thinking . . . no, he was being stupid. Potter wasn't suchan unusual name. He was sure there were lots of people called Potter who had a son called Harry. Come to think of it, he wasn't evensure his nephew was called Harry. He'd never even seen the boy. It might have been Harvey. Or Harold. There was no point in worrying Mrs. Dursley; she always got so upset at any mention of hersister. He didn't blame her if he'd had a sister like that . . . but allthe same, those people in cloaks . . .He found it a lot harder to concentrate on drills that afternoonand when he left the building at five o'clock, he was still so worriedthat he walked straight into someone just outside the door.'Sorry,' he grunted, as the tiny old man stumbled and almostfell. It was a few seconds before Mr. Dursley realized that the manwas wearing a violet cloak. He didn't seem at all upset at being almost knocked to the ground. On the contrary, his face split into awide smile and he said in a squeaky voice that made passersby stare,'Don't be sorry, my dear sir, for nothing could upset me today! Rejoice, for You-Know-Who has gone at last! Even Muggles like yourself should be celebrating, this happy, happy day!'And the old man hugged Mr. Dursley around the middle andwalked off.Mr. Dursley stood rooted to the spot. He had been hugged by acomplete stranger. He also thought he had been called a Muggle,whatever that was. He was rattled. He hurried to his car and set offfor home, hoping he was imagining things, which he had neverhoped before, because he didn't approve of imagination.As he pulled into the driveway of number four, the first thing hesaw and it didn't improve his mood was the tabby cat he'dspotted that morning. It was now sitting on his garden wall. Hewas sure it was the same one; it had the same markings around itseyes.'Shoo!' said Mr. Dursley loudly. The cat didn't move. It just gave him a stern look. Was this normal cat behavior? Mr. Dursley wondered. Trying to pull himself together, he let himself into the house. He was still determined not tomention anything to his wife.Mrs. Dursley had had a nice, normal day. She told him over dinner all about Mrs. Next Door's problems with her daughter and how Dudley had learnt a new word (‘Shan’t!’). Mr Dursley tried to act normally. When Dudley had been put to bed, he went into the living-room in time to catch the last report on the evening news: ‘And finally, bird-watchers everywhere have reported that the nation’s owls have been behaving very unusually today. Although owls normally hunt at night and are hardly ever seen in daylight, there have been hundreds of sightings of these birds flying in every direction since sunrise. Experts are unable to explain why the owls have suddenly changed their sleeping pattern.’ The news reader allowed himself a grin. ‘Most mysterious. And now, over to Jim McGuffin with the weather. Going to be any more showers of owls tonight, Jim?’ ‘Well, Ted,’ said the weatherman, ‘I don’t know about that, but it’s" | ||
tokens = tokenizer.tokenize(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I really liked that.
But lets make it script that accepts the name of the tokenizer and the text as parameters?
Like python3 token_counter.py --tokenizer Meta/Llama3 --text XYZ-BLABLABLA
What do you think? I think its more proffesional
llmperf.py
Outdated
measurer = vllm_perf.static_batch_measurer(prompt, args) | ||
else: | ||
print(f"Static batch test not implemented for {args.engine}") | ||
return | ||
run_test_n_times(measurer, args.iterations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
measurer
is always None in here. So I guese this static batch will not work anymore right?
Seems like we supported that only on native vLLM.
Now that we are OpenAI API specific, it wont work. (Which I think its fine)
nim_parser.add_argument("--api_key", type=str, default="API_KEY", help="The OpenAI API Key") | ||
nim_parser.add_argument("--api_base", type=str, default="http://localhost:8000/v1", help="The OpenAI Server URL") | ||
|
||
tgi_parser = engine_parser.add_parser("tgi", help="Text-generation-inference Engine by HuggingFace") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that both for nim
, vllm
and tgi
we add the same exact flags.
So lets add these flags always, and not require the user to say nim
/vllm
/tgi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omer-dayan the ports of the containers for tgi and vllm are different. That was actually the main reason why I kept them. I need to double check that also with nim (I didn't try it out yet). Do you think we can find a nicer way around for that?
async def single_request(): | ||
completion = await openai.Completion.acreate( | ||
completion = await client.completions.create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested that it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omer-dayan Yes I used it already
openai_perf.py
Outdated
openai.api_base = args.api_base | ||
models = openai.Model.list() | ||
return models["data"][0]["id"] | ||
def get_model(args, async_client=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked it now that we return client in this function!
But the name now become a bit vague.
I would think that get_model
will return model, but it returns client as well.
So we can change it to get_client_model
or get_runtime
What do you think?
…unt and display number of tokens
…transformers to the requirements