Move `original_max_position_embeddings` to rope params 
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

As per title, resolves the TODO from Joao and moves patching for `original_max_position_embeddings` inside rope dict standardization. That way, `original_max_position_embeddings` is moved to the correct field once at init time and we can delete similar patches from individual rope func. Note that this is not a breaking change, instead we move near-duplicate code to a single place



cc @hmellor 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42513). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3

This comment contains `run-slow`, running the specified jobs: 

models: ["models/deepseek_v3", "models/gemma2", "models/gemma3", "models/llama", "models/mistral", "models/phi", "models/phi3", "models/qwen2", "models/qwen2_vl"]
quantizations: []


run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3



## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19854717321)

### Model CI Report

#### ❌ Failed tests

- [gemma3](https://github.com/huggingface/transformers/actions/runs/19854717321/job/56890347395):
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_can_load_with_global_device_set
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_can_load_with_global_device_set
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_bc_torch_dtype
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_can_load_ignoring_mismatched_shapes
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_can_load_with_device_context_manager
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_can_use_safetensors
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_cannot_load_with_meta_device_context_manager
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_causal_lm_can_accept_training_kwargs
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_config
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_config_attn_implementation_setter
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_correct_missing_keys
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_cpu_offload
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_disk_offload_bin
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_disk_offload_safetensors
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_generate
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_00_fp16_pad_left_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_01_fp16_pad_left
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_02_fp16_pad_left_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_03_fp16_pad_left_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_04_fp16_pad_right_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_05_fp16_pad_right
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_06_fp16_pad_right_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_07_fp16_pad_right_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_08_fp32_pad_left_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_09_fp32_pad_left
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_10_fp32_pad_left_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_11_fp32_pad_left_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_12_fp32_pad_right_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_13_fp32_pad_right
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_14_fp32_pad_right_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_15_fp32_pad_right_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_16_bf16_pad_left_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_17_bf16_pad_left
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_18_bf16_pad_left_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_19_bf16_pad_left_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_20_bf16_pad_right_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_21_bf16_pad_right
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_22_bf16_pad_right_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_23_bf16_pad_right_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_eager_matches_sdpa_inference_24_fp32_pad_left_output_attentions
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_generation_beyond_sliding_window_tiny_model
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_load_save_without_tied_weights
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_model_rope_scaling_frequencies
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_model_weights_reload_no_missing_tied_weights
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_save_load
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_sdpa_can_compile_dynamic
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_sdpa_can_dispatch_non_composite_models
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3TextModelTest::test_sdpa_can_dispatch_on_flash
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_automodelforcausallm
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_bc_torch_dtype
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_can_load_from_already_mapped_keys
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_can_load_ignoring_mismatched_shapes
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_can_load_with_device_context_manager
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_can_use_safetensors
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_cannot_load_with_meta_device_context_manager
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_config_attn_implementation_setter
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_generate
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_00_fp16_pad_left_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_01_fp16_pad_left
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_02_fp16_pad_left_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_03_fp16_pad_left_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_04_fp16_pad_right_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_05_fp16_pad_right
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_06_fp16_pad_right_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_07_fp16_pad_right_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_08_fp32_pad_left_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_09_fp32_pad_left
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_10_fp32_pad_left_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_11_fp32_pad_left_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_12_fp32_pad_right_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_13_fp32_pad_right
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_14_fp32_pad_right_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_15_fp32_pad_right_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_16_bf16_pad_left_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_17_bf16_pad_left
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_18_bf16_pad_left_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_19_bf16_pad_left_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_20_bf16_pad_right_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_21_bf16_pad_right
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_22_bf16_pad_right_no_attn_mask_sdpa_kernels
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_23_bf16_pad_right_no_attn_mask
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_eager_matches_sdpa_inference_24_fp32_pad_left_output_attentions
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_load_save_without_tied_weights
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_model_weights_reload_no_missing_tied_weights
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_reverse_loading_mapping
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_save_load
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_sdpa_can_compile_dynamic
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3Vision2TextModelTest::test_sdpa_can_dispatch_non_composite_models
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_dynamic_sliding_window_is_default
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_export_text_only
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_generation_beyond_sliding_window_1_sdpa
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_generation_beyond_sliding_window_2_eager
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_model_1b_text_only
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_model_4b_batch
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_model_4b_batch_crops
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_model_4b_bf16
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_model_4b_crops
    tests/models/gemma3/test_modeling_gemma3.py::Gemma3IntegrationTest::test_model_4b_multiimage

- [phi3](https://github.com/huggingface/transformers/actions/runs/19854717321/job/56890347445):
    tests/models/phi3/test_modeling_phi3.py::Phi3IntegrationTest::test_model_phi3_mini_128k_instruct_logits




run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3




run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3




run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3




run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3




run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3



run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3

💔 This comment contains `run-slow`, but unknown error occurred and [the workflow run](https://github.com/huggingface/transformers/actions/runs/19924840076) aborted!

run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3

run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3

This comment contains `run-slow`, running the specified jobs: 

models: ["models/deepseek_v3", "models/gemma2", "models/gemma3", "models/llama", "models/mistral", "models/phi", "models/phi3", "models/qwen2", "models/qwen2_vl"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19925184112)

### Model CI Report

#### ❌ Failed tests

- [phi3](https://github.com/huggingface/transformers/actions/runs/19925184112/job/57123515318):
    tests/models/phi3/test_modeling_phi3.py::Phi3IntegrationTest::test_model_phi3_mini_128k_instruct_logits



oke, i broke phi longrope apparently

Hope it works 🤞🏻 

run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3



run-slow: phi3, phi, llama, mistral, mistral, qwen2_vl, deepseek_v3, qwen2, gemma2, gemma3



This comment contains `run-slow`, running the specified jobs: 

models: ["models/deepseek_v3", "models/gemma2", "models/gemma3", "models/llama", "models/mistral", "models/phi", "models/phi3", "models/qwen2", "models/qwen2_vl"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19962235018)

✅ No failing test specific to this PR 🎉 !


> ## CI Results
> [Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/19962235018)
> 
> ✅ No failing test specific to this PR 🎉 !

what a wonderful Friday afternoon 🥳 

run-slow: glm4v_moe

This comment contains `run-slow`, running the specified jobs: 

models: ["models/glm4v_moe"]
quantizations: []

Thanks for reviews, I will merge it when tokenization CI is fixed on main, no rush for this PR 

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/20030495156)

✅ No failing test specific to this PR 🎉 !


I think we can ignore 

`TestMistralCommonBackend`



yeah, definitely, it is failing in all PRs currently

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: gemma3

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=42513&sha=264fb4