Skip to content
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

refactor: linearizer support multiple sets of accumulators #4419

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

chaosagent
Copy link
Contributor

No description provided.

@chaosagent chaosagent marked this pull request as draft May 4, 2024 14:47
@chaosagent
Copy link
Contributor Author

@0xtimmy brought up a good point in #4409 about re-broadcasting accs across unroll dim, need to adjust

@chaosagent chaosagent closed this May 4, 2024
@chaosagent
Copy link
Contributor Author

I'm not sure if I'm missing some details. @0xtimmy thoughts? or feel free to just do it yourself.

I think loaded_buffers need to be scoped per sequential loop.

@chaosagent chaosagent reopened this May 4, 2024
@0xtimmy
Copy link
Contributor

0xtimmy commented May 4, 2024

the self.earlybufs get updated (before the ast_parse) every time render_reducop is called so they are scoped in that sense
I had something similar to what you did with accs, treating it as a Dict[LazyOp, List[UOp]]

i think it looks good

@0xtimmy 0xtimmy mentioned this pull request May 4, 2024
@chaosagent
Copy link
Contributor Author

seems like accs and loaded_buffers kind of the same thing

@chaosagent chaosagent marked this pull request as ready for review May 5, 2024 06:52
@Qazalin
Copy link
Collaborator

Qazalin commented May 5, 2024

looks good, can you resolve the conflicts?

return acc
for u in self.ast_parse(x.src[0], accs, offs, loaded_buffers)]
if x.op in ReduceOps and do_reduce is None:
return [accs[x][i] for i in offs] if offs is not None else accs[x]
Copy link
Collaborator

@Qazalin Qazalin May 6, 2024

Choose a reason for hiding this comment

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

can you bring back the assert? we only need this when there are multiple reduceops.

Suggested change
return [accs[x][i] for i in offs] if offs is not None else accs[x]
assert offs is None, "not available if we aren't doing reduce"
return accs[x]

I think deleting asserts is a behavior change

@chaosagent
Copy link
Contributor Author

chaosagent commented May 8, 2024

It's hard to test this because there is no interface behavior change. Thus the future behavior changes need to be careful not to use this wrong. Maybe I am not refactoring these things in the correct order.

Copy link
Contributor

github-actions bot commented May 8, 2024

This branch currently is behind tinygrad/master. The line count difference bot is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants