Skip to content

fix: remove tensor_name_count retention budget dimension for remote SafeTensors - #1822

Merged
mldangelo-oai merged 4 commits into
promptfoo:mainfrom
ushaket:fix/safetensors-retention-budget-tensor-count
Aug 29, 2026
Merged

fix: remove tensor_name_count retention budget dimension for remote SafeTensors#1822
mldangelo-oai merged 4 commits into
promptfoo:mainfrom
ushaket:fix/safetensors-retention-budget-tensor-count

Conversation

@ushaket

@ushaket ushaket commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #1823

Summary

The tensor_name_count dimension in _HuggingFaceSafeTensorsRetentionBudget caused large multi-shard SafeTensors models to fail closed prematurely. Specifically, RedHatAI/GLM-5.2-FP8 (753B params, 141 safetensors shards, ~756 GB) hit the 65,536 tensor-name cap at shard ~84/141 and produced an incomplete scan (exit 2).

The result_bytes cap (32 MB serialized JSON) already bounds aggregate output size, making tensor_name_count redundant — removing it lets large models complete without losing protection against pathological inputs.

Changes

  • Remove _MAX_HF_SAFETENSORS_RETAINED_TENSOR_NAMES constant and the tensor_name_count exceeded check from _HuggingFaceSafeTensorsRetentionBudget.retain().
  • Remove all references to max_retained_tensor_names in preflight and retain return dicts.
  • Update tests: max-cardinality repository test now expects success (all 100 files scanned), fail-closed test triggers via result_bytes instead.
  • Add CHANGELOG entry under [Unreleased].

The result_count (512) and result_bytes (32 MB) budget dimensions remain unchanged.

Testing

Tested locally against 6 HuggingFace models spanning a wide range of sizes:

Model Params Disk size ST shards Result (fix branch) Result (main)
RedHatAI/SmolLM3-3B-FP8-dynamic 3B ~3.3 GB 1 pass pass
Qwen/Qwen3-8B 8.2B ~16.4 GB 5 pass pass
google/gemma-4-26B-A4B-it 25.2B ~51.6 GB 2 pass pass
RedHatAI/gpt-oss-120b-FP8-Dynamic 120B ~117 GB 24 pass pass
moonshotai/Kimi-K2-Thinking 1T ~594 GB 62 pass pass
RedHatAI/GLM-5.2-FP8 753B ~756 GB 141 pass (all 141 scanned) fail (tensor_name_count exceeded at shard 84)

GLM-5.2-FP8 is the only model that failed on main. All six pass on the fix branch with zero budget failures.

uv run ruff format ... && uv run ruff check ... && uv run mypy ... && uv run pytest -n auto -m "not slow and not integration" --maxfail=1

All clean.

ushaket and others added 4 commits August 25, 2026 14:49
…afeTensors

The tensor_name_count dimension in the HuggingFace SafeTensors retention
budget caused large multi-shard models (e.g. GLM-5.2-FP8 with 141 shards)
to fail closed prematurely at shard ~84/141. The result_bytes cap (32 MB)
already bounds aggregate serialized size, making tensor_name_count redundant.

Remove _MAX_HF_SAFETENSORS_RETAINED_TENSOR_NAMES and the tensor_name_count
exceeded check from the retention budget. The result_count (512) and
result_bytes (32 MB) dimensions remain as protection against pathological
inputs.

Tested locally against 6 HuggingFace models from 16 GB to 594 GB with
zero budget failures. GLM-5.2-FP8 confirmed as the only model affected
on main (budget exceeded at shard 84/141, retained_tensor_names: 65380).

Co-authored-by: Cursor <cursoragent@cursor.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T05:25:09.255805Z e8c4ae2 Manual request
🔒 Security Review Completed 2026-08-29T05:26:02.425144Z e8c4ae2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mldangelo-oai

Copy link
Copy Markdown
Contributor

@codex review

Please review exact head e8c4ae2.

@mldangelo-oai

Copy link
Copy Markdown
Contributor

@codex security review

Please review exact head e8c4ae2.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: e8c4ae2ece

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: e8c4ae2ece

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@mldangelo-oai
mldangelo-oai merged commit 4c24e17 into promptfoo:main Aug 29, 2026
29 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 29, 2026
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.

Remote SafeTensors scan fails closed on large multi-shard models due to tensor_name_count budget

2 participants