Skip to content

Fix cumsum dtype - #4511

Open
jloftin-nv wants to merge 2 commits into
pytorch:mainfrom
jloftin-nv:dev-jloftin-cumsum-dtype
Open

Fix cumsum dtype#4511
jloftin-nv wants to merge 2 commits into
pytorch:mainfrom
jloftin-nv:dev-jloftin-cumsum-dtype

Conversation

@jloftin-nv

Copy link
Copy Markdown
Contributor

Description

The cumsum converter drops the keyword-only dtype argument and always seeds the TRT loop accumulator as float32, so integer / typed cumsums disagree with PyTorch.

Forward dtype from the aten node and use a typed zero for the recurrence seed.

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • [ X] My code follows the style guidelines of this project (You can use the linters)
  • [ X] I have performed a self-review of my own code
  • [X ] I have commented my code, particularly in hard-to-understand areas and hacks
  • [ X] I have made corresponding changes to the documentation
  • [ X] I have added tests to verify my fix or my feature
  • [ X] New and existing unit tests pass locally with my changes
  • [ X] I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions Bot added component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: converters Issues re: Specific op converters component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Aug 18, 2026
@meta-cla meta-cla Bot added the cla signed label Aug 18, 2026
@github-actions
github-actions Bot requested a review from cehongwang August 18, 2026 21:51
@lanluo-nvidia lanluo-nvidia added this to the v2.14.0 milestone Aug 20, 2026
if dtype is not None:
acc_dtype = dtype
elif not input_dtype.is_floating_point:
acc_dtype = torch.int64

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is int64? Can it be int32 or other non-float dtype?

@jloftin-nv jloftin-nv Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see here it defaults to int64 in PyTorch

@cehongwang

Copy link
Copy Markdown
Collaborator

Can you also add a bf 16 test case?

@jloftin-nv
jloftin-nv force-pushed the dev-jloftin-cumsum-dtype branch from 4fa9d8d to b398035 Compare August 21, 2026 22:36
@lanluo-nvidia lanluo-nvidia modified the milestones: v2.14.0, v2.15.0 Aug 22, 2026
@jloftin-nv

Copy link
Copy Markdown
Contributor Author

Can you also add a bf 16 test case?

Added

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

Labels

cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants