Skip to content

Preserve tiny sigmoid scores in biased fused routing - #3637

Open
philipcmonk wants to merge 2 commits into
NVIDIA:mainfrom
philipcmonk:fix-sigmoid-score-cancellation
Open

philipcmonk wants to merge 2 commits into
NVIDIA:mainfrom
philipcmonk:fix-sigmoid-score-cancellation

Conversation

@philipcmonk

Copy link
Copy Markdown

Description

Gather selected sigmoid scores from the saved unbiased intermediate instead of subtracting expert bias after top-k. Adding the bias can round away tiny scores, which subtraction cannot recover.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

When using sigmoid score function, use saved original score instead of (score + bias) - bias which can cause unnecessary rounding.

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

cc @deepakn94 @abhinav-khattar @RobMcH

Gather selected sigmoid scores from the saved unbiased intermediate
instead of subtracting expert bias after top-k. Adding the bias can
round away tiny scores, which subtraction cannot recover.

Keep expert selection, QB histograms, and other score functions unchanged.
Cover tiny and mixed scores across top-k sizes, QB modes, and output maps.

Signed-off-by: Philip Monk <pmonk@nvidia.com>
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Oct 6, 2026
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes score preservation in the fused routing kernel.

The PR appears safe to merge; no blocking issue was found.

What we checked:

  • Saved scores are ready: Both kernels save every raw sigmoid score before selecting experts. Their __syncwarp() calls order the writes before the selected-score reads.

Summary

Biased sigmoid routing now gathers selected scores from the saved unbiased values instead of subtracting the bias. This preserves tiny scores that adding the bias can round away.

  • Updates both forward kernels without changing expert selection.
  • Adds checks for scores, routing layouts, histograms, and gradients.
  • No actionable issues found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Raw sigmoid scores] --> B[Save unbiased scores]
  A --> C[Add expert bias]
  C --> D[Select experts]
  B --> E[Gather selected raw scores]
  D --> E
  E --> F[Normalize and scale]
Loading

Reviews (2) · Last reviewed commit: "Merge branch 'main' into fix-sigmoid-sco..."

@ksivaman
ksivaman self-requested a review October 6, 2026 19:38
@ksivaman

ksivaman commented Oct 6, 2026

Copy link
Copy Markdown
Member

/te-ci pytorch L0

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants