Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
  • Prompting13
  • Trust and Verification14
  • Using AI for Engineering Work17
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
    • Cost Arithmetic
    • Latency and Throughput
      • Time to First Token and Decode Speed
      • A Simple Latency Model
      • Streaming, Batching and Interactive Use
      • Rate Limits and Retries
    • Reducing Tokens
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Latency and Throughput
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Tokens, Cost and Latency
  4. Latency and Throughput
  5. A Simple Latency Model

Reference: Tokens, Cost and Latency · Beginner to Intermediate

A Simple Latency Model

Total latency as queue plus prefill plus output tokens times time per token.

On this page

    The model

    Total latency is the sum of three parts: queue wait, prompt read (prefill), and one decode step per output token. Each term takes an example parameter, stated wherever it appears.

    The form is total = queue + prefill + n_output x time_per_token. It is a planning aid, not a performance guarantee.

    Term

    Unit

    Grows with

    Queue

    Seconds

    Load at the moment of the request.

    Prefill

    Seconds

    Input length and prompt processing.

    n_output x time_per_token

    Tokens x seconds per token

    Reply length at the measured decode pace.

    Worked numbers

    The calc block evaluates the model for three cases. Each line shows the substitution before the result, so it checks by hand.

    plaintext
    1
    2
    3
    4
    5
    total = queue + prefill + n_output x time_per_token (example model)
    case A: 0.00 + 0.40 + 100 x 0.020 = 0.40 + 2.00 = 2.40 s
    case B: 0.50 + 0.60 + 200 x 0.015 = 1.10 + 3.00 = 4.10 s
    case C: 1.20 + 0.30 + 40 x 0.025 = 1.50 + 1.00 = 2.50 s
    case A is decode-bound; case C is queue-bound

    A runnable model

    The program below implements the same sum and rechecks the three worked totals. Two generators with seed 7 must agree, which shows that fixed seeds repeat.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    import random
    import sys
    
    def total_latency(queue_s, prefill_s, n_out, tpot_s):
        return queue_s + prefill_s + n_out * tpot_s
    
    cases = [
        (0.00, 0.40, 100, 0.020, 2.40),
        (0.50, 0.60, 200, 0.015, 4.10),
        (1.20, 0.30, 40, 0.025, 2.50),
    ]
    
    bad = 0
    for q, p, n, t, exp in cases:
        if abs(total_latency(q, p, n, t) - exp) > 1e-9:
            bad += 1
            print("FAIL: case %d total differs from its worked value" % bad)
            sys.exit(1)
    
    r1 = random.Random(7)
    r2 = random.Random(7)
    if [r1.random() for _ in range(4)] != [r2.random() for _ in range(4)]:
        print("FAIL: same seed produced different draws")
        sys.exit(1)
    
    print("PASS: 3 latency totals and repeated draws from seed 7 agree")

    Common mistakes

    Common pitfall

    Treating the example parameters as speeds of a real service. They are labelled EXAMPLE inputs; real queue, prefill and decode figures vary by model and load, so measure them.

    Interview

    Likely probes: naming the terms and reading which one dominates.

    • State the three terms with units before quoting any total.

    • Short replies point at queue and prefill; long replies point at decode pace.

    • Streaming changes when tokens are seen, not the total the model gives.

    Check yourself Case C has queue 1.20 s, prefill 0.30 s, and 40 tokens at 0.025 s. What is the total, and which term dominates?

    1.20 + 0.30 + 1.00 = 2.50 s. The queue term dominates.

    Check yourself Output length doubles from 100 to 200 tokens at 0.020 s each. By how much does the total grow?

    100 x 0.020 = 2.00 s extra. Queue and prefill do not move with output length.

    Related topics

    • Time to first token and decode speed

    • Streaming, batching and interactive use

    Previous

    136 / 173

    Next: Streaming, Batching and Interactive Use

    Up next

    Up nextStreaming, Batching and Interactive Use

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Rate Limits and Retries