Skip to content

[Pallas] Test jagged carry with dynamic row counts#2722

Closed
thcmbs wants to merge 2 commits into
thcmbs/stack/3from
thcmbs/stack/4
Closed

[Pallas] Test jagged carry with dynamic row counts#2722
thcmbs wants to merge 2 commits into
thcmbs/stack/3from
thcmbs/stack/4

Conversation

@thcmbs

@thcmbs thcmbs commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 8, 2026
thcmbs added a commit that referenced this pull request Jun 8, 2026
stack-info: PR: #2722, branch: thcmbs/stack/4
@thcmbs thcmbs force-pushed the thcmbs/stack/3 branch 5 times, most recently from 77afab6 to a01f806 Compare June 11, 2026 16:29
if not (
isinstance(block_row, int)
and isinstance(block_col, int)
and isinstance(n_cols, int)

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.

I know this is just a draft, but I've been testing this PR as well. This restriction on n_cols being static prevented me from using the carry on grouped_gemm. However it's not hard to lift; the only issue is that we must support scratch shapes to print symbolic values. We can do that with

diff --git a/helion/_compiler/backend.py b/helion/_compiler/backend.py
--- a/helion/_compiler/backend.py
+++ b/helion/_compiler/backend.py
@@ -2437,7 +2437,10 @@ class PallasBackend(Backend):
                 for s in device_fn._scratch_args
             ]
             if scratch_shapes:
-                launcher_args.append(f"_scratch_shapes={scratch_shapes!r}")
+                from .host_function import HostFunction
+                launcher_args.append(
+                    f"_scratch_shapes={HostFunction.current().literal_expr(scratch_shapes)}"
+                )
 
             # Identify which launcher arg positions correspond to pipeline-body
             # tensors (need HBM refs); all others get proper BlockSpecs.
diff --git a/helion/_compiler/host_function.py b/helion/_compiler/host_function.py
--- a/helion/_compiler/host_function.py
+++ b/helion/_compiler/host_function.py
@@ -281,6 +281,8 @@ class HostFunction:
         if isinstance(expr, list):
             return "[" + ", ".join(self.literal_expr(x) for x in expr) + "]"
         if isinstance(expr, tuple):
+            if not expr:
+                return "()"
             return "(" + ", ".join(self.literal_expr(x) for x in expr) + ", )"
         return repr(expr)

(the first hunk is the important one; the second hunk unbreaks some tests pass when printing empty tuples on the scratch shapes)

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.

Do you want to pick up this work? I'd just submit this example as is to prevent regressions on what we currently support, but more than happy if we extend the coverage.

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.

Yes, happy to do this since I need it for grouped_gemm.

@thcmbs thcmbs force-pushed the thcmbs/stack/3 branch 7 times, most recently from 9fdb34c to 3c77116 Compare June 16, 2026 13:15
@thcmbs thcmbs closed this Jun 16, 2026
@thcmbs thcmbs deleted the thcmbs/stack/4 branch June 16, 2026 13:15
@thcmbs thcmbs restored the thcmbs/stack/4 branch June 16, 2026 13:20
@thcmbs thcmbs reopened this Jun 16, 2026
thcmbs added a commit that referenced this pull request Jun 16, 2026
stack-info: PR: #2722, branch: thcmbs/stack/4
thcmbs added a commit that referenced this pull request Jun 18, 2026
stack-info: PR: #2722, branch: thcmbs/stack/4
thcmbs added a commit that referenced this pull request Jun 18, 2026
stack-info: PR: #2722, branch: thcmbs/stack/4
stack-info: PR: #2719, branch: thcmbs/stack/3
stack-info: PR: #2722, branch: thcmbs/stack/4
@thcmbs thcmbs marked this pull request as ready for review June 19, 2026 13:39
@cota

cota commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

As it is now (just a test), does it more sense to land this as part of its parent PR?

@thcmbs

thcmbs commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

As it is now (just a test), does it more sense to land this as part of its parent PR?

Yep, fair point - done

@thcmbs thcmbs closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants