Skip to content

2 pass added to the pallas kernel - #2

Open
kesavanramakrishnan wants to merge 1 commit into
marcelroed:mainfrom
kesavanramakrishnan:pallas-rework
Open

2 pass added to the pallas kernel#2
kesavanramakrishnan wants to merge 1 commit into
marcelroed:mainfrom
kesavanramakrishnan:pallas-rework

Conversation

@kesavanramakrishnan

Copy link
Copy Markdown
Collaborator

modified the pallas kernel reduce to 2 passes (as referenced in the tk kernel), should be a free speedup (stage 1 is ~1.2x faster than 3 pass version and end to end is ~1.15x)

@marcelroed this should be an easy merge

@marcelroed

Copy link
Copy Markdown
Owner

Awesome, thank you! Will review soon.

@marcelroed marcelroed left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm sitting down with this to find a real criteria for optimality, since it still seems like this can be simplified quite a bit.


D_i = D_ref[:]
# CHANGED (2-pass): B in closed form from the fused pass (was a second K pass).
B_i = r1_i - dD_i * r2_i - D_i * dD_i + r3_i

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Indicates r1 and r3 can be collapsed into a single value.

return B_i_acc
dD_i_acc += jnp.sum(ddS_ij * P_ij, axis=1)
r1_acc += jnp.sum(dPa_ij * P_ij, axis=1)
r2_acc += jnp.sum(dP_ij * P_ij, axis=1)

@marcelroed marcelroed Jun 14, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is r2 not identical to D, which is precomputed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes! realized this earlier as well, I removed it but forgot to update this version, though perf is about the same

@marcelroed marcelroed self-assigned this Jun 14, 2026
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.

2 participants