Commit 162ee99
authored
VLM: fix EmbeddedInput shape handling, error recovery, and parallel loading (#79)
* VLM: fix tokenCount for 2D tensors, replace precondition with throw
- EmbeddedInput.tokenCount: handle 2D [seq_len, hidden_dim] vs 3D [batch, seq_len, hidden_dim]
- scatterMerge: replace precondition(float16) with guard/throw for bfloat16 compatibility
* Address review: remove premature maxTiles flag, centralize embedding shape handling
- Remove --max-tiles CLI option (tiling model not implemented yet)
- Move seq_len extraction into EmbeddedInput.seqLen(of:) so scatterMerge
and other call sites use one canonical shape resolution path
- tokenCount is now a stored property computed once at init
* Simplify EmbeddedInput: assume 3D [batch, seq_len, hidden_dim] layout
All current VLM models produce 3D embeddings. Drop the 2D fallback
and the seqLen helper -- tokenCount is just shape[1].
* EmbeddedInput: validate exactly 3D shape at init, throw on mismatch
* Fix test: EmbeddedInput.init is now throwing
* Fix test: mark embeddedInputBasics as throws1 parent d5a78c8 commit 162ee99
4 files changed
Lines changed: 18 additions & 14 deletions
File tree
- swift
- Sources
- CoreAILanguageModels/InferenceEngines
- Tools/llm-runner
- Tests/LanguageModelsTests
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
| 388 | + | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | | - | |
564 | | - | |
| 563 | + | |
| 564 | + | |
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| |||
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| |||
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| 374 | + | |
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
0 commit comments