Skip to content

docs: document Windows + Python 3.14 segfault and ship opt-in win_patch - #161

Closed
xiehuanyi wants to merge 1 commit into
NandhaKishorM:mainfrom
xiehuanyi:fix/123-win-py314-note
Closed

xiehuanyi wants to merge 1 commit into
NandhaKishorM:mainfrom
xiehuanyi:fix/123-win-py314-note

Conversation

@xiehuanyi

Copy link
Copy Markdown
Contributor

Relates to #123.

On Windows 11 + Python 3.14 + torch 2.14, any ModernBERT build via transformers segfaults in PreTrainedModel.initialize_weights, so Agent(...) cannot finish loading.

This PR implements the two non-breaking suggestions from the issue (deliberately not the hard requires-python ceiling, which would block users who rely on the workaround):

  • README installation section documents the incompatibility and the two options (use Python 3.11-3.13, or the opt-in patch).
  • New laya/win_patch.py: guarded (Windows + >=3.14 only, no-op elsewhere) no-op for initialize_weights. Safe for laya because Agent.init immediately calls load_state_dict(strict=True), verified against laya/agent.py:194.

Usage: import laya.win_patch before loading laya.

Copilot AI lite review requested due to automatic review settings September 22, 2026 11:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The platform-specific monkeypatch lacks automated coverage for its guard and application behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Documents and provides an opt-in workaround for the Windows/Python 3.14 ModernBERT loading segfault.

Changes:

  • Documents affected environments and workaround options.
  • Adds guarded laya.win_patch monkeypatch.
File Description
README.md Documents the incompatibility and usage.
laya/​win_patch.py Applies the opt-in platform-specific workaround.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread laya/win_patch.py
import transformers.modeling_utils as _mu
except ImportError:
return False
_mu.PreTrainedModel.initialize_weights = lambda self: None
@NandhaKishorM

Copy link
Copy Markdown
Owner

Thank you for documenting the workaround so clearly. #195 landed today and skips the weight-init pass that crashes, on every platform, so the opt-in patch is no longer needed. If you are able to confirm on Windows with Python 3.14 that laya.load() now works without it, please post in #123.

@NandhaKishorM

Copy link
Copy Markdown
Owner

Closing this as no longer needed, which is the outcome you anticipated in the PR itself.

#195 landed in 0.3.7 and skips the weight-init pass that segfaulted, on every platform, so the opt-in laya/win_patch.py has nothing left to patch around. The reporter has since confirmed on Windows 11 with Python 3.14 that laya.load() works without any manual patch, and #162 (merged today) now documents the fix and the upgrade path in the README's troubleshooting section.

Two things I want to credit, because they are why this was easy to act on. You declined to add the hard requires-python ceiling the issue suggested, on the grounds that it would block users relying on the workaround, and you were right; a ceiling would have been the irreversible choice. And the README section documented the crash precisely enough that #195's author could tell their fix addressed the same code path.

Closing as fixed upstream rather than rejected.

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.

3 participants