Skip to navigation

nemo_automodel.components.speculative.dflash.cached_target

View as MarkdownOpen in Claude

Load only the frozen token tables used by cached DFlash training.

Module Contents

Classes

NameDescription
DFlashTargetTablesTarget token embedding and output projection, both frozen.
DFlashTargetTablesConfigCheckpoint keys for the two target tables read by DFlash.

Functions

NameDescription
_read_weights-

API

class nemo_automodel.components.speculative.dflash.cached_target.DFlashTargetTables(
embed_tokens: torch.nn.Embedding,
lm_head: torch.nn.Linear
)
Dataclass

Target token embedding and output projection, both frozen.

embed_tokens
Embedding
lm_head
Linear
class nemo_automodel.components.speculative.dflash.cached_target.DFlashTargetTablesConfig(
embedding_key: str = 'model.embed_tokens.weight',
lm_head_key: str = 'lm_head.weight'
)
Dataclass

Checkpoint keys for the two target tables read by DFlash.

embedding_key
str = 'model.embed_tokens.weight'
lm_head_key
str = 'lm_head.weight'
target_model_name_or_path: str,
config: transformers.PreTrainedConfig,
device: torch.device,
dtype: torch.dtype

Read the target’s input and output tables without building the target.

Parameters:

target_model_name_or_path
str

Hugging Face safetensors checkpoint.

config
PreTrainedConfig

Target config, with vocabulary, hidden size and tying metadata.

device
torch.device

Device for the frozen tables.

dtype
torch.dtype

Compute dtype used by the draft.

Returns: DFlashTargetTables

Frozen tables, sharing the same weight when an omitted output head

nemo_automodel.components.speculative.dflash.cached_target._read_weights(
source: str,
keys: tuple[str, str],
revision: str | None
) -> dict[str, torch.Tensor]