From 3921676ad0a583de7ce34e0545e40ff4274ce659 Mon Sep 17 00:00:00 2001 From: Chen Lai Date: Tue, 5 Aug 2025 10:16:05 -0700 Subject: [PATCH] forward fix (#13129) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/13129 Fix the test ``` buck test 'fbcode//mode/opt' fbcode//gen_ai/genie_projects/bonsai/tests/models:test_models -- --exact 'gen_ai/genie_projects/bonsai/tests/models:test_models - test_executorch_staticllama_models (gen_ai.genie_projects.bonsai.tests.models.test_model_def.TestModelDef)' ``` Reviewed By: psiddh, kirklandsign Differential Revision: D79597179 --- examples/qualcomm/oss_scripts/llama/model/static_llama.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/qualcomm/oss_scripts/llama/model/static_llama.py b/examples/qualcomm/oss_scripts/llama/model/static_llama.py index 192f23de302..49b38445c6a 100755 --- a/examples/qualcomm/oss_scripts/llama/model/static_llama.py +++ b/examples/qualcomm/oss_scripts/llama/model/static_llama.py @@ -70,7 +70,7 @@ def __init__(self, config: ModelArgs, output_new_cache_only=False): self.scale = float(self.head_dim) ** 0.5 - if config.enable_r3: + if hasattr(config, "enable_r3") and config.enable_r3: self.register_buffer( "r3_weight", torch.tensor( @@ -186,11 +186,11 @@ def forward_sha( ] for i in range(len(q)): q[i] = apply_rotary_emb_single(q[i], freqs_cos, freqs_sin) - if self.config.enable_r3: + if hasattr(self.config, "enable_r3") and self.config.enable_r3: q[i] = torch.matmul(q[i], self.r3_weight.T) for i in range(len(k)): k[i] = apply_rotary_emb_single(k[i], freqs_cos, freqs_sin) - if self.config.enable_r3: + if hasattr(self.config, "enable_r3") and self.config.enable_r3: k[i] = torch.matmul(k[i], self.r3_weight.T) k[i] = k[i].transpose(1, 2)