Skip to content

fix: forward-compatible _patched_get_init_context for transformers v5.3.0#1504

Merged
akoumpa merged 4 commits intomainfrom
huiyingl/fix-get-init-context-compat
Mar 10, 2026
Merged

fix: forward-compatible _patched_get_init_context for transformers v5.3.0#1504
akoumpa merged 4 commits intomainfrom
huiyingl/fix-get-init-context-compat

Conversation

@HuiyingLi
Copy link
Contributor

@HuiyingLi HuiyingLi commented Mar 9, 2026

Summary

  • transformers v5.3.0 added a new allow_all_kernels parameter to PreTrainedModel.get_init_context, causing a TypeError: _patched_get_init_context() takes 4 positional arguments but 5 were given
  • Updated _patched_get_init_context to accept *args, **kwargs and forward them, making the patch compatible with both old and new transformers versions

Test plan

  • Verified Qwen3.5-4B VLM finetune recipe runs successfully on single GPU with transformers v5.3.0
  • CI tests pass

🤖 Generated with Claude Code

@copy-pr-bot
Copy link

copy-pr-bot bot commented Mar 9, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

HuiyingLi and others added 2 commits March 9, 2026 14:43
….3.0

transformers v5.3.0 added `allow_all_kernels` parameter to
`PreTrainedModel.get_init_context`. Accept *args/**kwargs so the
patch works with both old and new transformers versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
…lpers

Tests cover:
- Extra args/kwargs forwarding (transformers v5.3.0 allow_all_kernels)
- Meta device filtering with no_hf_meta_device context manager
- Patch installation on PreTrainedModel
- Nested context manager behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi HuiyingLi force-pushed the huiyingl/fix-get-init-context-compat branch from cd4b5d0 to 3b73476 Compare March 9, 2026 21:43
@HuiyingLi
Copy link
Contributor Author

/ok to test 3b73476

@HuiyingLi HuiyingLi linked an issue Mar 9, 2026 that may be closed by this pull request
Consolidate tests into the existing test file rather than creating a
separate test_model_init.py, since test_auto_model.py already tests
other functions from model_init.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@HuiyingLi
Copy link
Contributor Author

/ok to test b8bdad7

akoumpa
akoumpa previously approved these changes Mar 10, 2026
@akoumpa
Copy link
Contributor

akoumpa commented Mar 10, 2026

/ok to test b1afeb9

@akoumpa akoumpa merged commit 4d50a85 into main Mar 10, 2026
52 checks passed
@akoumpa akoumpa deleted the huiyingl/fix-get-init-context-compat branch March 10, 2026 04:16
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.

Training Qwen3.5 dense models not working

2 participants