inspector / ir /artifacts /gemma4_unified.json
lysandre's picture
lysandre HF Staff
Deploy architecture inspector
ed5700a verified
Raw
History Blame Contribute Delete
20.4 kB
{
"architecture": {
"attention_variant": "GQA",
"family": "image_text_to_text",
"is_moe": false,
"mixer": "attention",
"positional": "rope",
"sliding_window": 1024,
"tie_word_embeddings": true,
"towers": [
{
"attention_variant": "GQA",
"config_class": "Gemma4UnifiedTextConfig",
"hidden_size": 2304,
"name": "text",
"num_attention_heads": 8,
"num_hidden_layers": 30,
"positional": "rope"
}
],
"view": "multimodal"
},
"capabilities": {
"attention_backends": [
"eager",
"sdpa",
"flash_attention",
"flex_attention"
],
"attention_patterns": [
"sliding",
"causal"
],
"attention_schedule": [
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention"
],
"task_heads": [
"causal_lm",
"image_text_to_text",
"multimodal_lm",
"pretraining"
],
"tensor_parallel": true
},
"components": [
{
"children": [
"language_model"
],
"class_name": "Gemma4UnifiedModel",
"id": "model",
"kind": "model",
"path_pattern": "model"
},
{
"children": [
"language_model.embed_tokens",
"decoder_layers",
"language_model.norm",
"language_model.rotary_emb"
],
"class_name": "Gemma4UnifiedTextModel",
"id": "language_model",
"kind": "model",
"path_pattern": "model.language_model"
},
{
"attributes": {
"embedding_dim": "config.hidden_size",
"num_embeddings": "config.vocab_size",
"tied_lm_head": true
},
"class_name": "Gemma4UnifiedTextScaledWordEmbedding",
"id": "language_model.embed_tokens",
"kind": "embedding",
"path_pattern": "model.language_model.embed_tokens"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "language_model.norm",
"kind": "normalization",
"path_pattern": "model.language_model.norm"
},
{
"attributes": {
"head_dim": "config.head_dim",
"scheme": "rope"
},
"class_name": "Gemma4UnifiedTextRotaryEmbedding",
"id": "language_model.rotary_emb",
"kind": "position",
"path_pattern": "model.language_model.rotary_emb"
}
],
"config": {
"class_name": "Gemma4UnifiedConfig",
"model_type": "gemma4_unified",
"module": "transformers.models.gemma4_unified.configuration_gemma4_unified",
"referenced_fields": {},
"salient_fields": {
"is_encoder_decoder": false,
"tie_word_embeddings": true
}
},
"edges": [
{
"kind": "data",
"source": "language_model.embed_tokens",
"target": "decoder_layers"
},
{
"kind": "data",
"source": "decoder_layers",
"target": "language_model.norm"
},
{
"kind": "data",
"source": "decoder_layer.self_attn",
"target": "decoder_layer.mlp"
},
{
"kind": "data",
"source": "decoder_layer.mlp",
"target": "decoder_layer.input_layernorm"
},
{
"kind": "data",
"source": "decoder_layer.input_layernorm",
"target": "decoder_layer.post_attention_layernorm"
},
{
"kind": "data",
"source": "decoder_layer.post_attention_layernorm",
"target": "decoder_layer.pre_feedforward_layernorm"
},
{
"kind": "data",
"source": "decoder_layer.pre_feedforward_layernorm",
"target": "decoder_layer.post_feedforward_layernorm"
},
{
"kind": "data",
"source": "decoder_layer.self_attn.k_norm",
"target": "decoder_layer.self_attn.v_norm"
},
{
"kind": "mask",
"source": "input:attention_mask",
"target": "decoder_layer.self_attn"
},
{
"kind": "residual",
"source": "decoder_layer",
"target": "decoder_layer.self_attn"
},
{
"kind": "residual",
"source": "decoder_layer",
"target": "decoder_layer.mlp"
},
{
"kind": "position",
"source": "language_model.rotary_emb",
"target": "decoder_layer.self_attn"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn",
"target": "decoder_layer.self_attn.q_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn",
"target": "decoder_layer.self_attn.k_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn",
"target": "decoder_layer.self_attn.v_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn.q_proj",
"target": "decoder_layer.self_attn.q_norm"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn.k_proj",
"target": "decoder_layer.self_attn.k_norm"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn.q_norm",
"target": "decoder_layer.self_attn.o_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn.k_norm",
"target": "decoder_layer.self_attn.o_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.self_attn.v_proj",
"target": "decoder_layer.self_attn.o_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.mlp",
"target": "decoder_layer.mlp.gate_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.mlp",
"target": "decoder_layer.mlp.up_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.mlp.gate_proj",
"target": "decoder_layer.mlp.down_proj"
},
{
"kind": "data",
"provenance": "intra_module",
"source": "decoder_layer.mlp.up_proj",
"target": "decoder_layer.mlp.down_proj"
}
],
"extends": "gemma4",
"model_type": "gemma4_unified",
"patches": [
{
"component_kind": null,
"parent_class": "Gemma4ImageProcessorKwargs",
"relation": "new",
"target_class": "Gemma4UnifiedImageProcessorKwargs"
},
{
"added": {
"methods": [
"_preprocess"
]
},
"component_kind": null,
"parent_class": "Gemma4ImageProcessor",
"relation": "new",
"target_class": "Gemma4UnifiedImageProcessor"
},
{
"component_kind": null,
"parent_class": "Gemma4VideoProcessorKwargs",
"relation": "new",
"target_class": "Gemma4UnifiedVideoProcessorKwargs"
},
{
"added": {
"methods": [
"_preprocess"
]
},
"component_kind": null,
"parent_class": "Gemma4VideoProcessor",
"relation": "new",
"target_class": "Gemma4UnifiedVideoProcessor"
},
{
"component_kind": null,
"parent_class": "Gemma4ProcessorKwargs",
"relation": "new",
"target_class": "Gemma4UnifiedProcessorKwargs"
},
{
"added": {
"methods": [
"_compute_audio_num_tokens",
"replace_audio_token"
]
},
"component_kind": null,
"parent_class": "Gemma4Processor",
"relation": "new",
"target_class": "Gemma4UnifiedProcessor"
},
{
"added": {
"attrs": [
"audio_embed_dim",
"initializer_range",
"model_type",
"rms_norm_eps"
],
"methods": [
"audio_samples_per_token",
"hidden_size",
"output_proj_dims"
]
},
"component_kind": "config",
"parent_class": "PreTrainedConfig",
"relation": "new",
"target_class": "Gemma4UnifiedAudioConfig"
},
{
"added": {
"attrs": [
"base_model_ep_plan",
"base_model_tp_plan",
"enable_moe_block",
"hidden_size_per_layer_input",
"max_position_embeddings",
"model_type",
"moe_intermediate_size",
"num_experts",
"sliding_window",
"top_k_experts",
"use_bidirectional_attention",
"vocab_size_per_layer_input"
]
},
"component_kind": "config",
"parent_class": "Gemma4TextConfig",
"relation": "new",
"target_class": "Gemma4UnifiedTextConfig"
},
{
"added": {
"attrs": [
"initializer_range",
"mm_embed_dim",
"mm_posemb_size",
"model_type",
"output_proj_dims",
"patch_size",
"pooling_kernel_size",
"rms_norm_eps"
],
"methods": [
"model_patch_size"
]
},
"component_kind": "config",
"parent_class": "PreTrainedConfig",
"relation": "new",
"target_class": "Gemma4UnifiedVisionConfig"
},
{
"added": {
"attrs": [
"audio_config",
"sub_configs",
"text_config",
"vision_config"
]
},
"component_kind": "config",
"parent_class": "Gemma4Config",
"relation": "new",
"target_class": "Gemma4UnifiedConfig"
},
{
"added": {
"attrs": [
"attention_mask",
"pooler_output"
]
},
"component_kind": null,
"parent_class": "ModelOutput",
"relation": "new",
"target_class": "Gemma4UnifiedAudioModelOutput"
},
{
"added": {
"attrs": [
"pooler_output"
]
},
"component_kind": null,
"parent_class": "ModelOutput",
"relation": "new",
"target_class": "Gemma4UnifiedVisionModelOutput"
},
{
"component_kind": "transformer_block",
"overridden": {
"methods": [
"__init__",
"forward"
]
},
"parent_class": "Gemma2DecoderLayer",
"parent_model": "gemma2",
"relation": "inherits",
"target_class": "Gemma4UnifiedTextDecoderLayer"
},
{
"component_kind": "model",
"deleted": {
"methods": [
"_resize_per_layer_embeddings",
"get_per_layer_input_embeddings",
"resize_token_embeddings",
"set_per_layer_input_embeddings"
]
},
"overridden": {
"attrs": [
"_no_split_modules"
],
"methods": [
"_init_weights"
]
},
"parent_class": "Gemma4PreTrainedModel",
"relation": "inherits",
"target_class": "Gemma4UnifiedPreTrainedModel"
},
{
"added": {
"attrs": [
"_can_record_outputs",
"config",
"input_modalities"
]
},
"component_kind": "model",
"overridden": {
"methods": [
"__init__",
"forward"
]
},
"parent_class": "LlamaModel",
"parent_model": "llama",
"relation": "inherits",
"target_class": "Gemma4UnifiedTextModel"
},
{
"component_kind": "lm_head",
"overridden": {
"methods": [
"forward"
]
},
"parent_class": "Gemma4ForCausalLM",
"relation": "inherits",
"target_class": "Gemma4UnifiedForCausalLM"
},
{
"added": {
"methods": [
"__init__",
"forward"
]
},
"component_kind": null,
"parent_class": "Module",
"relation": "new",
"target_class": "Gemma4UnifiedVisionEmbedder"
},
{
"component_kind": null,
"overridden": {
"methods": [
"__init__",
"forward"
]
},
"parent_class": "Gemma4MultimodalEmbedder",
"relation": "inherits",
"target_class": "Gemma4UnifiedMultimodalEmbedder"
},
{
"component_kind": "model",
"deleted": {
"methods": [
"get_per_layer_input_embeddings",
"set_per_layer_input_embeddings"
]
},
"overridden": {
"methods": [
"__init__",
"forward",
"get_audio_features",
"get_image_features",
"get_video_features"
]
},
"parent_class": "Gemma4Model",
"relation": "inherits",
"target_class": "Gemma4UnifiedModel"
},
{
"component_kind": "lm_head",
"deleted": {
"methods": [
"get_per_layer_input_embeddings",
"set_per_layer_input_embeddings"
]
},
"overridden": {
"methods": [
"forward",
"prepare_inputs_for_generation"
]
},
"parent_class": "Gemma4ForConditionalGeneration",
"relation": "inherits",
"target_class": "Gemma4UnifiedForConditionalGeneration"
}
],
"provenance": {
"config_class": "Gemma4UnifiedConfig",
"config_module": "transformers.models.gemma4_unified.configuration_gemma4_unified",
"model_class": "Gemma4UnifiedModel",
"model_module": "transformers.models.gemma4_unified.modeling_gemma4_unified"
},
"repeats": [
{
"body": "decoder_layer",
"container_path_pattern": "model.language_model.layers",
"count": 30,
"count_expr": "30",
"count_source": "module_tree",
"id": "decoder_layers",
"index_symbol": "i",
"item_path_pattern": "model.language_model.layers.{i}",
"kind": "symbolic_repeat",
"provenance": {
"class_name": "Gemma4UnifiedTextDecoderLayer",
"container_path_pattern": "model.language_model.layers",
"item_path_pattern": "model.language_model.layers.{i}",
"source": "module_tree_repeat_collapse"
},
"repeated_class_name": "Gemma4UnifiedTextDecoderLayer"
}
],
"schema_version": "architecture-template-v0",
"templates": [
{
"children": [
"decoder_layer.self_attn",
"decoder_layer.mlp",
"decoder_layer.input_layernorm",
"decoder_layer.post_attention_layernorm",
"decoder_layer.pre_feedforward_layernorm",
"decoder_layer.post_feedforward_layernorm"
],
"class_name": "Gemma4UnifiedTextDecoderLayer",
"id": "decoder_layer",
"kind": "transformer_block",
"path_pattern": "model.language_model.layers.{i}"
},
{
"attributes": {
"head_dim": 256,
"n_heads": 8,
"n_kv_heads": 4,
"qk_norm": true,
"rope": true,
"sliding_window": 1024,
"variant": "GQA"
},
"children": [
"decoder_layer.self_attn.q_proj",
"decoder_layer.self_attn.q_norm",
"decoder_layer.self_attn.k_norm",
"decoder_layer.self_attn.v_norm",
"decoder_layer.self_attn.k_proj",
"decoder_layer.self_attn.v_proj",
"decoder_layer.self_attn.o_proj"
],
"class_name": "Gemma4UnifiedTextAttention",
"id": "decoder_layer.self_attn",
"kind": "attention",
"path_pattern": "model.language_model.layers.{i}.self_attn"
},
{
"attributes": {
"in_features": "config.hidden_size",
"out_features": 2048
},
"class_name": "Linear",
"id": "decoder_layer.self_attn.q_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.self_attn.q_proj"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.self_attn.q_norm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.self_attn.q_norm"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.self_attn.k_norm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.self_attn.k_norm"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.self_attn.v_norm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.self_attn.v_norm"
},
{
"attributes": {
"in_features": "config.hidden_size",
"out_features": 1024
},
"class_name": "Linear",
"id": "decoder_layer.self_attn.k_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.self_attn.k_proj"
},
{
"attributes": {
"in_features": "config.hidden_size",
"out_features": 1024
},
"class_name": "Linear",
"id": "decoder_layer.self_attn.v_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.self_attn.v_proj"
},
{
"attributes": {
"in_features": 2048,
"out_features": "config.hidden_size"
},
"class_name": "Linear",
"id": "decoder_layer.self_attn.o_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.self_attn.o_proj"
},
{
"attributes": {
"hidden_size": 2304,
"intermediate_size": 9216
},
"children": [
"decoder_layer.mlp.gate_proj",
"decoder_layer.mlp.up_proj",
"decoder_layer.mlp.down_proj"
],
"class_name": "Gemma4UnifiedTextMLP",
"id": "decoder_layer.mlp",
"kind": "feed_forward",
"path_pattern": "model.language_model.layers.{i}.mlp"
},
{
"attributes": {
"in_features": "config.hidden_size",
"out_features": "config.intermediate_size"
},
"class_name": "Linear",
"id": "decoder_layer.mlp.gate_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.mlp.gate_proj"
},
{
"attributes": {
"in_features": "config.hidden_size",
"out_features": "config.intermediate_size"
},
"class_name": "Linear",
"id": "decoder_layer.mlp.up_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.mlp.up_proj"
},
{
"attributes": {
"in_features": "config.intermediate_size",
"out_features": "config.hidden_size"
},
"class_name": "Linear",
"id": "decoder_layer.mlp.down_proj",
"kind": "projection",
"path_pattern": "model.language_model.layers.{i}.mlp.down_proj"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.input_layernorm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.input_layernorm"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.post_attention_layernorm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.post_attention_layernorm"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.pre_feedforward_layernorm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.pre_feedforward_layernorm"
},
{
"attributes": {
"norm_type": "rms"
},
"class_name": "Gemma4UnifiedRMSNorm",
"id": "decoder_layer.post_feedforward_layernorm",
"kind": "normalization",
"path_pattern": "model.language_model.layers.{i}.post_feedforward_layernorm"
}
]
}