Repository navigation
Conversation
|
cc @Cyrilvallez since you were the reviewer on #49737 ! |
|
cc @vasqu @IlyasMoutawwakil do you think we want to support such a feature for fp8? |
vasqu
left a comment
There was a problem hiding this comment.
Looking better thanks, some smaller details mostly let's get the attr within their inits not directly under the class
|
Hi @vasqu, would you mind taking another look at this PR when you have a chance? Thanks again for the detailed feedback and your time! |
vasqu
left a comment
There was a problem hiding this comment.
Sorry to backtrack a bit but the forward definitely gets more ugly. This is mostly about style not a functional issue overall re my comments here
| # Declare the clipping order for replacement expert implementations. | ||
| self.limit_after_act = True |
There was a problem hiding this comment.
lets add it as config value no?
There was a problem hiding this comment.
Agreed that the clipping order should be discoverable from the config. Ling and Step3p7 now expose limit_after_act as a read-only property on their config classes, and BF16/FP8 initialize from it. Post-activation clipping is fixed by these architectures, and the released checkpoint configs do not declare a separate flag. This keeps it available through the config without adding a serialized field or making the order independently configurable. Would that work for these released checkpoints? For future checkpoint formats, I'd prefer to make this explicit in the published config from the outset. Leaving this thread open for your thoughts.
@vasqu Thanks for taking another look. Agreed that the clipping order should be discoverable from the config. For the existing Ling and Step3p7 checkpoints, post-activation clipping is part of the architecture, and their configs don't declare a separate flag. Would you be okay with exposing limit_after_act as a fixed, read-only property on their config classes for these existing models? Both BF16 and FP8 could read it through the same config interface without introducing a new serialized field. For future Ling checkpoint releases, I plan to make this metadata explicit in config.json, following the standardized naming we agree on here. |
|
Thanks again for the detailed review, @vasqu. I've pushed a cleanup that restores constructor-only infinity normalization, moves per-layer limit selection into the child modules, and reuses the Step3p7 shared-MLP forward. FP8 now reads the settings from the config, and only the complete tiny-model FP8 output test remains among the added tests. The GPU integration test passed, and I checked separately that losing the clipping order, either threshold, or the layer index makes its output assertion fail. I've updated the description and resolved the addressed threads, leaving the two config-property discussions open for your thoughts. When you have a chance, could you please take another look? Thanks for helping simplify this. |
vasqu
left a comment
There was a problem hiding this comment.
Last comments looks good now
| self.limit = (config.swiglu_limits_shared[layer_idx] if config.swiglu_limits_shared else 0) or float("inf") | ||
| # Zero or a missing per-layer limit disables clipping. | ||
| self.limit = ( | ||
| config.swiglu_limits_shared[layer_idx] if layer_idx is not None and config.swiglu_limits_shared else None |
There was a problem hiding this comment.
layer idx check is maybe a bit overkill no?
| @property | ||
| def limit_after_act(self) -> bool: | ||
| """Clipping order is fixed by the architecture and is not serialized.""" | ||
| return True |
There was a problem hiding this comment.
yep im fine with a property on this, it should only be true anyways so setting it shouldnt be done in these cases anyways then
|
|
||
|
|
||
| class BailingHybridExperts(DeepseekV3Experts): | ||
| @use_experts_implementation |
There was a problem hiding this comment.
hmm maybe we just forgot but imo the step model should be able to use the decorator as well, can you check? so here we dont need the extra decorator declared
| # swiglu_limit is a scalar shared across layers; swiglu_limits is a per-layer list. | ||
| # Post-activation clipping prefers the list, falling back to the scalar if absent. | ||
| # Zero/None disables clipping in this path; other gate formulas keep their scalar semantics. | ||
| self.limit_after_act = getattr(config, "limit_after_act", False) | ||
| self.limit = None | ||
| if self.limit_after_act: | ||
| limits = getattr(config, "swiglu_limits", None) | ||
| if limits is not None and layer_idx is None: | ||
| raise ValueError("Per-layer SwiGLU limits require a layer index.") | ||
| self.limit = (limits[layer_idx] if limits is not None else self.swiglu_limit) or float("inf") |
There was a problem hiding this comment.
id remove the comment tbh + limits could exist outside of limit after act no?
| @require_torch_gpu | ||
| @require_kernels | ||
| @require_cuda_capability_at_least(9, 0) | ||
| class BailingHybridFp8IntegrationTest(unittest.TestCase): |
There was a problem hiding this comment.
there is already BailingHybridIntegrationTest, can we fit it in there? maybe a smaller dummy model if possible?
|
[For maintainers] Suggested jobs to run (before merge) run-slow: bailing_hybrid, step3p7 |
| has_bias: bool = False, | ||
| has_gate: bool = True, | ||
| expert_dtype: str = "fp8", | ||
| layer_idx: int | None = None, |
There was a problem hiding this comment.
the fp8 experts don't need all this, just pass the right swiglu_limit from the original module and set it if given else use the one from the config
What does this PR do?
BailingHybrid currently ignores the per-layer SwiGLU limits in the published Ling checkpoint configs. This applies the routed and shared expert limits independently: the gate is clipped after SiLU, and the up projection is bounded symmetrically. Missing or zero limits retain the unclipped behavior.
Ling reuses the Step3p7 expert and shared-MLP forwards. Each module selects its limit from the config using its layer index. FP8 replacement uses the same config rather than copying clipping attributes from the original module. Ling's published config keys and zero values are preserved;
limit_after_actis exposed as a fixed config-class property, without a new serialized field. Existing pre-activation and SwiGLU-OAI formulas retain their behavior. SonicMoE rejects routed clipping at its backend entry point because its fused gate does not implement this formula.Split from #49737 following review. This PR does not include the Ling 3.1 MLA or MTP changes.
Validation
MemoryCleanupMixinand a two-expert dummy model. It saves and loads a complete tiny hybrid model through the FP8 quantizer, executesmodel(input_ids), and compares fixed expected logits. The test passed on GPU without skipping.3ecbf80f1) cover direct and low-rank Q projections, FP8 shared projections, cached/cacheless logits, generated tokens, module dtypes and native-format save/reload. Outputs match exactly. Expert gate compilation withfullgraph=Truealso matches eager execution.AI assistance was used for implementation, review and testing.