Skip to content

fix(phi4): restore RoPE export workaround for transformers 5.x - #245

Merged
JakeStevens merged 1 commit into
huggingface:mainfrom
JakeStevens:fix/phi4-longrope-export
Jul 22, 2026
Merged

fix(phi4): restore RoPE export workaround for transformers 5.x#245
JakeStevens merged 1 commit into
huggingface:mainfrom
JakeStevens:fix/phi4-longrope-export

Conversation

@JakeStevens

Copy link
Copy Markdown
Collaborator

transformers 5.x renamed the RoPE config field rope_scaling -> rope_parameters (rope_scaling is now a property alias) and dispatches on the 'rope_type' key instead of 'type'. The existing export workaround only set rope_scaling['type'] = 'default', which no longer takes effect: the model still reads rope_parameters['rope_type'] == 'longrope', keeps the dynamic longrope path, and export fails on the data-dependent branch in longrope_frequency_update.

Add a shared helper disable_dynamic_rope_for_export() used by the causal_lm and multimodal_text_to_text tasks. It sets both 'type' and 'rope_type' to 'default' (compatible with transformers 4.x and 5.x), only downgrades the RoPE types with data-dependent branching (longrope, dynamic), and handles the transformers-5 nested per-layer-type rope dict shape.

@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.

@regisss

regisss commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

@JakeStevens

Copy link
Copy Markdown
Collaborator Author

Yes I've put up:

#246

to try to address that. Seems like /mnt has variable amount of space, I added fallbacks to try /, and to more dynamically size the swap

@JakeStevens
JakeStevens force-pushed the fix/phi4-longrope-export branch from 28a0ef9 to 8e90add Compare July 22, 2026 15:32

@regisss regisss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!
I let you merge the PR since you have write rights now :)

…type key)

transformers 5.x renamed the RoPE config field rope_scaling -> rope_parameters
(rope_scaling is now a property alias) and dispatches on the 'rope_type' key
instead of 'type'. The existing export workaround only set rope_scaling['type']
= 'default', which no longer takes effect: the model still reads
rope_parameters['rope_type'] == 'longrope', keeps the dynamic longrope path, and
export fails on the data-dependent branch in longrope_frequency_update.

Add a shared helper disable_dynamic_rope_for_export() used by the causal_lm and
multimodal_text_to_text tasks. It sets both 'type' and 'rope_type' to 'default'
(compatible with transformers 4.x and 5.x), only downgrades the RoPE types with
data-dependent branching (longrope, dynamic), and handles the transformers-5
nested per-layer-type rope dict shape.
@JakeStevens
JakeStevens force-pushed the fix/phi4-longrope-export branch from 8e90add to 2a0a125 Compare July 22, 2026 16:59
@JakeStevens

Copy link
Copy Markdown
Collaborator Author

all green, beautiful :)

@JakeStevens
JakeStevens merged commit d1140ec into huggingface:main Jul 22, 2026
86 checks passed
@JakeStevens
JakeStevens deleted the fix/phi4-longrope-export branch July 22, 2026 17:43
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