| { |
| "architecture": { |
| "attention_variant": "GQA", |
| "family": "causal_lm", |
| "is_moe": false, |
| "logit_softcapping": { |
| "attn": 50.0, |
| "final": 30.0 |
| }, |
| "mixer": "attention", |
| "positional": "rope", |
| "sliding_window": 4096, |
| "tie_word_embeddings": true, |
| "view": "decoder" |
| }, |
| "capabilities": { |
| "attention_backends": [ |
| "eager", |
| "sdpa", |
| "flash_attention", |
| "flex_attention" |
| ], |
| "attention_patterns": [ |
| "sliding", |
| "causal" |
| ], |
| "attention_schedule": [ |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention", |
| "sliding_attention", |
| "full_attention" |
| ], |
| "task_heads": [ |
| "causal_lm", |
| "sequence_classification", |
| "token_classification" |
| ], |
| "tensor_parallel": true |
| }, |
| "components": [ |
| { |
| "children": [ |
| "embed_tokens", |
| "decoder_layers", |
| "norm", |
| "rotary_emb" |
| ], |
| "class_name": "Gemma2Model", |
| "id": "model", |
| "kind": "model", |
| "path_pattern": "model" |
| }, |
| { |
| "attributes": { |
| "embedding_dim": "config.hidden_size", |
| "num_embeddings": "config.vocab_size", |
| "tied_lm_head": true |
| }, |
| "class_name": "Gemma2TextScaledWordEmbedding", |
| "id": "embed_tokens", |
| "kind": "embedding", |
| "path_pattern": "model.embed_tokens" |
| }, |
| { |
| "attributes": { |
| "norm_type": "rms" |
| }, |
| "class_name": "Gemma2RMSNorm", |
| "id": "norm", |
| "kind": "normalization", |
| "path_pattern": "model.norm" |
| }, |
| { |
| "attributes": { |
| "head_dim": "config.head_dim", |
| "rope_theta": 10000.0, |
| "scheme": "rope" |
| }, |
| "class_name": "Gemma2RotaryEmbedding", |
| "id": "rotary_emb", |
| "kind": "position", |
| "path_pattern": "model.rotary_emb" |
| } |
| ], |
| "config": { |
| "class_name": "Gemma2Config", |
| "model_type": "gemma2", |
| "module": "transformers.models.gemma2.configuration_gemma2", |
| "referenced_fields": { |
| "num_hidden_layers": 26 |
| }, |
| "salient_fields": { |
| "head_dim": 256, |
| "hidden_size": 2304, |
| "intermediate_size": 9216, |
| "is_encoder_decoder": false, |
| "max_position_embeddings": 8192, |
| "num_attention_heads": 8, |
| "num_hidden_layers": 26, |
| "num_key_value_heads": 4, |
| "sliding_window": 4096, |
| "tie_word_embeddings": true, |
| "vocab_size": 256000 |
| } |
| }, |
| "dataflow": { |
| "input": { |
| "name": "input_ids", |
| "shape": [ |
| "B", |
| "S" |
| ] |
| }, |
| "output": { |
| "shape": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "shapes": { |
| "decoder_layer.input_layernorm": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "decoder_layer.mlp": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "decoder_layer.post_attention_layernorm": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "decoder_layer.post_feedforward_layernorm": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "decoder_layer.pre_feedforward_layernorm": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "decoder_layer.self_attn": { |
| "in": null, |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "decoder_layers": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "embed_tokens": { |
| "in": [ |
| "B", |
| "S" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "norm": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ] |
| }, |
| "rotary_emb": { |
| "in": [ |
| "B", |
| "S", |
| "config.hidden_size" |
| ], |
| "out": [ |
| "B", |
| "S", |
| "config.head_dim" |
| ] |
| } |
| }, |
| "source": "observed_forward_meta" |
| }, |
| "edges": [ |
| { |
| "kind": "data", |
| "source": "embed_tokens", |
| "target": "decoder_layers" |
| }, |
| { |
| "kind": "data", |
| "source": "decoder_layers", |
| "target": "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": "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.o_proj" |
| }, |
| { |
| "kind": "data", |
| "provenance": "intra_module", |
| "source": "decoder_layer.self_attn.k_proj", |
| "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" |
| }, |
| { |
| "kind": "cache_read", |
| "source": "state:kv_cache", |
| "target": "decoder_layer.self_attn" |
| }, |
| { |
| "kind": "cache_write", |
| "source": "decoder_layer.self_attn", |
| "target": "state:kv_cache" |
| }, |
| { |
| "kind": "data", |
| "provenance": "observed_forward", |
| "source": "decoder_layer.input_layernorm", |
| "target": "decoder_layer.self_attn" |
| }, |
| { |
| "kind": "data", |
| "provenance": "observed_forward", |
| "source": "decoder_layer.self_attn", |
| "target": "decoder_layer.post_attention_layernorm" |
| }, |
| { |
| "kind": "data", |
| "provenance": "observed_forward", |
| "source": "decoder_layer.post_attention_layernorm", |
| "target": "decoder_layer.pre_feedforward_layernorm" |
| }, |
| { |
| "kind": "data", |
| "provenance": "observed_forward", |
| "source": "decoder_layer.pre_feedforward_layernorm", |
| "target": "decoder_layer.mlp" |
| }, |
| { |
| "kind": "data", |
| "provenance": "observed_forward", |
| "source": "decoder_layer.mlp", |
| "target": "decoder_layer.post_feedforward_layernorm" |
| } |
| ], |
| "extends": "gemma", |
| "model_type": "gemma2", |
| "patches": [ |
| { |
| "added": { |
| "attrs": [ |
| "attention_bias", |
| "attention_dropout", |
| "attn_logit_softcapping", |
| "base_model_pp_plan", |
| "base_model_tp_plan", |
| "bos_token_id", |
| "eos_token_id", |
| "final_logit_softcapping", |
| "head_dim", |
| "hidden_activation", |
| "hidden_size", |
| "initializer_range", |
| "intermediate_size", |
| "keys_to_ignore_at_inference", |
| "layer_types", |
| "max_position_embeddings", |
| "model_type", |
| "num_attention_heads", |
| "num_hidden_layers", |
| "num_key_value_heads", |
| "pad_token_id", |
| "query_pre_attn_scalar", |
| "rms_norm_eps", |
| "rope_parameters", |
| "sliding_window", |
| "tie_word_embeddings", |
| "use_bidirectional_attention", |
| "use_cache", |
| "vocab_size" |
| ], |
| "methods": [ |
| "__post_init__", |
| "validate_architecture" |
| ] |
| }, |
| "component_kind": "config", |
| "parent_class": "PreTrainedConfig", |
| "relation": "new", |
| "target_class": "Gemma2Config" |
| }, |
| { |
| "component_kind": "feed_forward", |
| "overridden": { |
| "methods": [ |
| "__init__" |
| ] |
| }, |
| "parent_class": "GemmaMLP", |
| "relation": "inherits", |
| "target_class": "Gemma2MLP" |
| }, |
| { |
| "component_kind": "position", |
| "overridden": { |
| "methods": [ |
| "__init__", |
| "forward" |
| ] |
| }, |
| "parent_class": "GemmaRotaryEmbedding", |
| "relation": "inherits", |
| "target_class": "Gemma2RotaryEmbedding" |
| }, |
| { |
| "component_kind": "attention", |
| "overridden": { |
| "methods": [ |
| "__init__", |
| "forward" |
| ] |
| }, |
| "parent_class": "GemmaAttention", |
| "relation": "inherits", |
| "target_class": "Gemma2Attention" |
| }, |
| { |
| "added": { |
| "methods": [ |
| "__init__", |
| "forward" |
| ] |
| }, |
| "component_kind": "transformer_block", |
| "parent_class": "GradientCheckpointingLayer", |
| "relation": "new", |
| "target_class": "Gemma2DecoderLayer" |
| }, |
| { |
| "component_kind": "model", |
| "overridden": { |
| "methods": [ |
| "__init__", |
| "forward" |
| ] |
| }, |
| "parent_class": "GemmaModel", |
| "relation": "inherits", |
| "target_class": "Gemma2Model" |
| }, |
| { |
| "component_kind": "lm_head", |
| "overridden": { |
| "methods": [ |
| "__init__", |
| "forward" |
| ] |
| }, |
| "parent_class": "GemmaForCausalLM", |
| "relation": "inherits", |
| "target_class": "Gemma2ForCausalLM" |
| } |
| ], |
| "provenance": { |
| "config_class": "Gemma2Config", |
| "config_module": "transformers.models.gemma2.configuration_gemma2", |
| "model_class": "Gemma2Model", |
| "model_module": "transformers.models.gemma2.modeling_gemma2" |
| }, |
| "repeats": [ |
| { |
| "body": "decoder_layer", |
| "container_path_pattern": "model.layers", |
| "count": 26, |
| "count_expr": "config.num_hidden_layers", |
| "count_source": "config", |
| "id": "decoder_layers", |
| "index_symbol": "i", |
| "item_path_pattern": "model.layers.{i}", |
| "kind": "symbolic_repeat", |
| "provenance": { |
| "class_name": "Gemma2DecoderLayer", |
| "container_path_pattern": "model.layers", |
| "item_path_pattern": "model.layers.{i}", |
| "source": "module_tree_repeat_collapse" |
| }, |
| "repeated_class_name": "Gemma2DecoderLayer" |
| } |
| ], |
| "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": "Gemma2DecoderLayer", |
| "id": "decoder_layer", |
| "kind": "transformer_block", |
| "path_pattern": "model.layers.{i}" |
| }, |
| { |
| "attributes": { |
| "head_dim": 256, |
| "n_heads": 8, |
| "n_kv_heads": 4, |
| "rope": true, |
| "sliding_window": 4096, |
| "variant": "GQA" |
| }, |
| "children": [ |
| "decoder_layer.self_attn.q_proj", |
| "decoder_layer.self_attn.k_proj", |
| "decoder_layer.self_attn.v_proj", |
| "decoder_layer.self_attn.o_proj" |
| ], |
| "class_name": "Gemma2Attention", |
| "id": "decoder_layer.self_attn", |
| "kind": "attention", |
| "path_pattern": "model.layers.{i}.self_attn" |
| }, |
| { |
| "attributes": { |
| "in_features": "config.hidden_size", |
| "out_features": 2048, |
| "tp": "colwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.self_attn.q_proj", |
| "kind": "projection", |
| "path_pattern": "model.layers.{i}.self_attn.q_proj" |
| }, |
| { |
| "attributes": { |
| "in_features": "config.hidden_size", |
| "out_features": 1024, |
| "tp": "colwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.self_attn.k_proj", |
| "kind": "projection", |
| "path_pattern": "model.layers.{i}.self_attn.k_proj" |
| }, |
| { |
| "attributes": { |
| "in_features": "config.hidden_size", |
| "out_features": 1024, |
| "tp": "colwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.self_attn.v_proj", |
| "kind": "projection", |
| "path_pattern": "model.layers.{i}.self_attn.v_proj" |
| }, |
| { |
| "attributes": { |
| "in_features": 2048, |
| "out_features": "config.hidden_size", |
| "tp": "rowwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.self_attn.o_proj", |
| "kind": "projection", |
| "path_pattern": "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": "Gemma2MLP", |
| "id": "decoder_layer.mlp", |
| "kind": "feed_forward", |
| "path_pattern": "model.layers.{i}.mlp" |
| }, |
| { |
| "attributes": { |
| "in_features": "config.hidden_size", |
| "out_features": "config.intermediate_size", |
| "tp": "colwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.mlp.gate_proj", |
| "kind": "projection", |
| "path_pattern": "model.layers.{i}.mlp.gate_proj" |
| }, |
| { |
| "attributes": { |
| "in_features": "config.hidden_size", |
| "out_features": "config.intermediate_size", |
| "tp": "colwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.mlp.up_proj", |
| "kind": "projection", |
| "path_pattern": "model.layers.{i}.mlp.up_proj" |
| }, |
| { |
| "attributes": { |
| "in_features": "config.intermediate_size", |
| "out_features": "config.hidden_size", |
| "tp": "rowwise" |
| }, |
| "class_name": "Linear", |
| "id": "decoder_layer.mlp.down_proj", |
| "kind": "projection", |
| "path_pattern": "model.layers.{i}.mlp.down_proj" |
| }, |
| { |
| "attributes": { |
| "norm_type": "rms" |
| }, |
| "class_name": "Gemma2RMSNorm", |
| "id": "decoder_layer.input_layernorm", |
| "kind": "normalization", |
| "path_pattern": "model.layers.{i}.input_layernorm" |
| }, |
| { |
| "attributes": { |
| "norm_type": "rms" |
| }, |
| "class_name": "Gemma2RMSNorm", |
| "id": "decoder_layer.post_attention_layernorm", |
| "kind": "normalization", |
| "path_pattern": "model.layers.{i}.post_attention_layernorm" |
| }, |
| { |
| "attributes": { |
| "norm_type": "rms" |
| }, |
| "class_name": "Gemma2RMSNorm", |
| "id": "decoder_layer.pre_feedforward_layernorm", |
| "kind": "normalization", |
| "path_pattern": "model.layers.{i}.pre_feedforward_layernorm" |
| }, |
| { |
| "attributes": { |
| "norm_type": "rms" |
| }, |
| "class_name": "Gemma2RMSNorm", |
| "id": "decoder_layer.post_feedforward_layernorm", |
| "kind": "normalization", |
| "path_pattern": "model.layers.{i}.post_feedforward_layernorm" |
| } |
| ] |
| } |
|
|