Skip to content

Conversation

@juncgu-google
Copy link
Collaborator

@juncgu-google juncgu-google commented Nov 11, 2025

Description

Add a staging buffer manager to book-keep the # of used staging blocks (page / chunk) for swap- in / out. This should be helpful in mitigating the OOM issue when kv cache offloading is handling very large of save / load blocks.

  1. staging buffer size is controlled by env var: TPU_OFFLOAD_STAGING_BUFFER_TOKENS=8192. we will find a way to specify the buffer size in GB instead of in tokens.
  2. when there are insufficient staging buffers for the incoming save / load operations, we will drop the extra save / load blocks.

Tests

pytest -sv tests/distrbuted/cpu_offloading_scheduler_test.py

Checklist

Before submitting this PR, please make sure:

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have made or will make corresponding changes to any relevant documentation.

@github-actions
Copy link

Description

Start with a short description of what the PR does and how this is a change from
the past.

The rest of the description includes relevant details and context, examples:

  • why is this change being made,
  • the problem being solved and any relevant context,
  • why this is a good solution,
  • some information about the specific implementation,
  • shortcomings of the solution and possible future improvements.

If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/123456
FIXES: #123456

Tests

Please describe how you tested this change, and include any instructions and/or
commands to reproduce.

Checklist

Before submitting this PR, please make sure:

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have made or will make corresponding changes to any relevant documentation.

Signed-off-by: Juncheng Gu <[email protected]>
@juncgu-google juncgu-google force-pushed the cpu-offloading/dev-1110 branch from 6d987d7 to c25e534 Compare November 12, 2025 23:42
@saikat-royc
Copy link
Collaborator

aligned with the high level appraoch on the block tracking, reporting and staging buffer budgeting. let's also add unit tests for added confidence in the PR

@juncgu-google juncgu-google changed the title [TPU Offload][WIP] Manage staging buffer in HBM [TPU Offload]Manage staging buffer in HBM Nov 14, 2025
Copy link
Collaborator

@saikat-royc saikat-royc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work on the unit tests!

Signed-off-by: Juncheng Gu <[email protected]>
@juncgu-google
Copy link
Collaborator Author

Thanks for the reviews!

@juncgu-google juncgu-google merged commit f6a6720 into cpu-offloading/dev Nov 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants