Skip to content

[CI] The bundle carries validation/layer, under the compiler's CI cap, and names each call left to aten - #401

Merged
YWHyuk merged 2 commits into
pytorchsim-triton-backendfrom
bundle/layer-suite
Oct 21, 2026
Merged

YWHyuk merged 2 commits into
pytorchsim-triton-backendfrom
bundle/layer-suite

Conversation

@YWHyuk

@YWHyuk YWHyuk commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

The validation bundle now carries the compiler's validation/layer suite: Qwen3-30B-A3B's decoder layer and each of its ops. The bundle fits the 240-min job, and each manifest names the calls Inductor leaves to aten.

Commits

  • 0204134: the layer suite. bundle.py builds each row of validation/layer/tpu_v6e_qwen3moe_layer_torchxla.csv the way the TPU harness ran it:

    • the whole layer for prefill and decode;
    • rmsnorm, q/k_norm, rope_q/k, residual, router_post, dispatch, gmm_gate_up, silu_mul, gmm_down and combine, each alone.

    It runs as its own timing-mode process in CI, because its projections are mm templates.

  • 57564ee: the cap, the processes, and the externs.

    • Cap. The layer suite bundles only the rows that the compiler's own validation/layer/simulate_shapes.py under_cap accepts: a layer's S and an op's T at most 4096. The definition is loaded from the pinned compiler, not restated here. Other suites still build every row.
    • Processes. bundle.py --jobs N builds the workloads in N spawned processes. Each process takes the next workload, largest first by the compiler's rank (token_pairs). CI uses --jobs 4 for the layer.
    • Externs. Each manifest.json gains externs: every call Inductor left to aten, in order, each with at, the number of launches before it. Detection:
      • The npu wrapper codegen class is the one registered for the device through Inductor's register_backend_for_device. Its generate_extern_kernel_out/alloc/multi_out, generate_fallback_kernel(_with_runtime_lookup), generate_scatter_fallback and generate_index_put_fallback each write a torchsim_extern(<op>) line before the call they emit.
      • <op> is the op the IR node holds (aten.sort.stable), or the Python callable it calls when it holds none (extern_kernels.mm).
      • bundle.py observes those lines at runtime, the same way it observes launches. Nothing parses generated code or text.
      • A TorchDispatchMode was tried first and rejected: with a mode active, Dynamo runs dispatch eagerly instead of compiling it.

Measured

The bundle step was run as CI runs it: gemm in timing mode, the layer in timing mode with --jobs 4, and vector+attention, all three at once. Dumps were cold, no previous picks were used, and the host has 50 cores. Rows over the cap (all T or S 8192, 14 of them) were dropped.

run wall
layer, 96 capped rows, 4 processes 5229 s (87 min)
gemm 4856 s
vector + attention 1503 s
the step 5229 s

In one process the capped layer took about 3.8 h by earlier per-row probes; prefill S 4096 alone is 5104 s. The layer's wall time is now set by that one row.

Externs found in the bundle: 32 of 96 layer workloads, and none in gemm (62), vector (228) or attention (56).

  • aten._grouped_mm.default: every gmm op row (which holds only a cumsum kernel), plus 2 per layer.
  • aten.sort.stable: dispatch at T >= 128, and the prefill layers.

Tracking

Landing order

This workflow runs only on a push to pytorchsim-triton-backend, never on a PR. That push opens or updates the compiler's bot/pts-bundle PR (scripts/ci/ptb_bundle_pr.sh). The order:

  1. A layer workload with calls left to aten is incomplete: shown, and in no verdict or geomean PyTorchSim-Triton-Backend#226 first. The layer report then marks workloads with externs incomplete and leaves them out of every verdict and geomean. It ignores a manifest without the field, so either order loads, but this order keeps the bundle PR's first report honest.
  2. [Simulator] Compiler pin: PTB main 32b15ae #394 (compiler pin to PTB 9798c68). That commit has validation/layer and its under_cap / token_pairs. At the current pin d0553bd the layer suite has no csv, and the bundle job would fail.
  3. This PR. Its merge pushes the bundle with the layer rows and their externs to the compiler as bot/pts-bundle.

🤖 Generated with Claude Code

https://claude.ai/code/session_011cGNfHFySFsi7feZKKvq7e

…er and each of its ops

The layer suite reads the compiler's validation/layer/tpu_v6e_qwen3moe_layer_torchxla.csv and
builds each row as the TPU harness (tpu-perf-archive harness/qwen_moe_layer_v1.py) ran it: the
whole layer for prefill (T = S) and decode (one token over a cache of S, its own K/V not written),
and rmsnorm, q_norm, k_norm, rope_q, rope_k, residual, router_post, dispatch, gmm_gate_up,
silu_mul, gmm_down and combine alone at the layer's shapes. Routing is the harness's fixed uniform
ids (token i -> experts 8i..8i+7 mod 128), passed in as an input; combine's unsort is its
`positions` form; torch_xla's gmm is torch.nn.functional.grouped_mm. The manifest carries
section, name, T and S.

A workload's inputs now come from a maker drawing on the generator, so the layer's weights,
rope tables and ids are inputs beside the normal tensors; the existing suites draw exactly what
they drew before. The layer runs in its own timing-mode process in CI, since its projections
are mm templates; its picks are folded into the record with the GEMMs'.
…four processes, and names each call left to aten

The layer suite bundles only the rows the compiler's validation/layer/simulate_shapes.py under_cap takes
(a layer's S, an op's T at most 4096), read from the compiler itself so the cap has one definition; the
other suites still build every row. `bundle.py --jobs N` builds the workloads in N spawned processes,
each taking the next one, largest first by the compiler's rank (token_pairs for the layer); CI builds
the layer with four, since its prefill at S 4096 alone takes ~85 min. Measured on the bundle step as CI
runs it (gemm and vector+attention beside it, cold dumps, no previous picks): the 96 capped layer rows
in 5229 s against ~3.8 h in one process, gemm 4856 s, vector+attention 1503 s, the step 5229 s.

Each manifest gains `externs`: every call Inductor left to aten (an extern kernel or a fallback), in
order, with `at`, the launches before it. They run as aten does and nothing is simulated for them. The
npu wrapper codegen, the class registered for the device, writes a torchsim_extern line before each
such call, naming the op its IR node holds (or the callable it calls), and bundle.py observes those as
it observes launches; nothing reads generated code. On the layer suite these are
aten._grouped_mm.default (#398) and aten.sort.stable (#399), tracked in #397.
@YWHyuk
YWHyuk force-pushed the bundle/layer-suite branch from 57564ee to 859c97a Compare October 21, 2026 03:17
@YWHyuk
YWHyuk merged commit 55ce67e into pytorchsim-triton-backend Oct 21, 2026
@YWHyuk
YWHyuk deleted the bundle/layer-suite branch October 23, 2026 03:03
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.

1 participant