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
    • Reducing Tokens
      • Prefix Caching
      • Summarisation and Information Loss
      • Retrieval Instead of Pasting
      • Trimming Logs and RTL
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Reducing Tokens
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Tokens, Cost and Latency
  4. Reducing Tokens
  5. Prefix Caching

Reference: Tokens, Cost and Latency · Beginner to Intermediate

Prefix Caching

Identical prompt prefixes can be reused across calls, and small edits decide the saving.

On this page

    What reuse means

    A hosted service can reuse work for a prompt opening it has seen before. The opening must stay identical across calls, since reuse is keyed on exact repetition.

    Whether and how much this saves varies by model and service, so measure it. The concept below holds wherever repeat billings exist: identical input need not be processed twice.

    Belongs in the stable opening

    Belongs in the changing suffix

    Role instructions and output schema

    The new question or task.

    Register maps and protocol summaries

    Fresh log lines since the last call.

    Coding conventions and review checklists

    Retry feedback and new observations.

    A worked saving

    Assume a service counts repeated prefix tokens at 1 unit per million and new tokens at 3 units per million. These are stated EXAMPLE rates, not any real price.

    plaintext
    1
    2
    3
    4
    5
    6
    7
    8
    9
    prefix 6000 tokens, fresh suffix 500 tokens, 10 calls, identical prefix
    without reuse: 10 x (6000 + 500) = 65000 tokens
    cost = 65000 x 3 / 1000000 = 195000 / 1000000 = 0.195 units
    with reuse: first call 6500 new tokens + 9 suffixes of 500
    new tokens = 6500 + 9 x 500 = 6500 + 4500 = 11000
    new cost = 11000 x 3 / 1000000 = 33000 / 1000000 = 0.033 units
    repeated cost = 9 x 6000 x 1 / 1000000 = 54000 / 1000000 = 0.054 units
    total = 0.033 + 0.054 = 0.087 units
    saving = (0.195 - 0.087) / 0.195 = 0.108 / 0.195 = 0.5538... = about 55%

    Bill line

    Tokens

    Cost in units

    First call, full prefix plus suffix

    6500 new

    0.0195

    Nine suffixes

    4500 new

    0.0135

    Nine prefix repeats

    54000 repeated

    0.054

    Total with reuse

    65000

    0.087

    What breaks reuse

    Reuse breaks at the first changed token of the opening. Edits, reordering and even whitespace changes can move everything after them out of the reusable region.

    • Appending new material at the end preserves the longest reusable opening.

    • Editing the middle restarts reuse from the edit point onward.

    • Timestamps and counters in the opening defeat reuse on every call.

    Common mistakes

    Common pitfall

    A run identifier stamped at the top of every prompt makes each opening unique. Reuse then never triggers, so move varying fields to the suffix.

    Interview

    Likely probes: what counts as identical, and where new text goes.

    • Reuse keys on identical openings, so stable text leads and fresh text trails.

    • The worked saving above is about 55% under its stated EXAMPLE rates.

    • Caching behaviour varies by model and service, so every saving is measured, not assumed.

    Check yourself Ten calls share a 6000-token opening, but each stamps a fresh timestamp on line one. How much prefix reuse happens?

    None. The first line differs each time, so no opening repeats.

    Check yourself Under the worked EXAMPLE rates, what does the 10-call session cost with and without reuse?

    Without reuse 0.195 units; with reuse 0.087 units, a saving of about 55%.

    Related topics

    • Summarisation and information loss

    • Cost arithmetic

    • Latency and throughput

    Previous

    139 / 173

    Next: Summarisation and Information Loss

    Up next

    Up nextSummarisation and Information Loss

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Retrieval Instead of Pasting
    • Trimming Logs and RTL