Skip to content

Add feature manager#1926

Merged
regisss merged 6 commits into
huggingface:mainfrom
HabanaAI:auto-pr-1296d0e
Jul 11, 2025
Merged

Add feature manager#1926
regisss merged 6 commits into
huggingface:mainfrom
HabanaAI:auto-pr-1296d0e

Conversation

@astachowiczhabana
Copy link
Copy Markdown
Collaborator

This commit introduces a new feature management system to the repository, which includes functionality to detect and utilize specific hardware features, environment variables, and configurations. It also includes utility functions and test cases to validate the feature detection logic.

Key Changes

  1. New Feature Manager Module:
  • Added optimum/habana/environment.py for managing runtime parameters, detecting the type of Habana device, and retrieving environment information.
  • Added optimum/habana/feature_detection_utils.py for implementing feature detection logic with capabilities like caching, logical operators, and kernel detection.
  • Introduced optimum/habana/features.py for defining specific features like hardware availability, Synapse version ranges, and environment flags.
  1. Integration with Existing Code:
  • Updated examples/text-generation/utils.py and examples/trl/ppo.py to use set_model_config for setting model configuration dynamically.
  • Refactored optimum/habana/transformers/models/llama/modeling_llama.py to utilize the new Feature Manager for conditional imports (e.g., FusedRMSNorm).
  1. Test Suite:
  • Added tests/test_features.py for unit testing feature detection logic.
  • Tests cover hardware detection, environment variable checks, optional model configurations, and logical operators.

Benefits:

  • Modularized feature management for better maintainability and extensibility.
  • Improved hardware compatibility and dynamic configuration handling.
  • Comprehensive test coverage to ensure correctness and reliability.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread optimum/habana/features.py Outdated
@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.

Comment thread optimum/habana/environment.py Outdated
Comment thread optimum/habana/environment.py
@12010486
Copy link
Copy Markdown
Contributor

No objections, also @uartie run some CI tests and they were all passing. Shall we wait for 1.18 to merge it?

@libinta libinta added the run-test Run CI for PRs from external contributors label May 14, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 4, 2025

The code quality check failed, please run make style.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 4, 2025

The code quality check failed, please run make style.

astachowiczhabana added a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jul 8, 2025
astachowiczhabana added a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jul 8, 2025
astachowiczhabana added a commit that referenced this pull request Jul 8, 2025
@astachowiczhabana astachowiczhabana self-assigned this Jul 9, 2025
astachowiczhabana added a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jul 10, 2025
Copy link
Copy Markdown
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move environment.py, feature_detection_utils.py and features.py to a new utils folder in optimum/habana. I'll move checkpoint_utils.py and utils.py there too after.

@github-actions
Copy link
Copy Markdown

The code quality check failed, please run make style.

Copy link
Copy Markdown
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@regisss regisss merged commit ee81dbf into huggingface:main Jul 11, 2025
2 of 4 checks passed
pbielak pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jul 11, 2025
A previous PR [1] introduced a new package `optimum.habana.utils`
which created a conflict with the `optimum/habana/utils.py` file.
This commit adds the missing `utils/__init__.py` file and moves the
`utils.py` file into the `utils/` module (renamed as `misc.py`).

[1] huggingface#1926
pbielak pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jul 11, 2025
A previous PR [1] introduced a new package `optimum.habana.utils`
which created a conflict with the `optimum/habana/utils.py` file.
This commit adds the missing `utils/__init__.py` file and moves the
`utils.py` file into the `utils/` module (renamed as `misc.py`).

[1] huggingface#1926
@pbielak pbielak mentioned this pull request Jul 11, 2025
astachowiczhabana pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Jul 11, 2025
A previous PR [1] introduced a new package `optimum.habana.utils`
which created a conflict with the `optimum/habana/utils.py` file.
This commit adds the missing `utils/__init__.py` file and moves the
`utils.py` file into the `utils/` module (renamed as `misc.py`).

[1] huggingface#1926
astachowiczhabana added a commit that referenced this pull request Jul 11, 2025
Fix utils package

A previous PR [1] introduced a new package `optimum.habana.utils`
which created a conflict with the `optimum/habana/utils.py` file.
This commit adds the missing `utils/__init__.py` file and moves the
`utils.py` file into the `utils/` module (renamed as `misc.py`).

[1] #1926

Co-authored-by: Piotr Bielak <pbielak@habana.ai>
astachowiczhabana added a commit that referenced this pull request Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-test Run CI for PRs from external contributors synapse1.22

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants