Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions examples/models/llama/export_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,6 @@ def _prepare_for_llama_export(llm_config: LlmConfig) -> LLMEdgeManager:
)
)

# Now cast to the dtype override after quantization, so non-quantized
# components use the desired computation dtype.
edge_manager.model = edge_manager.model.to(dtype=dtype_override.to_torch_dtype())

return edge_manager


Expand Down Expand Up @@ -1857,6 +1853,12 @@ def _get_source_transforms( # noqa
)
)

# Cast to dtype_override after quantization transforms, so non-quantized
# components use the desired computation dtype. This must happen before
# _convert_model_for_aarch64 which converts IntxUnpackedToInt8Tensor to
# IntxOpaqueTensor (which doesn't support .to()).
transforms.append(lambda m: m.to(dtype=dtype_override.to_torch_dtype()))

if any([use_torchao_kernels_linear, use_torchao_kernels_tied_embedding]):
from torchao.prototype.tensor_conversion.api import _convert_model_for_aarch64

Expand Down
Loading