Skip to content
Merged
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
13 changes: 8 additions & 5 deletions .github/workflows/metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,17 @@ jobs:
${CONDA_RUN} huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
echo "::endgroup::"

echo "::group::Setup ExecuTorch"
PYTHON_EXECUTABLE=python ${CONDA_RUN} EXECUTORCH_BUILD_KERNELS_TORCHAO=1 TORCHAO_BUILD_EXPERIMENTAL_MPS=1 ./install_executorch.sh
echo "::endgroup::"

# After install_executorch.sh, whose requirements-examples.txt installs a
# newer transformers than optimum-executorch supports.
echo "::group::Setup Optimum-ExecuTorch"
${CONDA_RUN} pip install "optimum~=2.0.0" "transformers==5.0.0rc1"
OPTIMUM_ET_VERSION=$(cat .ci/docker/ci_commit_pins/optimum-executorch.txt)
echo "Using optimum-executorch version: ${OPTIMUM_ET_VERSION}"
${CONDA_RUN} pip install git+https://github.com/huggingface/optimum-executorch.git@${OPTIMUM_ET_VERSION}
echo "::endgroup::"

echo "::group::Setup ExecuTorch"
PYTHON_EXECUTABLE=python ${CONDA_RUN} EXECUTORCH_BUILD_KERNELS_TORCHAO=1 TORCHAO_BUILD_EXPERIMENTAL_MPS=1 ./install_executorch.sh
${CONDA_RUN} pip install --no-deps git+https://github.com/huggingface/optimum-executorch.git@${OPTIMUM_ET_VERSION}
echo "::endgroup::"

echo "::group::Pip List"
Expand Down
8 changes: 8 additions & 0 deletions examples/qualcomm/oss_scripts/t5/t5_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ def __init__(
self.static_cache.layers[i].values,
persistent=False,
)
self.register_buffer(
f"cumulative_length_{i}",
self.static_cache.layers[i].cumulative_length,
persistent=False,
)

def get_example_inputs(self):
max_hidden_seq_length = self.max_hidden_seq_length
Expand Down Expand Up @@ -402,6 +407,9 @@ def forward(
encoder_attention_mask,
cache_position,
):
# StaticLayer writes at cumulative_length and ignores cache_position.
for layer in self.static_cache.layers:
layer.cumulative_length.copy_(cache_position[0:1])
# Get outputs from decoder
outputs = self.decoder(
input_ids=decoder_input_ids,
Expand Down
8 changes: 8 additions & 0 deletions examples/qualcomm/oss_scripts/whisper/whisper_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ def __init__(self, whisper_model, max_cache_length, batch_size):
self.register_buffer(
f"value_cache_{idx}", self.static_cache.layers[idx].values
)
self.register_buffer(
f"cumulative_length_{idx}",
self.static_cache.layers[idx].cumulative_length,
persistent=False,
)
self.cache = EncoderDecoderCache(self.static_cache, DynamicCache())

def forward(
self, decoder_input_ids, attention_mask, encoder_hidden_states, cache_position
):
# StaticLayer writes at cumulative_length and ignores cache_position.
for layer in self.static_cache.layers:
layer.cumulative_length.copy_(cache_position[0:1])
# Get outputs from decoder
outputs = self.decoder(
input_ids=decoder_input_ids,
Expand Down
Loading