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
      • The Cost Formula
      • A Code-Review Job
      • A Nightly Regression Summary
      • Sensitivity and a Cost Calculator
    • Latency and Throughput
    • 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

‹Cost Arithmetic
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Tokens, Cost and Latency
  4. Cost Arithmetic
  5. Sensitivity and a Cost Calculator

Reference: Tokens, Cost and Latency · Beginner to Intermediate

Sensitivity and a Cost Calculator

What doubling the context does, plus a runnable cost calculator.

On this page

    What doubling the context does

    Doubling context doubles the input count, not the total cost. The effect follows the input share of the starting call.

    The base call from the first lesson costs 0.030 units. Each row below doubles one side of it.

    Case

    Input

    Output

    Total (units)

    Against base

    Base

    8000

    500

    0.030

    1.00x

    Double input

    16000

    500

    0.054

    1.80x

    Double output

    8000

    1000

    0.036

    1.20x

    Double both

    16000

    1000

    0.060

    2.00x

    plaintext
    1
    2
    3
    4
    base: 8000 in, 500 out -> 0.024 + 0.006 = 0.030 units
    double input: 16000 in -> 0.048 + 0.006 = 0.054 units = 1.80x base
    double output: 1000 out -> 0.024 + 0.012 = 0.036 units = 1.20x base
    double both: 0.048 + 0.012 = 0.060 units = 2.00x base

    Which lever matters most

    Input-heavy calls move with input, and review and summary jobs are input-heavy. Output trims matter most when replies are long.

    The split varies by task and model. Measure the real token counts before choosing what to cut.

    A runnable cost calculator

    The program below prices any job from token counts at the EXAMPLE prices. Its five self-checks repeat the hand arithmetic from every lesson.

    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
    27
    import sys
    
    PRICE_IN = 3.0
    PRICE_OUT = 12.0
    PER_M = 1000000.0
    
    def job_cost(in_tokens, out_tokens):
        return in_tokens / PER_M * PRICE_IN + out_tokens / PER_M * PRICE_OUT
    
    def close(got, want):
        return abs(got - want) < 1e-9
    
    checks = [
        (job_cost(8000, 500), 0.030),
        (job_cost(12000, 800), 0.0456),
        (job_cost(60000, 2000), 0.204),
        (30 * job_cost(60000, 2000), 6.12),
        (job_cost(16000, 500), 0.054),
    ]
    
    for i in range(len(checks)):
        got, want = checks[i]
        if not close(got, want):
            print("FAIL: check " + str(i + 1) + " got " + str(got) + " want " + str(want))
            sys.exit(1)
    
    print("PASS: calculator agrees with hand arithmetic on 5 checks")

    Common pitfall

    A calculator checks arithmetic, not token estimates. Exact arithmetic on wrong token counts still gives the wrong budget.

    Interview

    Likely probes: reading the sensitivity table and trusting the tool.

    • Doubling input on the base call gives 1.80x, doubling output gives 1.20x, doubling both gives 2.00x.

    • The five self-checks replay the lesson totals: 0.030, 0.0456, 0.204, 6.12 and 0.054.

    • The program proves the arithmetic agrees; the token estimates still need measuring.

    Check yourself The base call costs 0.030 units. What does doubling only the output give, and why is the ratio small?

    It gives 0.036 units, which is 1.20x base. Output starts at 20% of the total, so doubling it adds little.

    Check yourself All five calculator checks pass. What does that prove, and what does it leave open?

    It proves the code agrees with the hand-worked totals. It leaves open whether the token estimates match any real service.

    Related topics

    • The cost formula

    • Latency and throughput

    Previous

    134 / 173

    Next: Latency and Throughput

    Up next

    Up nextLatency and Throughput

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • The Cost Formula
    • A Code-Review Job