-
Notifications
You must be signed in to change notification settings - Fork 577
Support quantization for tokamax gmm v2 #4451
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: main
Are you sure you want to change the base?
Changes from 30 commits
f814413
2cec661
b135e8e
f9f37b8
22bd5bc
159ea30
0db4e43
5073aef
f201c4a
a251753
f4553b6
fc5ac54
fced014
2ae50ca
61e72b2
16ac8aa
7b84920
51376c1
ded3f1b
5334a53
4d8578b
6225e47
201a8fc
38bd713
608305d
1ad5e94
87b2c8e
a5aac8c
9b67772
a911746
86d3272
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 |
|---|---|---|
|
|
@@ -358,6 +358,7 @@ class Checkpointing(BaseModel): | |
| source_checkpoint_layout: Literal["orbax", "safetensors", "safetensors_dynamic"] = Field( | ||
| "orbax", description="The layout of the source checkpoint to load." | ||
| ) | ||
| save_checkpoint_on_start: bool = Field(True, description="If True, saves an initial checkpoint upon training start.") | ||
| save_checkpoint_on_completion: bool = Field( | ||
| True, description="If True, saves a final checkpoint upon training completion." | ||
| ) | ||
|
|
@@ -450,7 +451,7 @@ class Quantization(BaseModel): | |
| use_qwix_quantization: bool = Field(False, description="Whether to use qwix for quantization.") | ||
| use_manual_quantization: bool = Field( | ||
| False, | ||
| description="Whether to use manual quantization for batch split. Only used if use_batch_split_schedule is True.", | ||
| description="Whether to use manual quantization for batch split. Only used if `use_batch_split_schedule=True`.", | ||
| ) | ||
| weight_quantization_calibration_method: str = Field( | ||
| "absmax", | ||
|
|
@@ -626,20 +627,6 @@ class Attention(BaseModel): | |
| use_post_attn_norm: bool = Field(False, description="Apply LayerNorm after the attention block.") | ||
| use_post_ffw_norm: bool = Field(False, description="Apply LayerNorm after the feed-forward block.") | ||
| use_ragged_attention: bool = Field(False, description="Whether to use ragged attention kernels.") | ||
| use_tokamax_gmm: bool = Field( | ||
| False, | ||
| description="Whether to use the Tokamax library for GMM kernel implementation.", | ||
| ) | ||
| use_gmm_v2: bool = Field( | ||
|
Collaborator
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. Can we still have this config that sets all fwd, dlhs and drhs to true in types.py when true?
Collaborator
Author
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. I have refactored the flag. Instead of three flags, we now use the original single flag
Collaborator
Author
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. keep |
||
| False, | ||
| description=( | ||
| "Whether to use GMM v2 (with bf16 activations and weights) for MoE." | ||
| " Requires use_tokamax_gmm: true. Currently incompatible with quantization." | ||
| ), | ||
| ) | ||
| num_moe_emb_chunks: int = Field( | ||
| 0, description="Number of chunks for overlapping token all-gather and GMM computation along embedding dimension." | ||
| ) | ||
| ragged_block_size: int = Field(256, description="Block size for ragged attention.") | ||
| enable_padding_causal_mask: bool = Field(True, description="Temporary flag for Transformer Engine padding.") | ||
| use_tokamax_splash: bool = Field(False, description="Whether to use tokamax splash attention.") | ||
|
|
@@ -991,6 +978,21 @@ class MoEKernels(BaseModel): | |
|
|
||
| merge_gating_gmm: bool = Field(False, description="whether to merge the two gating gmm kernels into one.") | ||
|
|
||
| num_moe_emb_chunks: int = Field( | ||
| 0, description="Number of chunks for overlapping token all-gather and GMM computation along embedding dimension." | ||
| ) | ||
|
|
||
| # tokamax gmm | ||
| use_tokamax_gmm: bool = Field( | ||
| False, | ||
| description="Whether to use the Tokamax library for GMM kernel implementation.", | ||
| ) | ||
|
|
||
| use_gmm_v2: bool = Field( | ||
| False, | ||
| description="Whether to use Tokamax GMM v2 for MoE kernel.", | ||
| ) | ||
|
|
||
|
|
||
| class DeepSeekMoE(BaseModel): | ||
| """Configuration specific to DeepSeek-style MoE layers.""" | ||
|
|
@@ -3664,10 +3666,15 @@ def calculate_global_batch_sizes(per_device_batch_size, expansion_factor, num_de | |
| if self.share_kv_projections and self.attention_type == "mla": | ||
| raise ValueError("`share_kv_projections` is not compatible with `attention_type='mla'`.") | ||
|
|
||
| if self.use_gmm_v2 and (self.quantization or self.use_qwix_quantization): | ||
| raise ValueError("Quantization with GMM v2 is not supported yet.") | ||
| if self.use_gmm_v2 and not self.use_tokamax_gmm: | ||
| raise ValueError("GMM v2 requires `use_tokamax_gmm=true`.") | ||
| if self.use_manual_quantization and not self.use_batch_split_schedule: | ||
| raise ValueError("manual quantization is only used when `use_batch_split_schedule=True`.") | ||
|
|
||
| # Validation for GMM v2 | ||
| if self.use_gmm_v2: | ||
| if not self.use_tokamax_gmm: | ||
| raise ValueError("GMM v2 requires `use_tokamax_gmm=True`.") | ||
| if self.use_batch_split_schedule: | ||
| raise ValueError("GMM v2 is not supported with a batch split schedule.") | ||
|
|
||
| for val in self.compress_ratios: | ||
| if val != 0 and val < 4: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.