Skip to content

refactor: improve environment and dependency compatibility#963

Open
Jingyuan-zhu wants to merge 2 commits intoOptimalScale:mainfrom
Jingyuan-zhu:fix/infra
Open

refactor: improve environment and dependency compatibility#963
Jingyuan-zhu wants to merge 2 commits intoOptimalScale:mainfrom
Jingyuan-zhu:fix/infra

Conversation

@Jingyuan-zhu
Copy link

@Jingyuan-zhu Jingyuan-zhu commented Feb 10, 2026

Summary

This PR addresses several dependency drift issues that currently prevent LMFlow from running in Python 3.10+ and older stable environments (Python 3.9) and improved conversation template for modern chat models.

Changes

  1. Python 3.9 Backward Compatibility: Replaced PEP 604 union types (|) with typing.Union and updated generic aliases in protocol.py and versioning.py. This restores support for Python 3.9.
  2. Dependency Decoupling: Implemented a lazy loading pattern for sglang_inferencer in auto_pipeline.py to make new user easily run a simple fine-tuning happy path
  3. Upstream API Adaptation: Wrapped transformers.utils.send_example_telemetry in a try-except block to handle its removal in transformers >= 4.41.0.
  4. Standardized optional dependency checks within versioning.py.
  5. Deprecation Cleanup: migrated version checks from deprecated pkg_resources to importlib.metadata + packaging.version in versioning.py. This removes repeated startup deprecation warnings
  6. Conversation template improvements: added conversation_template=tokenizer which requires tokenizer.chat_template and conversation_template=hf_auto which uses tokenizer template if available, otherwise falls back to LMFlow default template. If no template is specified, the system now prefers the tokenizer-native template when available to ensure perfect formatting for modern models

- Restore Python 3.9 support by replacing PEP 604 union types with typing.Union

- Decouple sglang dependency via lazy loading in AutoPipeline

- Fix ImportError by handling the removal of telemetry API in transformers >=4.41
…lity

- Restore Python 3.9 support by replacing PEP 604 union types with typing.Union.
- Decouple sglang dependency via lazy loading in AutoPipeline.
- Fix transformers telemetry API compatibility (>=4.41).
- Replace pkg_resources with importlib.metadata in version checks.
- Improve conversation template robustness:
  - add tokenizer/hf_auto modes
  - strict tokenizer mode with clear error
  - hf_auto fallback path
  - safer assistant mask handling for chat-template tokenization
  - handle missing block_size safely in tokenization flow.
- Add dependency constraints to reduce datasets/pyarrow and transformers drift."
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.

1 participant