-
Notifications
You must be signed in to change notification settings - Fork 598
feat(models): add qwen3.5-35b-a3b-fp8 model config and HuggingFace mapping #5076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr/fp8-orbax-restoration
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -912,6 +912,18 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"{prefix}-attention-attention-out-kernel": [ | ||||||||||||||
| f"model.language_model.layers.{i}.self_attn.o_proj.weight" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-attention-query-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.self_attn.q_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-attention-key-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.self_attn.k_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-attention-value-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.self_attn.v_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-attention-out-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.self_attn.o_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-attention-query_norm-scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.self_attn.q_norm.weight" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
|
|
@@ -940,6 +952,20 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| ) | ||||||||||||||
| for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-in_proj_qkvz-kernel_scale": [ | ||||||||||||||
| ( | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_qkv.weight_scale", | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_z.weight_scale", | ||||||||||||||
| ) | ||||||||||||||
| for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-in_proj_ba-kernel_scale": [ | ||||||||||||||
| ( | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_b.weight_scale", | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_a.weight_scale", | ||||||||||||||
| ) | ||||||||||||||
| for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-conv1d-kernel": [ | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.conv1d.weight" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
|
|
@@ -953,6 +979,9 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"{prefix}-attention-out_proj-kernel": [ | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.out_proj.weight" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-attention-out_proj-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.out_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| } | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -974,6 +1003,18 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"{prefix}-mlp-shared_expert_gate-kernel": [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.shared_expert_gate.weight" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wi_0-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.shared_expert.gate_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wi_1-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.shared_expert.up_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wo-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.shared_expert.down_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-mlp-shared_expert_gate-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.shared_expert_gate.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| } | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -986,6 +1027,12 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| (f"{prefix}-mlp-routed_experts-wi_0", f"{prefix}-mlp-routed_experts-wi_1"): [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.experts.gate_up_proj" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| f"{prefix}-mlp-routed_experts-wo-kernel_scale": [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.experts.down_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| (f"{prefix}-mlp-routed_experts-wi_0-kernel_scale", f"{prefix}-mlp-routed_experts-wi_1-kernel_scale"): [ | ||||||||||||||
| f"model.language_model.layers.{i}.mlp.experts.gate_up_proj.weight_scale" for i in hf_indices | ||||||||||||||
| ], | ||||||||||||||
| } | ||||||||||||||
| ) | ||||||||||||||
| else: | ||||||||||||||
|
|
@@ -1009,6 +1056,10 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"{prefix}-attention-attention-key-kernel": f"model.language_model.layers.{i}.self_attn.k_proj.weight", | ||||||||||||||
| f"{prefix}-attention-attention-value-kernel": f"model.language_model.layers.{i}.self_attn.v_proj.weight", | ||||||||||||||
| f"{prefix}-attention-attention-out-kernel": f"model.language_model.layers.{i}.self_attn.o_proj.weight", | ||||||||||||||
| f"{prefix}-attention-attention-query-kernel_scale": f"model.language_model.layers.{i}.self_attn.q_proj.weight_scale", | ||||||||||||||
| f"{prefix}-attention-attention-key-kernel_scale": f"model.language_model.layers.{i}.self_attn.k_proj.weight_scale", | ||||||||||||||
| f"{prefix}-attention-attention-value-kernel_scale": f"model.language_model.layers.{i}.self_attn.v_proj.weight_scale", | ||||||||||||||
| f"{prefix}-attention-attention-out-kernel_scale": f"model.language_model.layers.{i}.self_attn.o_proj.weight_scale", | ||||||||||||||
| f"{prefix}-attention-attention-query_norm-scale": f"model.language_model.layers.{i}.self_attn.q_norm.weight", | ||||||||||||||
| f"{prefix}-attention-attention-key_norm-scale": f"model.language_model.layers.{i}.self_attn.k_norm.weight", | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -1027,11 +1078,20 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_b.weight", | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_a.weight", | ||||||||||||||
| ), | ||||||||||||||
| f"{prefix}-attention-in_proj_qkvz-kernel_scale": ( | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_qkv.weight_scale", | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_z.weight_scale", | ||||||||||||||
| ), | ||||||||||||||
| f"{prefix}-attention-in_proj_ba-kernel_scale": ( | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_b.weight_scale", | ||||||||||||||
| f"model.language_model.layers.{i}.linear_attn.in_proj_a.weight_scale", | ||||||||||||||
| ), | ||||||||||||||
| f"{prefix}-attention-conv1d-kernel": f"model.language_model.layers.{i}.linear_attn.conv1d.weight", | ||||||||||||||
| f"{prefix}-attention-A_log": f"model.language_model.layers.{i}.linear_attn.A_log", | ||||||||||||||
| f"{prefix}-attention-dt_bias": f"model.language_model.layers.{i}.linear_attn.dt_bias", | ||||||||||||||
| f"{prefix}-attention-norm-rms_norm-scale": f"model.language_model.layers.{i}.linear_attn.norm.weight", | ||||||||||||||
| f"{prefix}-attention-out_proj-kernel": f"model.language_model.layers.{i}.linear_attn.out_proj.weight", | ||||||||||||||
| f"{prefix}-attention-out_proj-kernel_scale": f"model.language_model.layers.{i}.linear_attn.out_proj.weight_scale", | ||||||||||||||
| } | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -1045,6 +1105,10 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"{prefix}-mlp-shared_expert-wi_1-kernel": (f"{hf_mlp}.shared_expert.up_proj.weight"), | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wo-kernel": (f"{hf_mlp}.shared_expert.down_proj.weight"), | ||||||||||||||
| f"{prefix}-mlp-shared_expert_gate-kernel": (f"{hf_mlp}.shared_expert_gate.weight"), | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wi_0-kernel_scale": (f"{hf_mlp}.shared_expert.gate_proj.weight_scale"), | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wi_1-kernel_scale": (f"{hf_mlp}.shared_expert.up_proj.weight_scale"), | ||||||||||||||
| f"{prefix}-mlp-shared_expert-wo-kernel_scale": (f"{hf_mlp}.shared_expert.down_proj.weight_scale"), | ||||||||||||||
| f"{prefix}-mlp-shared_expert_gate-kernel_scale": (f"{hf_mlp}.shared_expert_gate.weight_scale"), | ||||||||||||||
| } | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -1056,6 +1120,11 @@ def QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING(config, maxtext_config, scan_layers=Fals | |||||||||||||
| f"{prefix}-mlp-routed_experts-wi_0", | ||||||||||||||
| f"{prefix}-mlp-routed_experts-wi_1", | ||||||||||||||
| ): f"model.language_model.layers.{i}.mlp.experts.gate_up_proj", | ||||||||||||||
| f"{prefix}-mlp-routed_experts-wo-kernel_scale": f"model.language_model.layers.{i}.mlp.experts.down_proj.weight_scale", | ||||||||||||||
| ( | ||||||||||||||
| f"{prefix}-mlp-routed_experts-wi_0-kernel_scale", | ||||||||||||||
| f"{prefix}-mlp-routed_experts-wi_1-kernel_scale", | ||||||||||||||
| ): f"model.language_model.layers.{i}.mlp.experts.gate_up_proj.weight_scale", | ||||||||||||||
| } | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -1251,6 +1320,13 @@ def concat_ba_and_transpose(input_tensor, target_shape=None): | |||||||||||||
| interleaved = np.concatenate([b_r, a_r], axis=1) | ||||||||||||||
| return interleaved.reshape(-1, b_m.shape[-1]).T | ||||||||||||||
|
|
||||||||||||||
| def reshape_scale(input_tensor, target_shape=None): | ||||||||||||||
| if target_shape is None: | ||||||||||||||
| return input_tensor | ||||||||||||||
| if input_tensor.ndim == 2: | ||||||||||||||
| return input_tensor.transpose().reshape(target_shape) | ||||||||||||||
| return input_tensor.reshape(target_shape) | ||||||||||||||
|
Comment on lines
+1323
to
+1328
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To support the composite scale keys (such as def reshape_scale(input_tensor, target_shape=None):
if target_shape is None:
return input_tensor
if input_tensor.ndim == 2:
return input_tensor.transpose().reshape(target_shape)
return input_tensor.reshape(target_shape)
def process_wi_0_wi_1_scale(input_tensor, target_shape=None):
if saving_to_hf:
wi_0, wi_1 = input_tensor
return np.concatenate([wi_0, wi_1], axis=-1)
else:
return np.split(input_tensor, 2, axis=-1)
def split_qkvz_scale(input_tensor, target_shape=None):
if saving_to_hf:
conv_dim = 2 * H_k * D_k + H_v * D_v
return input_tensor[:conv_dim], input_tensor[conv_dim:]
else:
qkv_scale, z_scale = input_tensor
return np.concatenate([qkv_scale, z_scale], axis=0)
def split_ba_scale(input_tensor, target_shape=None):
if saving_to_hf:
return input_tensor[:H_v], input_tensor[H_v:]
else:
b_scale, a_scale = input_tensor
return np.concatenate([b_scale, a_scale], axis=0) |
||||||||||||||
|
|
||||||||||||||
| # Initialize Hooks | ||||||||||||||
| hooks = { | ||||||||||||||
| "params-decoder-logits_dense-kernel": transpose, | ||||||||||||||
|
|
@@ -1272,23 +1348,35 @@ def concat_ba_and_transpose(input_tensor, target_shape=None): | |||||||||||||
| if is_full_attention_layer: | ||||||||||||||
| for key in ["query", "key", "value", "out"]: | ||||||||||||||
| hooks[f"{prefix}-attention-attention-{key}-kernel"] = reshape_kernel # pyrefly: ignore[bad-assignment] | ||||||||||||||
| hooks[f"{prefix}-attention-attention-{key}-kernel_scale"] = reshape_scale | ||||||||||||||
| else: | ||||||||||||||
| hooks[f"{prefix}-attention-in_proj_qkvz-kernel"] = concat_qkvz_and_transpose | ||||||||||||||
| hooks[f"{prefix}-attention-in_proj_ba-kernel"] = concat_ba_and_transpose | ||||||||||||||
| hooks[f"{prefix}-attention-out_proj-kernel"] = transpose | ||||||||||||||
| hooks[f"{prefix}-attention-conv1d-kernel"] = permute_conv | ||||||||||||||
| hooks[f"{prefix}-attention-in_proj_qkvz-kernel_scale"] = reshape_scale | ||||||||||||||
| hooks[f"{prefix}-attention-in_proj_ba-kernel_scale"] = reshape_scale | ||||||||||||||
|
Comment on lines
+1357
to
+1358
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the newly defined
Suggested change
|
||||||||||||||
| hooks[f"{prefix}-attention-out_proj-kernel_scale"] = reshape_scale | ||||||||||||||
|
|
||||||||||||||
| mlp_prefix = f"{prefix}-mlp" | ||||||||||||||
| hooks[f"{mlp_prefix}-routed_experts-gate-kernel"] = transpose | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert-wi_0-kernel"] = transpose | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert-wi_1-kernel"] = transpose | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert-wo-kernel"] = transpose | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert_gate-kernel"] = transpose | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert-wi_0-kernel_scale"] = reshape_scale | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert-wi_1-kernel_scale"] = reshape_scale | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert-wo-kernel_scale"] = reshape_scale | ||||||||||||||
| hooks[f"{mlp_prefix}-shared_expert_gate-kernel_scale"] = reshape_scale | ||||||||||||||
| # pyrefly: ignore[unsupported-operation] | ||||||||||||||
| hooks[(f"{mlp_prefix}-routed_experts-wi_0", f"{mlp_prefix}-routed_experts-wi_1")] = ( | ||||||||||||||
| process_wi_0_wi_1 # pyrefly: ignore[unsupported-operation] | ||||||||||||||
| ) | ||||||||||||||
| hooks[f"{mlp_prefix}-routed_experts-wo"] = transpose_expert | ||||||||||||||
| hooks[f"{mlp_prefix}-routed_experts-wo-kernel_scale"] = reshape_scale | ||||||||||||||
| hooks[(f"{mlp_prefix}-routed_experts-wi_0-kernel_scale", f"{mlp_prefix}-routed_experts-wi_1-kernel_scale")] = ( | ||||||||||||||
| reshape_scale | ||||||||||||||
| ) | ||||||||||||||
|
Comment on lines
+1377
to
+1379
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the newly defined
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| # Vision hooks for Qwen3.5 | ||||||||||||||
| vision_config = config.get("vision_config", None) | ||||||||||||||
|
|
@@ -4263,6 +4351,8 @@ def mhc_concat_scale(input_tensors, target_shape=None): | |||||||||||||
| "qwen3-next-80b-a3b": QWEN3_NEXT_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "qwen3.5-397b-a17b": QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "qwen3.5-35b-a3b": QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "qwen3.5-35b-a3b-fp8": QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "qwen3.5-35b-fp8": QWEN3_5_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "mixtral-8x7b": MIXTRAL_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "mixtral-8x22b": MIXTRAL_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
| "olmo3-7b": OLMO3_MAXTEXT_TO_HF_PARAM_MAPPING, | ||||||||||||||
|
|
@@ -4317,6 +4407,8 @@ def mhc_concat_scale(input_tensors, target_shape=None): | |||||||||||||
| "qwen3-omni-30b-a3b": QWEN3_OMNI_MOE_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "qwen3.5-397b-a17b": QWEN3_5_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "qwen3.5-35b-a3b": QWEN3_5_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "qwen3.5-35b-a3b-fp8": QWEN3_5_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "qwen3.5-35b-fp8": QWEN3_5_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "qwen3-next-80b-a3b": QWEN3_NEXT_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "mixtral-8x7b": MIXTRAL_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
| "mixtral-8x22b": MIXTRAL_MAXTEXT_TO_HF_PARAM_HOOK_FN, | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # model config for qwen3.5-35b-a3b-fp8 (FP8 weight-only storage with dynamic dequantization) | ||
|
|
||
| decoder_block: "qwen3_5" | ||
|
|
||
| # Core Architectural Parameters | ||
| base_emb_dim: 2048 | ||
| base_num_decoder_layers: 40 | ||
| base_num_query_heads: 16 | ||
| base_num_kv_heads: 2 | ||
| head_dim: 256 | ||
| vocab_size: 248320 | ||
| normalization_layer_epsilon: 1.0e-6 | ||
|
|
||
| # MoE Specific Parameters | ||
| # Set base_mlp_dim to match base_moe_mlp_dim to pass validation for fully MoE models. | ||
| base_mlp_dim: 512 | ||
| base_moe_mlp_dim: 512 | ||
| num_experts: 256 | ||
| shared_experts: 1 | ||
| num_experts_per_tok: 8 | ||
| norm_topk_prob: True | ||
|
|
||
| # GatedDeltaNet Specific Parameters for Linear Attention (GDN) | ||
| inhomogeneous_layer_cycle_interval: 4 | ||
| gdn_conv_kernel_dim: 4 | ||
| gdn_key_head_dim: 128 | ||
| gdn_value_head_dim: 128 | ||
| gdn_num_key_heads: 16 | ||
| gdn_num_value_heads: 32 | ||
| gdn_chunk_size: 64 | ||
|
|
||
| # RoPE Settings | ||
| rope_max_timescale: 10000000 | ||
| partial_rotary_factor: 0.25 | ||
|
|
||
| # General Model Settings | ||
| enable_dropout: False | ||
|
|
||
| # Vision Encoder Configuration (need to set use_multimodal=true) | ||
| vision_encoder_block: "qwen3_5" | ||
| # Based on Qwen3.5 MoE Vision Model Config | ||
| image_size_for_vit: 768 | ||
| hidden_size_for_vit: 1152 | ||
| intermediate_size_for_vit: 4304 | ||
| num_attention_heads_for_vit: 16 | ||
| num_hidden_layers_for_vit: 27 | ||
| num_channels_for_vit: 3 | ||
| patch_size_for_vit: 16 | ||
| temporal_patch_size_for_vit: 2 | ||
| spatial_merge_size_for_vit: 2 | ||
| out_hidden_size_for_vit: 2048 # Projects to decoder emb_dim (2048) | ||
| num_position_embeddings_for_vit: 2304 | ||
| deepstack_visual_indexes_for_vit: [] # No deepstack for Qwen3.5 VL | ||
| rope_theta_for_vit: 10000 | ||
|
|
||
| # MRoPE Settings (Multi-dimensional RoPE for multimodal) | ||
| use_mrope: true | ||
| mrope_section: [11, 11, 10] | ||
|
|
||
| weight_dtype: "float8_e4m3fn" | ||
| dtype: "bfloat16" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
QWEN3_5_HF_WEIGHTS_TO_SHAPEfunction inhf_shape.pyneeds to be updated to define the shapes of the newly mappedweight_scaleparameters (such asself_attn.q_proj.weight_scale,linear_attn.in_proj_qkv.weight_scale, etc.). Without these shape definitions, any attempt to convert checkpoints for the FP8 models (e.g., MaxText -> HF) will fail with aKeyErrorwhen looking up the expected shapes of the scale tensors.