Skip to content

Commit 341e36e

Browse files
feat: vision encoder should always be exported with float32
1 parent 00fc22d commit 341e36e

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

examples/models/lfm2_5_vl/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ python examples/models/lfm2_5_vl/export_lfm2_5_vl.py \
2222
--dtype fp32
2323
```
2424

25-
With quantization (8da4w decoder + int8 embedding):
25+
With quantization (8da4w decoder + int8 embedding + float32 vision encoder):
2626

2727
```bash
2828
python examples/models/lfm2_5_vl/export_lfm2_5_vl.py \
2929
--model_dir LiquidAI/LFM2-VL-1.6B \
3030
--quantize
3131
```
3232

33-
## Runner Compatibility
34-
35-
The exported PTE is compatible with `llava_main` (the ExecuTorch multimodal C++ runner). Method names match `extension/llm/runner/constants.h`.
36-
3733
### Required runner configuration
3834

3935
- Resize image to exactly 512×512

examples/models/lfm2_5_vl/export_lfm2_5_vl.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ def export(self) -> "Lfm2p5VlEdgeManager":
8888
return self
8989

9090

91-
def export_image_encoder(
92-
lfm2, quantize: bool = False
93-
) -> torch.export.ExportedProgram:
91+
def export_image_encoder(lfm2, quantize: bool = False) -> torch.export.ExportedProgram:
9492
"""Export vision encoder as 'vision_encoder' method.
9593
9694
Input: [1, 3, 512, 512] float32 NCHW pixels in [0, 255]
@@ -120,9 +118,7 @@ def forward(self, images: torch.Tensor) -> torch.Tensor:
120118

121119
if quantize:
122120
logging.info("Exporting vision encoder (int8 dynamic quantized)...")
123-
quantizer = XNNPACKQuantizer().set_global(
124-
get_symmetric_quantization_config()
125-
)
121+
quantizer = XNNPACKQuantizer().set_global(get_symmetric_quantization_config())
126122
manager = (
127123
Lfm2p5VlEdgeManager(
128124
model=encoder,
@@ -285,7 +281,7 @@ def export_all(
285281
lfm2 = lfm2.to(dtype.to_torch_dtype())
286282

287283
logging.info("[1/3] Exporting vision encoder...")
288-
vision_ep = export_image_encoder(lfm2, quantize)
284+
vision_ep = export_image_encoder(lfm2, quantize=False)
289285

290286
# Text decoder MUST come before token embedding (see export_token_embedding docstring)
291287
logging.info("[2/3] Exporting text decoder...")

0 commit comments

Comments
 (0)