Skip to content

Unitxt 1.14.1 - Faster Unitxt 🚀

Compare
Choose a tag to compare
@elronbandel elronbandel released this 27 Oct 11:49
· 102 commits to main since this release
3adcc54

Important Change: Unitxt is Faster!

To improve Unitxt’s performance, we've made several optimizations:

  1. Operator Acceleration: Many operators have been sped up by removing unnecessary deep copying in their code, enhancing runtime efficiency.

  2. Caching Hugging Face Datasets: We added the option to cache Hugging Face datasets in loaders, which can prevent redundant loading operations. To enable this, you can either:

    • Set it globally in code:
      import unitxt
      
      unitxt.settings.disable_hf_datasets_cache = False
    • Use the settings context:
      with settings.context(disable_hf_datasets_cache=False):
          # your code
    • Or set the environment variable:
      export UNITXT_DISABLE_HF_DATASETS_CACHE=False
  3. Eager Execution Mode: Running Unitxt without streaming, which can be faster in certain scenarios. Enable eager execution using the environment variable or directly in code:

    unitxt.settings.use_eager_execution = True
    # or
    with settings.context(use_eager_execution=True):
        # your code
  4. Partial Stream Loading: This feature lets you load only the necessary data instances, avoiding full dataset loads when not required. Here's an example:

    from unitxt import load_dataset
    
    dataset = load_dataset(
        card="cards.doc_vqa.lmms_eval",
        template="templates.qa.with_context.title",
        format="formats.models.llava_interleave",
        loader_limit=300,
        streaming=True,
    )
    print(next(iter(dataset["test"][0])))  # Loads only the first instance

    Complete Example: Combining the optimizations above can lead to near 1000x faster dataset loading:

    from unitxt import load_dataset, settings
    
    with settings.context(
        disable_hf_datasets_cache=False,
        use_eager_execution=True,
    ):
        dataset = load_dataset(
            card="cards.doc_vqa.lmms_eval",
            template="templates.qa.with_context.title",
            format="formats.models.llava_interleave",
            loader_limit=300,
            streaming=True,
        )
        print(next(iter(dataset["test"][0])))  # Loads only the first instance
  5. Execution Speed Tracking: A GitHub action has been added to monitor Unitxt’s execution speed in new pull requests, helping ensure that optimizations are maintained.


Summary

This release is focused on accelerating performance in Unitxt by introducing several key optimizations. Operator efficiency has been enhanced by removing deep copies, making operations faster. Users can now enable dataset caching for Hugging Face datasets to prevent redundant loading, configured directly in code or through environment variables. An optional eager execution mode has been added, bypassing streaming to increase speed in certain scenarios. Additionally, partial stream loading allows selective instance loading, reducing memory usage and improving response times. To maintain these improvements, a new GitHub action now monitors Unitxt’s execution speed in pull requests, ensuring consistent performance across updates.

All Changes

New Contributors

Full Changelog: 1.13.1...1.14.1