Close Menu
    Trending
    • Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025
    • The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z
    • Musk’s X appoints ‘king of virality’ in bid to boost growth
    • Why Entrepreneurs Should Stop Obsessing Over Growth
    • Implementing IBCS rules in Power BI
    • What comes next for AI copyright lawsuits?
    • Why PDF Extraction Still Feels LikeHack
    • GenAI Will Fuel People’s Jobs, Not Replace Them. Here’s Why
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Artificial Intelligence»Load-Testing LLMs Using LLMPerf | Towards Data Science
    Artificial Intelligence

    Load-Testing LLMs Using LLMPerf | Towards Data Science

    Team_AIBS NewsBy Team_AIBS NewsApril 18, 2025No Comments9 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Language Mannequin (LLM) just isn’t essentially the ultimate step in productionizing your Generative AI software. An typically forgotten, but essential a part of the MLOPs lifecycle is correctly load testing your LLM and guaranteeing it is able to stand up to your anticipated manufacturing visitors. Load testing at a excessive stage is the follow of testing your software or on this case your mannequin with the visitors it will expect in a manufacturing setting to make sure that it’s performant.

    Previously we’ve mentioned load testing traditional ML models utilizing open supply Python instruments comparable to Locust. Locust helps seize normal efficiency metrics comparable to requests per second (RPS) and latency percentiles on a per request foundation. Whereas that is efficient with extra conventional APIs and ML fashions it doesn’t seize the complete story for LLMs. 

    LLMs historically have a a lot decrease RPS and better latency than conventional ML fashions attributable to their measurement and bigger compute necessities. Normally the RPS metric does probably not present essentially the most correct image both as requests can drastically range relying on the enter to the LLM. For example you may need a question asking to summarize a big chunk of textual content and one other question which may require a one-word response. 

    This is the reason tokens are seen as a way more correct illustration of an LLM’s efficiency. At a excessive stage a token is a piece of textual content, at any time when an LLM is processing your enter it “tokenizes” the enter. A token differs relying particularly on the LLM you might be utilizing, however you possibly can think about it as an illustration as a phrase, sequence of phrases, or characters in essence.

    Picture by Writer

    What we’ll do on this article is discover how we will generate token primarily based metrics so we will perceive how your LLM is acting from a serving/deployment perspective. After this text you’ll have an thought of how one can arrange a load-testing instrument particularly to benchmark completely different LLMs within the case that you’re evaluating many fashions or completely different deployment configurations or a mixture of each.

    Let’s get palms on! In case you are extra of a video primarily based learner be happy to comply with my corresponding YouTube video down beneath:

    NOTE: This text assumes a fundamental understanding of Python, LLMs, and Amazon Bedrock/SageMaker. In case you are new to Amazon Bedrock please seek advice from my starter information here. If you wish to study extra about SageMaker JumpStart LLM deployments seek advice from the video here.

    DISCLAIMER: I’m a Machine Studying Architect at AWS and my opinions are my very own.

    Desk of Contents

    1. LLM Particular Metrics
    2. LLMPerf Intro
    3. Making use of LLMPerf to Amazon Bedrock
    4. Further Assets & Conclusion

    LLM-Particular Metrics

    As we briefly mentioned within the introduction with reference to LLM internet hosting, token primarily based metrics usually present a significantly better illustration of how your LLM is responding to completely different payload sizes or sorts of queries (summarization vs QnA). 

    Historically we have now all the time tracked RPS and latency which we are going to nonetheless see right here nonetheless, however extra so at a token stage. Listed below are a number of the metrics to concentrate on earlier than we get began with load testing:

    1. Time to First Token: That is the length it takes for the primary token to generate. That is particularly helpful when streaming. For example when utilizing ChatGPT we begin processing data when the primary piece of textual content (token) seems.
    2. Complete Output Tokens Per Second: That is the overall variety of tokens generated per second, you possibly can consider this as a extra granular different to the requests per second we historically observe.

    These are the foremost metrics that we’ll give attention to, and there’s a couple of others comparable to inter-token latency that will even be displayed as a part of the load assessments. Have in mind the parameters that additionally affect these metrics embrace the anticipated enter and output token measurement. We particularly play with these parameters to get an correct understanding of how our LLM performs in response to completely different technology duties. 

    Now let’s check out a instrument that allows us to toggle these parameters and show the related metrics we’d like.

    LLMPerf Intro

    LLMPerf is constructed on prime of Ray, a well-liked distributed computing Python framework. LLMPerf particularly leverages Ray to create distributed load assessments the place we will simulate real-time manufacturing stage visitors. 

    Be aware that any load-testing instrument can also be solely going to have the ability to generate your anticipated quantity of visitors if the consumer machine it’s on has sufficient compute energy to match your anticipated load. For example as you scale the concurrency or throughput anticipated on your mannequin, you’d additionally wish to scale the consumer machine(s) the place you might be operating your load take a look at.

    Now particularly inside LLMPerf there’s a couple of parameters which might be uncovered which might be tailor-made for LLM load testing as we’ve mentioned:

    • Mannequin: That is the mannequin supplier and your hosted mannequin that you just’re working with. For our use-case it’ll be Amazon Bedrock and Claude 3 Sonnet particularly.
    • LLM API: That is the API format wherein the payload needs to be structured. We use LiteLLM which supplies a standardized payload construction throughout completely different mannequin suppliers, thus simplifying the setup course of for us particularly if we wish to take a look at completely different fashions hosted on completely different platforms.
    • Enter Tokens: The imply enter token size, you too can specify a normal deviation for this quantity.
    • Output Tokens: The imply output token size, you too can specify a normal deviation for this quantity.
    • Concurrent Requests: The variety of concurrent requests for the load take a look at to simulate.
    • Take a look at Period: You may management the length of the take a look at, this parameter is enabled in seconds.

    LLMPerf particularly exposes all these parameters via their token_benchmark_ray.py script which we configure with our particular values. Let’s have a look now at how we will configure this particularly for Amazon Bedrock.

    Making use of LLMPerf to Amazon Bedrock

    Setup

    For this instance we’ll be working in a SageMaker Classic Notebook Instance with a conda_python3 kernel and ml.g5.12xlarge occasion. Be aware that you just wish to choose an occasion that has sufficient compute to generate the visitors load that you just wish to simulate. Be sure that you even have your AWS credentials for LLMPerf to entry the hosted mannequin be it on Bedrock or SageMaker.

    LiteLLM Configuration

    We first configure our LLM API construction of alternative which is LiteLLM on this case. With LiteLLM there’s help throughout numerous mannequin suppliers, on this case we configure the completion API to work with Amazon Bedrock:

    import os
    from litellm import completion
    
    os.environ["AWS_ACCESS_KEY_ID"] = "Enter your entry key ID"
    os.environ["AWS_SECRET_ACCESS_KEY"] = "Enter your secret entry key"
    os.environ["AWS_REGION_NAME"] = "us-east-1"
    
    response = completion(
        mannequin="anthropic.claude-3-sonnet-20240229-v1:0",
        messages=[{ "content": "Who is Roger Federer?","role": "user"}]
    )
    output = response.selections[0].message.content material
    print(output)

    To work with Bedrock we configure the Mannequin ID to level in the direction of Claude 3 Sonnet and move in our immediate. The neat half with LiteLLM is that messages key has a constant format throughout mannequin suppliers.

    Submit-execution right here we will give attention to configuring LLMPerf for Bedrock particularly.

    LLMPerf Bedrock Integration

    To execute a load take a look at with LLMPerf we will merely use the offered token_benchmark_ray.py script and move within the following parameters that we talked of earlier:

    • Enter Tokens Imply & Normal Deviation
    • Output Tokens Imply & Normal Deviation
    • Max variety of requests for take a look at
    • Period of take a look at
    • Concurrent requests

    On this case we additionally specify our API format to be LiteLLM and we will execute the load take a look at with a easy shell script like the next:

    %%sh
    python llmperf/token_benchmark_ray.py 
        --model bedrock/anthropic.claude-3-sonnet-20240229-v1:0 
        --mean-input-tokens 1024 
        --stddev-input-tokens 200 
        --mean-output-tokens 1024 
        --stddev-output-tokens 200 
        --max-num-completed-requests 30 
        --num-concurrent-requests 1 
        --timeout 300 
        --llm-api litellm 
        --results-dir bedrock-outputs

    On this case we hold the concurrency low, however be happy to toggle this quantity relying on what you’re anticipating in manufacturing. Our take a look at will run for 300 seconds and submit length you need to see an output listing with two information representing statistics for every inference and in addition the imply metrics throughout all requests within the length of the take a look at.

    We will make this look slightly neater by parsing the abstract file with pandas:

    import json
    from pathlib import Path
    import pandas as pd
    
    # Load JSON information
    individual_path = Path("bedrock-outputs/bedrock-anthropic-claude-3-sonnet-20240229-v1-0_1024_1024_individual_responses.json")
    summary_path = Path("bedrock-outputs/bedrock-anthropic-claude-3-sonnet-20240229-v1-0_1024_1024_summary.json")
    
    with open(individual_path, "r") as f:
        individual_data = json.load(f)
    
    with open(summary_path, "r") as f:
        summary_data = json.load(f)
    
    # Print abstract metrics
    df = pd.DataFrame(individual_data)
    summary_metrics = {
        "Mannequin": summary_data.get("mannequin"),
        "Imply Enter Tokens": summary_data.get("mean_input_tokens"),
        "Stddev Enter Tokens": summary_data.get("stddev_input_tokens"),
        "Imply Output Tokens": summary_data.get("mean_output_tokens"),
        "Stddev Output Tokens": summary_data.get("stddev_output_tokens"),
        "Imply TTFT (s)": summary_data.get("results_ttft_s_mean"),
        "Imply Inter-token Latency (s)": summary_data.get("results_inter_token_latency_s_mean"),
        "Imply Output Throughput (tokens/s)": summary_data.get("results_mean_output_throughput_token_per_s"),
        "Accomplished Requests": summary_data.get("results_num_completed_requests"),
        "Error Price": summary_data.get("results_error_rate")
    }
    print("Claude 3 Sonnet - Efficiency Abstract:n")
    for okay, v in summary_metrics.objects():
        print(f"{okay}: {v}")

    The ultimate load take a look at outcomes will look one thing like the next:

    Screenshot by Writer

    As we will see we see the enter parameters that we configured, after which the corresponding outcomes with time to first token(s) and throughput with reference to imply output tokens per second.

    In a real-world use case you may use LLMPerf throughout many alternative mannequin suppliers and run assessments throughout these platforms. With this instrument you should use it holistically to determine the precise mannequin and deployment stack on your use-case when used at scale.

    Further Assets & Conclusion

    The whole code for the pattern could be discovered at this related Github repository. In the event you additionally wish to work with SageMaker endpoints you’ll find a Llama JumpStart deployment load testing pattern here.

    All in all load testing and analysis are each essential to making sure that your LLM is performant towards your anticipated visitors earlier than pushing to manufacturing. In future articles we’ll cowl not simply the analysis portion, however how we will create a holistic take a look at with each parts.

    As all the time thanks for studying and be happy to depart any suggestions and join with me on Linkedln and X.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleBlockchain for Secure Telecom Transactions and Data Integrity | by Venkata Bhardwaj Komaragiri | Apr, 2025
    Next Article Here’s What Being an Entrepreneur Is Really Like — From Someone Who Did It
    Team_AIBS News
    • Website

    Related Posts

    Artificial Intelligence

    Implementing IBCS rules in Power BI

    July 1, 2025
    Artificial Intelligence

    Become a Better Data Scientist with These Prompt Engineering Tips and Tricks

    July 1, 2025
    Artificial Intelligence

    Lessons Learned After 6.5 Years Of Machine Learning

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    Behind the Crash: A Data Scientist’s Journey to Understand Road Fatalities | by Rahaditya Zuhdi | Jun, 2025

    June 29, 2025

    Generating Data Dictionary for Excel Files Using OpenPyxl and AI Agents

    May 8, 2025

    Robot Videos: One-Legged Robot, Good-bye Aldebaran, and More

    June 6, 2025
    Our Picks

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025

    The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z

    July 1, 2025

    Musk’s X appoints ‘king of virality’ in bid to boost growth

    July 1, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.