Skip to content

[llama-vision] Remove token_idx_cpu parameter#2018

Merged
IlyasMoutawwakil merged 1 commit into
huggingface:mainfrom
ugolowic:int-param-breaks-hpu-graphs
Jun 5, 2025
Merged

[llama-vision] Remove token_idx_cpu parameter#2018
IlyasMoutawwakil merged 1 commit into
huggingface:mainfrom
ugolowic:int-param-breaks-hpu-graphs

Conversation

@ugolowic
Copy link
Copy Markdown
Collaborator

@ugolowic ugolowic commented Jun 5, 2025

It turns out that in the configuration with hpu_graphs, an int-type parameter token_idx_cpu passed to mllama's forward() method causes cache misses in https://github.com/habana-internal/pytorch-integration/blob/GAUDI_v1.21.0_555/python_packages/habana_frameworks/torch/hpu/graphs.py#L618. It's due to the fact that the integer's value changes at each forward call, and the hashing function returns different hash. This leads to the graph not being reused from cache and, in consequence, a performance drop.

Example command:

PT_HPU_LAZY_MODE=1  python3  examples/image-to-text/run_pipeline.py --model_name_or_path meta-llama/Llama-3.2-11B-Vision-Instruct --use_hpu_graphs --limit_hpu_graphs --use_kv_cache --max_new_tokens 2048 --bf16 --batch_size 28  --use_flash_attention --flash_attention_recompute    --sdp_on_bf16 --logits_bf16  --max_input_tokens 128    --ignore_eos --trim_logits

@kalyanjk

Integer parameter token_idx_cpu passed to mllama's forward()
method caused an issue with hpu graph cache which led to
performance drop.

Signed-off-by: Urszula <urszula.golowicz@intel.com>
@ugolowic ugolowic requested a review from regisss as a code owner June 5, 2025 11:07
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@astachowiczhabana
Copy link
Copy Markdown
Collaborator

Hi @IlyasMoutawwakil can we merge this one for 1.18?

@IlyasMoutawwakil IlyasMoutawwakil merged commit 93ae6d7 into huggingface:main Jun 5, 2025
4 checks passed
IlyasMoutawwakil pushed a commit that referenced this pull request Jun 6, 2025
Integer parameter token_idx_cpu passed to mllama's forward()
method caused an issue with hpu graph cache which led to
performance drop.

Signed-off-by: Urszula <urszula.golowicz@intel.com>
astachowiczhabana pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jun 10, 2025
Integer parameter token_idx_cpu passed to mllama's forward()
method caused an issue with hpu graph cache which led to
performance drop.

Signed-off-by: Urszula <urszula.golowicz@intel.com>
astachowiczhabana pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jun 10, 2025
Integer parameter token_idx_cpu passed to mllama's forward()
method caused an issue with hpu graph cache which led to
performance drop.

Signed-off-by: Urszula <urszula.golowicz@intel.com>
gplutop7 pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Oct 15, 2025
* Merge v1.18-release

* Hot fix regional compilation (huggingface#2005)

Co-authored-by: regisss <15324346+regisss@users.noreply.github.com>

* Enable mixtral 8x7b accuracy evaluation (huggingface#1986)

Co-authored-by: Rafal <rbogdanowicz@habana.ai>

* Update readme files for explicit lazy mode (huggingface#1921)

Co-authored-by: Karol Brejna <karol.brejna@intel.com>
Co-authored-by: Piotr Bielak <piotr.bielak@intel.com>

* [llama-vision] Remove token_idx_cpu parameter (huggingface#2018)

Integer parameter token_idx_cpu passed to mllama's forward()
method caused an issue with hpu graph cache which led to
performance drop.

Signed-off-by: Urszula <urszula.golowicz@intel.com>

* Update README examples (huggingface#2020)

* Fix examples in README

audio-classification:
- add space between "False" and backslash

image-to-text:
- add "datasets" to requirements.txt

pytorch-image-models:
- add "datasets" to requirements.txt

sentence-transformers-training/nli:
- add command to properly discover HABANA_VISIBLE_MODULES

sentence-transformers-training/sts:
- add command to properly discover HABANA_VISIBLE_MODULES

speech-recognition:
- add `--trust_remote_code` for seq2seq examples

stable-diffusion/training:
- add missing OpenCV requirement for ControlNet Training

Co-authored-by: Karol Brejna <karol.brejna@intel.com>

* Review fixes: remove grabbing all modules

---------

Co-authored-by: Karol Brejna <karol.brejna@intel.com>
Co-authored-by: karol-brejna-i <karolbrejna@apache.org>

* Pin latest optimum to force mutual updates (huggingface#2016)

pin latest optimum to force mutual updates

* Fix FP8 support and address related issues (huggingface#2010)

- Resolve bugs related to FP8 (floating point 8-bit) computation
- Improve stability and correctness of FP8 operations
- Add/fix tests to validate FP8 functionality
- Update relevant documentation and comments

Co-authored-by: IlyasMoutawwakil

---------

Signed-off-by: Urszula <urszula.golowicz@intel.com>
Co-authored-by: Adam Stachowicz <astachowicz@habana.ai>
Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>
Co-authored-by: regisss <15324346+regisss@users.noreply.github.com>
Co-authored-by: Rafal Bogdanowicz <rafal.bogdanowicz@intel.com>
Co-authored-by: Rafal <rbogdanowicz@habana.ai>
Co-authored-by: Jan Kamiński <jkaminski@habana.ai>
Co-authored-by: Karol Brejna <karol.brejna@intel.com>
Co-authored-by: Piotr Bielak <piotr.bielak@intel.com>
Co-authored-by: Urszula Golowicz <urszula.golowicz@intel.com>
Co-authored-by: Piotr Bielak <pbielak@users.noreply.github.com>
Co-authored-by: karol-brejna-i <karolbrejna@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants