Skip to content

Compose dist-GEMM from parallel linear projections - #4702

Closed
anijain2305 wants to merge 1 commit into
gh/anijain2305/26/basefrom
gh/anijain2305/26/head
Closed

anijain2305 wants to merge 1 commit into
gh/anijain2305/26/basefrom
gh/anijain2305/26/head

Conversation

@anijain2305

@anijain2305 anijain2305 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

[ghstack-poisoned]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 15, 2026
@anijain2305
anijain2305 marked this pull request as draft September 15, 2026 17:05
@anijain2305

Copy link
Copy Markdown
Contributor Author

Opened accidentally because compose-dist-gemm was still an ancestor of the linear stack. The work is preserved locally on compose-dist-gemm and is not part of this PR stack.

@anijain2305
anijain2305 deleted the gh/anijain2305/26/head branch September 15, 2026 17:08
sanketpurandare added a commit that referenced this pull request Oct 12, 2026
## Agent details

Prepared with AI assistance.

Reuse TorchAO's fused rowwise/columnwise activation cast and existing single-axis CuTeDSL casts, consuming blocked E8M0 scales without separate rearrangement kernels. Keep CUDA as the default and expose CuTeDSL as an explicit activation_quantization_backend option through both the linear and its converter. Input-save format, weight quantization, output ownership, FSDP lifetime and gradient accumulation policy are unchanged.

CuTeDSL requires 128-aligned BF16 matrices and the required runtime/API at construction. Unsupported shapes fail explicitly rather than padding activations to a larger GEMM or silently selecting another implementation. Represent dense matrices as one group, view the valid column-scale prefix, and retain immutable real endpoints for CUDA-graph pointer lifetime. Fake endpoints never enter the real cache.

Explicitly request RCEIL for every activation cast, matching the weight-scale policy independently of provider defaults. The existing operand tests check this forwarding while still executing each real provider kernel.

Depends on pytorch/ao#4995 as the single AO dependency. That PR preserves Protonu's kernel from #4895 and includes current nonfinite handling, the 32x1 FakeTensor fix (also addressed by Aleksandar in #4702), and byte-oracle regressions. The original PRs are provenance, not additional dependencies.

## Test Plan

Real CUDA comparisons validate all cast directions and two backward contributions, including in-place accumulation. Real two-rank FSDP checks cover compiled RAF=true, retained PP weights and CUDA-graph replay. Schema/FakeTensor opchecks validate provider layouts. Matched CUDA-graph replay checks defined output bytes, timing and actual target kernels.

```bash
python -m pytest tests/unit_tests/cpu/quantization/test_quantization.py tests/unit_tests/cpu/quantization/test_quantized_fsdp_tensor.py -q
python -m pytest tests/unit_tests/gpu/quantization/test_mxfp8_linear.py -q
python -m pytest tests/unit_tests/gpu/quantization/test_mxfp8_fsdp.py -q -k 'cutedsl or (tensor_lifecycle and not simple)'
pre-commit run --all-files
```
sanketpurandare added a commit that referenced this pull request Oct 13, 2026
## Agent details

Prepared with AI assistance.

Reuse TorchAO's fused rowwise/columnwise activation cast and existing single-axis CuTeDSL casts, consuming blocked E8M0 scales without separate rearrangement kernels. Keep CUDA as the default and expose CuTeDSL as an explicit activation_quantization_backend option through both the linear and its converter. Input-save format, weight quantization, output ownership, FSDP lifetime and gradient accumulation policy are unchanged.

CuTeDSL requires 128-aligned BF16 matrices and the required runtime/API at construction. Unsupported shapes fail explicitly rather than padding activations to a larger GEMM or silently selecting another implementation. Represent dense matrices as one group, view the valid column-scale prefix, and retain immutable real endpoints for CUDA-graph pointer lifetime. Fake endpoints never enter the real cache.

Explicitly request RCEIL for every activation cast, matching the weight-scale policy independently of provider defaults. The existing operand tests check this forwarding while still executing each real provider kernel.

Depends on pytorch/ao#4995 as the single AO dependency. That PR preserves Protonu's kernel from #4895 and includes current nonfinite handling, the 32x1 FakeTensor fix (also addressed by Aleksandar in #4702), and byte-oracle regressions. The original PRs are provenance, not additional dependencies.

## Test Plan

Real CUDA comparisons validate all cast directions and two backward contributions, including in-place accumulation. Real two-rank FSDP checks cover compiled RAF=true, retained PP weights and CUDA-graph replay. Schema/FakeTensor opchecks validate provider layouts. Matched CUDA-graph replay checks defined output bytes, timing and actual target kernels.

```bash
python -m pytest tests/unit_tests/cpu/quantization/test_quantization.py tests/unit_tests/cpu/quantization/test_quantized_fsdp_tensor.py -q
python -m pytest tests/unit_tests/gpu/quantization/test_mxfp8_linear.py -q
python -m pytest tests/unit_tests/gpu/quantization/test_mxfp8_fsdp.py -q -k 'cutedsl or (tensor_lifecycle and not simple)'
pre-commit run --all-files
```
sanketpurandare added a commit that referenced this pull request Oct 14, 2026
Performnace of this fused cute-dsl quantizer is better than cuda, a single API for dense and grouped mxfp8 linears, no need for scale rearrangements since swizzled layouts are directly output.

AI-assisted implementation details:

> Reuse TorchAO's fused dense rowwise/columnwise activation cast and existing
> single-axis CuTeDSL casts, consuming directly blocked E8M0 scales. Keep CUDA
> as the default and CuTeDSL as explicit activation_quantization_backend opt-in
> through the Linear and converter. Input-save format, weight quantization,
> output ownership, FSDP lifetime and gradient accumulation policy are unchanged.
>
> Use the provider's offs=None dense specialization, with compact column scales
> and no synthetic endpoint, cache, FakeTensor endpoint branch or padding trim.
> Construction rejects an older required-offset provider as well as missing
> symbols/runtime. Both real and fake paths use the same dense contract.
>
> CuTeDSL requires 128-aligned BF16 matrices. Unsupported shapes fail explicitly,
> without padding to a larger GEMM or silently changing implementations. Pin
> RCEIL for every activation cast to match the 32x32 weight-scale policy.
>
> Depends only on pytorch/ao#4995. Preserve credit to Protonu's original #4895
> kernel and Aleksandar's #4702 single-axis metadata work; those PRs remain
> provenance, not additional dependencies.
>
> Test plan: current CPU contracts, real CUDA cast directions/backward formats
> and accumulation, two-rank compiled/retained/CUDA-graph FSDP lifecycle,
> strict configuration/README rendering, complete repository lint and matched
> replay timings with actual target-kernel traces.
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.

1 participant