MCPcopy Create free account
hub / github.com/apple/axlearn / Config

Class Config

axlearn/common/decoder.py:481–518  ·  view source on GitHub ↗

Configures Decoder.

Source from the content-addressed store, hash-verified

479 dim: Required[int] = REQUIRED
480 # Dropout rate applied throughout model, except for child Dropout configs with rate set
481 # explicitly.
482 dropout_rate: float = 0.0
483 # Vector from input ids table.
484 emb: BaseEmbedding.Config = TransformerTextEmbeddings.default_config()
485 # Transformer model trunk.
486 transformer: BaseStackedTransformerLayer.Config = StackedTransformerLayer.default_config()
487 # Layer norm applied to transformer output.
488 output_norm: Optional[InstantiableConfig] = LayerNorm.default_config()
489 # Optional dropout rate for the transformer output.
490 # If output_dropout.rate is None, it will default to cfg.dropout_rate
491 output_dropout: Dropout.Config = Dropout.default_config()
492 # Optional LmHead layer maps the hidden state to vocab logits (if None use emb.token_emb).
493 lm_head: Optional[InstantiableConfig] = None
494 pad_token_id: int = 0 # Int ID of the inputs to be masked for self-attention.
495 eos_token_id: int = 1 # Int ID of the end of sequence token id.
496 # Specifies how to partition the output logits of shape [batch, max_seq_len, vocab_size].
497 logits_partition_spec: tuple[Union[Optional[str], tuple[Optional[str]]], ...] = (
498 "data",
499 None,
500 "model",
501 )
502 # Partition spec for the pre-matmul `logits_x` activation (not the final logits
503 # output, which always uses `logits_partition_spec`). Defaults to None, which reuses
504 # `logits_partition_spec`; set explicitly -- it takes precedence -- when hidden-dim
505 # sharding should differ, e.g. to match the embedding/lm_head weight's sharding.
506 hidden_state_partition_spec: Optional[
507 tuple[Union[Optional[str], tuple[Optional[str]]], ...]
508 ] = None
509 # Precision dtype for logits computation.
510 # if None, uses the input dtype as default for logits computation.
511 logits_forward_dtype: Optional[jnp.dtype] = None
512 # The logit modifier to apply. If None, does not modify logits.
513 output_logits_modifier: Optional[ConfigOr[logit_modifiers.LogitsToLogitsFn]] = None
514 # The decoding implementation.
515 decoding: DecodingLayer.Config = DecodingLayer.default_config()
516
517 def __init__(self, cfg: Config, *, parent: Module):
518 super().__init__(cfg, parent=parent)
519 cfg = self.config
520
521 # Validate logits_forward_dtype

Callers

nothing calls this directly

Calls 1

default_configMethod · 0.45

Tested by

no test coverage detected