Commit cf14432
authored
[safetnesors] increase index.json parse limit from 10MB -> 20MB (#1790)
## Fix parsing of large safetensors index files (>10MB)
### Problem
Models with large index files (>10MB) were failing to parse. The code
was truncating index files at 10MB, causing JSON parsing errors for
models with many experts/shards.
**Failure example:**
[moonshotai/Kimi-K2-Instruct-0905](https://huggingface.co/moonshotai/Kimi-K2-Instruct-0905)
has a 13.5MB index file (384 experts per layer, 62 shards) and was
failing with:
```
Failed to parse file model.safetensors.index.json: not a valid JSON.
```
### Solution
- Increased index file size limit from 10MB to 20MB in
`parse-safetensors-metadata.ts`
- Added test case for large index files using the moonshotai model
### Changes
- `packages/hub/src/lib/parse-safetensors-metadata.ts`: Bump limit from
`10_000_000` to `20_000_000` bytes
- `packages/hub/src/lib/parse-safetensors-metadata.spec.ts`: Add
comprehensive test for large index files1 parent e081bf7 commit cf14432
File tree
2 files changed
+12
-1
lines changed- packages/hub/src/lib
2 files changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
305 | 316 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
0 commit comments