Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions backends/qualcomm/serialization/qnn_compile_spec_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class QcomChipset(IntEnum):
SM8450 = 36 # v69
SM8475 = 42 # v69
SM8550 = 43 # v73
SSG2115P = 46 # v73... I wish I can know where the number comes from...
SM8650 = 57 # v75


Expand All @@ -47,6 +48,7 @@ class SocInfo:
QcomChipset.SM8475: SocInfo(QcomChipset.SM8475, HtpInfo(HtpArch.V69, 8)),
QcomChipset.SM8550: SocInfo(QcomChipset.SM8550, HtpInfo(HtpArch.V73, 8)),
QcomChipset.SM8650: SocInfo(QcomChipset.SM8650, HtpInfo(HtpArch.V75, 8)),
QcomChipset.SSG2115P: SocInfo(QcomChipset.SSG2115P, HtpInfo(HtpArch.V73, 2)),
}


Expand Down
3 changes: 2 additions & 1 deletion backends/qualcomm/serialization/schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum QcomChipset: int {
SM8450 = 36,
SM8475 = 42,
SM8550 = 43,
SSG2115P = 46,
SM8650 = 57,
}

Expand Down Expand Up @@ -170,7 +171,7 @@ table QnnExecuTorchOptions {

/// Profiling level of the delegate and the backend. Default is off.
profile_level:QnnExecuTorchProfileLevel;

/// Enables usage of shared buffer between application and backend for graph I/O.
shared_buffer:bool;

Expand Down
1 change: 1 addition & 0 deletions backends/qualcomm/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class TestQNN(unittest.TestCase):
model: QcomChipset = None
compiler_specs: List[CompileSpec] = None
arch_table = {
"SSG2115P": QcomChipset.SSG2115P,
"SM8650": QcomChipset.SM8650,
"SM8550": QcomChipset.SM8550,
"SM8475": QcomChipset.SM8475,
Expand Down
55 changes: 27 additions & 28 deletions examples/models/llama2/export_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@
get_quant_embedding_transform,
get_quant_weight_transform,
)
from .source_transformation.quantized_kv_cache import (
replace_kv_cache_with_quantized_kv_cache,
)

# from .source_transformation.quantized_kv_cache import (
# replace_kv_cache_with_quantized_kv_cache,
# )
from .source_transformation.rms_norm import replace_rms_norm_with_native_rms_norm

from .source_transformation.rope import materialze_broadcast_of_rope_freq_cis
from .source_transformation.sdpa import (
replace_causal_mask,
replace_kv_cache_with_coreml_kv_cache,
replace_kv_cache_with_simple_kv_cache,
replace_sdpa_with_coreml_sdpa,
replace_sdpa_with_custom_op,
replace_sdpa_with_flex_sdpa,
replace_sdpa_with_simple_sdpa,
)

# from .source_transformation.sdpa import (
# replace_causal_mask,
# replace_kv_cache_with_coreml_kv_cache,
# replace_kv_cache_with_simple_kv_cache,
# replace_sdpa_with_coreml_sdpa,
# replace_sdpa_with_custom_op,
# replace_sdpa_with_flex_sdpa,
# replace_sdpa_with_simple_sdpa,
# )

IS_FBCODE = True # os.environ.get("FBCODE_PLATFORM", False)
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
Expand Down Expand Up @@ -893,23 +895,20 @@ def _get_source_transforms( # noqa
assert args.use_kv_cache, "quantize_kv_cache requires use_kv_cache=True"
transforms.append(replace_kv_cache_with_quantized_kv_cache)

if args.qnn:
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.qualcomm.utils.utils`
from executorch.backends.qualcomm.utils.utils import convert_linear_to_conv2d

# transforms.append(replace_kv_cache_with_simple_kv_cache)
# transforms.append(replace_sdpa_with_flex_sdpa)
# transforms.append(replace_causal_mask)
transforms.append(replace_rms_norm_with_native_rms_norm)
if args.optimized_rotation_path:
transforms.append(fuse_layer_norms)
transforms.append(get_model_with_r1_r2(args.optimized_rotation_path))
transforms.append(convert_linear_to_conv2d)
if args.use_kv_cache:
if args.qnn:
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.qualcomm.utils.utils`
from executorch.backends.qualcomm.utils.utils import (
convert_linear_to_conv2d,
)

transforms.append(replace_kv_cache_with_simple_kv_cache)
transforms.append(replace_sdpa_with_flex_sdpa)
transforms.append(replace_causal_mask)
transforms.append(replace_rms_norm_with_native_rms_norm)
if args.optimized_rotation_path:
transforms.append(fuse_layer_norms)
transforms.append(get_model_with_r1_r2(args.optimized_rotation_path))
transforms.append(convert_linear_to_conv2d)

elif args.mps:
if args.mps:
# Currently mps doesn't support sdpa op, use the simpler decomposition
# to get free perf gain.
transforms.append(replace_sdpa_with_simple_sdpa)
Expand Down
Loading