Skip to content

Broadcast tensor shape in distributed offload caches - #857

Open
kylesayrs wants to merge 2 commits into
remove-tie-word-embeddings-meta-defaultfrom
broadcast-offload-tensor-shape
Open

Broadcast tensor shape in distributed offload caches#857
kylesayrs wants to merge 2 commits into
remove-tie-word-embeddings-meta-defaultfrom
broadcast-offload-tensor-shape

Conversation

@kylesayrs

@kylesayrs kylesayrs commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Stacked on top of #856. Review/merge that one first.

Purpose

The distributed CPU and disk offload caches only reconciled dtype divergence between ranks; the non-source (meta-init) rank kept its own tensor shape. For tied/multimodal models, transformers can meta-initialize a parameter with a different shape than the checkpoint tensor materialized on the source rank.

In the CPU cache this makes Tensor.set_() lay the non-source rank's larger layout over the source's smaller shared storage:

RuntimeError: setStorage: sizes [128], strides [1], storage offset 0, and itemsize 4
requiring a storage size of 512 are out of bounds for storage of size 256

Changes

  • Broadcast the source tensor's shape alongside its dtype in DistributedCPUCache.offload and DistributedDiskCache.offload.
  • Rebuild the non-source tensor to match both dtype and shape before pointing it at the shared storage (CPU) / recording the meta placeholder (disk).
  • Add test_load_dist_no_missing_keys, covering multimodal, tied, and untied models under load_offloaded_model in a 2-rank (world_size=2) setup.

Testing

test_load_dist_no_missing_keys passes on 2 GPUs across all four models listed in #856. Without this change, the multimodal/tied gemma-4-1B-0.8B-tiny case fails with the setStorage error above.

Note: full disk offload can't be exercised in CI without an accelerate upgrade (ValueError: You are trying to offload the whole model to the disk), so the disk cache carries the analogous fix for parity but is not covered by a new test.

https://github.com/neuralmagic/llm-compressor-testing/actions/runs/33012761751

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a094839-23ee-465f-ae94-916f1af894f6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Require one maintainer review

All PRs must have at least one approving review from a maintainer before merging.

  • #changes-requested-reviews-by = 0
  • any of:
    • approved-reviews-by=brian-dellabetta
    • approved-reviews-by=HDCharles
    • approved-reviews-by=dsikka
    • approved-reviews-by=kylesayrs

@brian-dellabetta brian-dellabetta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, comment is helpful!

Comment thread src/compressed_tensors/offload/cache/dist_cpu.py Outdated
@mergify

mergify Bot commented Aug 26, 2026

Copy link
Copy Markdown

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages.

kylesayrs and others added 2 commits August 26, 2026 16:53
The distributed CPU and disk caches only reconciled dtype divergence
between ranks; the non-source (meta-init) rank kept its own tensor shape.
For tied/multimodal models, transformers can meta-initialize a parameter
with a different shape than the checkpoint tensor materialized on the
source rank. In the CPU cache, `Tensor.set_()` then lays the non-source
rank's larger layout over the source's smaller shared storage and raises
`setStorage: ... out of bounds`.

Broadcast the source tensor's shape alongside its dtype and rebuild the
non-source tensor to match both before pointing it at the shared storage
(CPU) or recording the meta placeholder (disk). Add
`test_load_dist_no_missing_keys` covering multimodal, tied, and untied
models under `load_offloaded_model` in a 2-rank setup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Brian Dellabetta <brian-dellabetta@users.noreply.github.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
@kylesayrs
kylesayrs force-pushed the broadcast-offload-tensor-shape branch from 3a24b9d to 0e79204 Compare August 26, 2026 20:53
@mergify mergify Bot removed the quality-failed label Aug 26, 2026
@mergify

mergify Bot commented Aug 26, 2026

Copy link
Copy Markdown

The quality checks have failed. Please run make style and make quality under
the root directory to adddress the lint failures. You will need to install the
dev optional install to get the required linting packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants