1. 02 Jul, 2024 1 commit
    • Sanchit Gandhi's avatar
      [whisper] static kv cache (#31166) · a9701953
      Sanchit Gandhi authored
      
      
      * make work with cache abstraction
      
      * correct for static cache
      
      * hacks for compile
      
      * make fast
      
      * fix
      
      * fix pos ids
      
      * generate
      
      * fix sdpa
      
      * fix sdpa cache pos
      
      * fix fa2
      
      * clean fa2
      
      * integrate cache into generate
      
      * make style
      
      * copies
      
      * more copies
      
      * update eager
      
      * update sdpa
      
      * update fa2
      
      * simplify
      
      * use cache pos
      
      * always compute cross-cache for debug
      
      * avoid recompiles
      Co-authored-by: default avatarArthur Zucker <arthur@huggingface.co>
      
      * fix fix
      
      * fix fix fix
      
      * more fix
      
      * try encoder-decoder cache (too messy)
      
      * revert encoder-decoder cache
      
      * check cross-attn cache
      
      * use enc-dec dataclass
      
      * use richer enc-dec dataclass
      
      * clean-up
      
      * revert static cache changes
      
      * small fixes
      
      * revert to cpu flag
      
      * fix copies
      
      * add static slow test
      
      * past k/v docstring
      
      * more docstrings
      
      * cache_position docstrings
      
      * add to docs
      
      * add enc-dec cache to docs
      
      * make style
      
      * fix after rebase
      
      * fix beam
      
      * style
      
      * fix generation strategies
      
      * fix most decoder-only tests
      
      * style
      
      * skip test
      
      * more clean up
      
      * small docstrings
      
      * Apply suggestions from code review
      Co-authored-by: default avatarJoao Gante <joaofranciscocardosogante@gmail.com>
      
      * add todo
      
      * only crop self-attn
      
      * check cache in mixin
      
      * style
      
      * fix re-compile after rebase
      
      * move `is_updated` logic to enc-dec wrapper
      
      * revert back
      
      * revert cache back
      
      * finalise design
      
      * fix
      
      * fix fix
      
      * style
      
      * Update src/transformers/cache_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * deprecate
      
      * updates
      
      * final updates
      
      * style
      
      * style
      
      ---------
      Co-authored-by: default avatarJoao Gante <joaofranciscocardosogante@gmail.com>
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      a9701953
  2. 26 Jun, 2024 1 commit
  3. 17 Jun, 2024 1 commit
    • Albert Villanova del Moral's avatar
      Pass datasets trust_remote_code (#31406) · a14b055b
      Albert Villanova del Moral authored
      * Pass datasets trust_remote_code
      
      * Pass trust_remote_code in more tests
      
      * Add trust_remote_dataset_code arg to some tests
      
      * Revert "Temporarily pin datasets upper version to fix CI"
      
      This reverts commit b7672826.
      
      * Pass trust_remote_code in librispeech_asr_dummy docstrings
      
      * Revert "Pin datasets<2.20.0 for examples"
      
      This reverts commit 833fc17a.
      
      * Pass trust_remote_code to all examples
      
      * Revert "Add trust_remote_dataset_code arg to some tests" to research_projects
      
      * Pass trust_remote_code to tests
      
      * Pass trust_remote_code to docstrings
      
      * Fix flax examples tests requirements
      
      * Pass trust_remote_dataset_code arg to tests
      
      * Replace trust_remote_dataset_code with trust_remote_code in one example
      
      * Fix duplicate trust_remote_code
      
      * Replace args.trust_remote_dataset_code with args.trust_remote_code
      
      * Replace trust_remote_dataset_code with trust_remote_code in parser
      
      * Replace trust_remote_dataset_code with trust_remote_code in dataclasses
      
      * Replace trust_remote_dataset_code with trust_remote_code arg
      a14b055b
  4. 07 Jun, 2024 1 commit
  5. 27 May, 2024 1 commit
  6. 22 May, 2024 1 commit
  7. 20 May, 2024 1 commit
  8. 15 May, 2024 1 commit
  9. 09 May, 2024 1 commit
  10. 19 Apr, 2024 3 commits
  11. 09 Apr, 2024 1 commit
  12. 08 Apr, 2024 1 commit
  13. 03 Apr, 2024 2 commits
  14. 01 Apr, 2024 1 commit
  15. 13 Mar, 2024 1 commit
  16. 12 Mar, 2024 1 commit
  17. 08 Mar, 2024 1 commit
  18. 01 Mar, 2024 1 commit
  19. 27 Feb, 2024 1 commit
  20. 31 Jan, 2024 1 commit
  21. 19 Jan, 2024 1 commit
  22. 18 Jan, 2024 1 commit
  23. 10 Jan, 2024 1 commit
  24. 22 Dec, 2023 1 commit
  25. 21 Dec, 2023 1 commit
  26. 18 Dec, 2023 1 commit
    • Matt's avatar
      More TF fixes (#28081) · 71d47f0a
      Matt authored
      * More build_in_name_scope()
      
      * Make sure we set the save spec now we don't do it with dummies anymore
      
      * make fixup
      71d47f0a
  27. 14 Dec, 2023 1 commit
    • Matt's avatar
      Proper build() methods for TF (#27794) · 050e0b44
      Matt authored
      * Add a convenience method for building in your own name scope
      
      * Second attempt at auto layer building
      
      * Revert "Second attempt at auto layer building"
      
      This reverts commit e03a3aaecf9ec41a805582b83cbdfe3290a631be.
      
      * Attempt #3
      
      * Revert "Attempt #3"
      
      This reverts commit b9df7a0857560d29b5abbed6127d9e9eca77cf47.
      
      * Add missing attributes that we're going to need later
      
      * Add some attributes we're going to need later
      
      * A fourth attempt! Feel the power flow through you!
      
      * Revert "A fourth attempt! Feel the power flow through you!"
      
      This reverts commit 6bf4aaf3875d6f28485f50187617a4c616c8aff7.
      
      * Add more values we'll need later
      
      * TF refactor that we'll need later
      
      * Revert "TF refactor that we'll need later"
      
      This reverts commit ca07202fb5b7b7436b893baa8d688b4f348ea7b9.
      
      * Revert "Revert "TF refactor that we'll need later""
      
      This reverts commit 1beb0f39f293ed9c27594575e1c849aadeb15c13.
      
      * make fixup
      
      * Attempt five!
      
      * Revert "Attempt five!"
      
      This reverts commit 3302207958dfd0374b0447a51c06eea51a506044.
      
      * Attempt six - this time don't add empty methods
      
      * Revert "Attempt six - this time don't add empty methods"
      
      This reverts commit 67d60129be75416b6beb8f47c7d38d77b18d79bb.
      
      * Attempt seven - better base model class detection!
      
      * Revert "Attempt seven - better base model class detection!"
      
      This reverts commit 5f14845e92ea0e87c598da933bfbfee10f553bc9.
      
      * Another attribute we'll need later
      
      * Try again with the missing attribute!
      
      * Revert "Try again with the missing attribute!"
      
      This reverts commit 760c6f30c5dffb3e04b0e73c34a77d1882a0fef7.
      
      * This is the attempt that will pierce the heavens!
      
      * Revert "This is the attempt that will pierce the heavens!"
      
      This reverts commit c868bb657de057aca7a5260350a3f831fc4dfee6.
      
      * Attempt seven - snag list is steadily decreasing
      
      * Revert "Attempt seven - snag list is steadily decreasing"
      
      This reverts commit 46fbd975deda64429bfb3e5fac4fc0370c00d316.
      
      * Attempt eight - will an empty snag list do it?
      
      * Revert "Attempt eight - will an empty snag list do it?"
      
      This reverts commit 7c8a3c2b083253649569e9877e02054ae5cec67b.
      
      * Fixes to Hubert issues that cause problems later
      
      * Trying again with Conv1D/SeparableConv fixes
      
      * Revert "Trying again with Conv1D/SeparableConv fixes"
      
      This reverts commit 55092bca952bc0f750aa1ffe246a640bf1e2036e.
      
      * Apply the build shape fixes to Wav2Vec2 as well
      
      * One more attempt!
      
      * Revert "One more attempt!"
      
      This reverts commit 5ac3e4cb01b9458cc93312873725f9444ae7261c.
      
      * Another attempt!
      
      * Revert "Another attempt!"
      
      This reverts commit ea16d890e019d7de8792a3b8e72f3b1c02adae50.
      
      * Let's see how many failures we get without the internal build method
      
      * Fix OpenAI
      
      * Fix MobileBERT
      
      * (Mostly) fix GroupVIT
      
      * Fix BLIP
      
      * One more BLIP fix
      
      * One more BLIP fix!
      
      * Fix Regnet
      
      * Finally fully fix GroupViT
      
      * Fix Data2Vec and add the new AdaptivePool
      
      * Fix Segformer
      
      * Fix Albert
      
      * Fix Deberta/DebertaV2
      
      * Fix XLM
      
      * Actually fix XLM
      
      * Fix Flaubert
      
      * Fix lxmert
      
      * Fix Resnet
      
      * Fix ConvBERT
      
      * Fix ESM
      
      * Fix Convnext / ConvnextV2
      
      * Fix SAM
      
      * Fix Efficientformer
      
      * Fix LayoutLMv3
      
      * Fix speech_to_text
      
      * Fix mpnet and mobilevit
      
      * Fix Swin
      
      * Fix CTRL
      
      * Fix CVT
      
      * Fix DPR
      
      * Fix Wav2Vec2
      
      * Fix T5
      
      * Fix Hubert
      
      * Fix GPT2
      
      * Fix Whisper
      
      * Fix DeiT
      
      * Fix the encoder-decoder / dual-encoder classes
      
      * make fix-copies
      
      * build in name scope
      
      * Fix summarization test
      
      * Fix tied weight names for BART + Blenderbot
      
      * Fix tied weight name building
      
      * Fix to TFESM weight building
      
      * Update TF SAM
      
      * Expand all the shapes out into Big Boy Shapes
      050e0b44
  28. 08 Dec, 2023 1 commit
    • fxmarty's avatar
      F.scaled_dot_product_attention support (#26572) · 80377eb0
      fxmarty authored
      
      
      * add sdpa
      
      * wip
      
      * cleaning
      
      * add ref
      
      * yet more cleaning
      
      * and more :)
      
      * wip llama
      
      * working llama
      
      * add output_attentions=True support
      
      * bigcode sdpa support
      
      * fixes
      
      * gpt-bigcode support, require torch>=2.1.1
      
      * add falcon support
      
      * fix conflicts falcon
      
      * style
      
      * fix attention_mask definition
      
      * remove output_attentions from attnmaskconverter
      
      * support whisper without removing any Copied from statement
      
      * fix mbart default to eager renaming
      
      * fix typo in falcon
      
      * fix is_causal in SDPA
      
      * check is_flash_attn_2_available in the models init as well in case the model is not initialized through from_pretrained
      
      * add warnings when falling back on the manual implementation
      
      * precise doc
      
      * wip replace _flash_attn_enabled by config.attn_implementation
      
      * fix typo
      
      * add tests
      
      * style
      
      * add a copy.deepcopy on the config in from_pretrained, as we do not want to modify it inplace
      
      * obey to config.attn_implementation if a config is passed in from_pretrained
      
      * fix is_torch_sdpa_available when torch is not installed
      
      * remove dead code
      
      * Update src/transformers/modeling_attn_mask_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_attn_mask_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_attn_mask_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_attn_mask_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_attn_mask_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/models/bart/modeling_bart.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * remove duplicate pretraining_tp code
      
      * add dropout in llama
      
      * precise comment on attn_mask
      
      * add fmt: off for _unmask_unattended docstring
      
      * precise num_masks comment
      
      * nuke pretraining_tp in LlamaSDPAAttention following Arthur's suggestion
      
      * cleanup modeling_utils
      
      * backward compatibility
      
      * fix style as requested
      
      * style
      
      * improve documentation
      
      * test pass
      
      * style
      
      * add _unmask_unattended tests
      
      * skip meaningless tests for idefics
      
      * hard_check SDPA requirements when specifically requested
      
      * standardize the use if XXX_ATTENTION_CLASSES
      
      * fix SDPA bug with mem-efficient backend on CUDA when using fp32
      
      * fix test
      
      * rely on SDPA is_causal parameter to handle the causal mask in some cases
      
      * fix FALCON_ATTENTION_CLASSES
      
      * remove _flash_attn_2_enabled occurences
      
      * fix test
      
      * add OPT to the list of supported flash models
      
      * improve test
      
      * properly test on different SDPA backends, on different dtypes & properly handle separately the pad tokens in the test
      
      * remove remaining _flash_attn_2_enabled occurence
      
      * Update src/transformers/modeling_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/modeling_attn_mask_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update docs/source/en/perf_infer_gpu_one.md
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * remove use_attn_implementation
      
      * fix docstring & slight bug
      
      * make attn_implementation internal (_attn_implementation)
      
      * typos
      
      * fix tests
      
      * deprecate use_flash_attention_2=True
      
      * fix test
      
      * add back llama that was removed by mistake
      
      * fix tests
      
      * remove _flash_attn_2_enabled occurences bis
      
      * add check & test that passed attn_implementation is valid
      
      * fix falcon torchscript export
      
      * fix device of mask in tests
      
      * add tip about torch.jit.trace and move bt doc below sdpa
      
      * fix parameterized.expand order
      
      * move tests from test_modeling_attn_mask_utils to test_modeling_utils as a relevant test class is already there
      
      * update sdpaattention class with the new cache
      
      * Update src/transformers/configuration_utils.py
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      
      * Update src/transformers/models/bark/modeling_bark.py
      
      * address review comments
      
      * WIP torch.jit.trace fix. left: test both eager & sdpa
      
      * add test for torch.jit.trace for both eager/sdpa
      
      * fix falcon with torch==2.0 that needs to use sdpa
      
      * fix doc
      
      * hopefully last fix
      
      * fix key_value_length that has no default now in mask converter
      
      * is it flacky?
      
      * fix speculative decoding bug
      
      * tests do pass
      
      * fix following #27907
      
      ---------
      Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
      80377eb0
  29. 23 Nov, 2023 1 commit
  30. 22 Nov, 2023 1 commit
    • Patrick von Platen's avatar
      [Whisper] Add sequential longform decoding (#27492) · 4151fbb4
      Patrick von Platen authored
      * [Whisper] Add seq gen
      
      * [Whisper] Add seq gen
      
      * more debug
      
      * Fix whisper logit processor
      
      * Improve whisper code further
      
      * Fix more
      
      * more debug
      
      * more debug
      
      * Improve further
      
      * Add tests
      
      * Prep for batch size > 1
      
      * Get batch_size>1 working
      
      * Correct more
      
      * Add extensive tests
      
      * more debug
      
      * more debug
      
      * more debug
      
      * add more tests
      
      * more debug
      
      * Apply suggestions from code review
      
      * more debug
      
      * add comments to explain the code better
      
      * add comments to explain the code better
      
      * add comments to explain the code better
      
      * Add more examples
      
      * add comments to explain the code better
      
      * fix more
      
      * add comments to explain the code better
      
      * add comments to explain the code better
      
      * correct
      
      * correct
      
      * finalize
      
      * Apply suggestions from code review
      
      * Apply suggestions from code review
      4151fbb4
  31. 16 Nov, 2023 2 commits
    • Arthur's avatar
      [`Styling`] stylify using ruff (#27144) · 651408a0
      Arthur authored
      
      
      * try to stylify using ruff
      
      * might need to remove these changes?
      
      * use ruf format andruff check
      
      * use isinstance instead of type comparision
      
      * use # fmt: skip
      
      * use # fmt: skip
      
      * nits
      
      * soem styling changes
      
      * update ci job
      
      * nits isinstance
      
      * more files update
      
      * nits
      
      * more nits
      
      * small nits
      
      * check and format
      
      * revert wrong changes
      
      * actually use formatter instead of checker
      
      * nits
      
      * well docbuilder is overwriting this commit
      
      * revert notebook changes
      
      * try to nuke docbuilder
      
      * style
      
      * fix feature exrtaction test
      
      * remve `indent-width = 4`
      
      * fixup
      
      * more nits
      
      * update the ruff version that we use
      
      * style
      
      * nuke docbuilder styling
      
      * leve the print for detected changes
      
      * nits
      
      * Remove file I/O
      Co-authored-by: default avatarcharliermarsh <charlie.r.marsh@gmail.com>
      
      * style
      
      * nits
      
      * revert notebook changes
      
      * Add # fmt skip when possible
      
      * Add # fmt skip when possible
      
      * Fix
      
      * More `  # fmt: skip` usage
      
      * More `  # fmt: skip` usage
      
      * More `  # fmt: skip` usage
      
      * NIts
      
      * more fixes
      
      * fix tapas
      
      * Another way to skip
      
      * Recommended way
      
      * Fix two more fiels
      
      * Remove asynch
      Remove asynch
      
      ---------
      Co-authored-by: default avatarcharliermarsh <charlie.r.marsh@gmail.com>
      651408a0
    • Patrick von Platen's avatar
      Revert "add attention_mask and position_ids in assisted model" (#27523) · 5603fad2
      Patrick von Platen authored
      * Revert "add attention_mask and position_ids in assisted model (#26892)"
      
      This reverts commit 184f60dc.
      
      * more debug
      5603fad2
  32. 09 Nov, 2023 1 commit
  33. 01 Nov, 2023 3 commits
  34. 31 Oct, 2023 1 commit
    • Hz, Ji's avatar
      device agnostic models testing (#27146) · 50378cbf
      Hz, Ji authored
      * device agnostic models testing
      
      * add decorator `require_torch_fp16`
      
      * make style
      
      * apply review suggestion
      
      * Oops, the fp16 decorator was misused
      50378cbf