Skip to content

[Test] Add YOLOv5 test file - #208

Merged
YWHyuk merged 1 commit into
PSAL-POSTECH:torch_v2.8from
Jagggged:fix/add_yolov5_2.8_ljg
Jan 27, 2026
Merged

YWHyuk merged 1 commit into
PSAL-POSTECH:torch_v2.8from
Jagggged:fix/add_yolov5_2.8_ljg

Conversation

@Jagggged

Copy link
Copy Markdown
Contributor
  • Add YOLOv5 test case for torch v2.8
  • Update Dockerfile to install required packages for YOLOv5
  • Add CPU fallback routine for convolution_overrideable operator

@YWHyuk
YWHyuk marked this pull request as draft January 26, 2026 04:32
@YWHyuk

YWHyuk commented Jan 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for PR @Jagggged

The compilation error is caused by an excessive number of graph breaks.
Once the predefined limit is reached, the model start to be executed in eager mode.
This is why aten.convolution ~ was called.

I think increasing these limits will resolve the issue.

torch._dynamo.config.recompile_limit = 64
torch._dynamo.config.cache_size_limit = 128

Can you add the above code in the test file and remove aten.fallback code in PyTorchSimDevice?

@Jagggged
Jagggged force-pushed the fix/add_yolov5_2.8_ljg branch 4 times, most recently from 0f7f1f1 to af7ebef Compare January 26, 2026 07:35
@Jagggged
Jagggged force-pushed the fix/add_yolov5_2.8_ljg branch from af7ebef to 89546d7 Compare January 26, 2026 07:36
@Jagggged

Copy link
Copy Markdown
Contributor Author

As suggested, I added the two lines above, removed the fallback routine, and recommitted the changes.
Thank you for your advice!

@YWHyuk
YWHyuk marked this pull request as ready for review January 27, 2026 07:54
@YWHyuk
YWHyuk merged commit 70f0f6c into PSAL-POSTECH:torch_v2.8 Jan 27, 2026
YWHyuk pushed a commit that referenced this pull request Oct 23, 2026
…s and indices once each

rewrite_topk replaced aten.topk with K rounds of amax, first index and
mask, then cat. Inductor fused the rounds into one kernel but made the cat
of 2K reductions into 2K column views of the outputs: a kernel with 16
output pointers for k = 8, and 16 DMAs a program on TOGSim. With the TOG
of the T 8192 router kernel cut to 2 contiguous stores and nothing else
changed, TOGSim went 94331 -> 81815 cycles; 16 contiguous stores stayed at
93388, so the cost is the count of DMAs. Every other kernel of the
compiler's validation bundle has one output.

frontend/topk.py registers aten::topk's npu kernel at AutogradPrivateUse1
and PrivateUse1 (the route attention takes, torch.library only) and calls
torchsim::topk, a triton_op. Its kernel takes a row on each lane, runs the
same rounds and gathers the K values and indices of its rows in registers,
then stores each once. topk_plan is the one gate: the last dim of a
floating input whose row fits the scratchpad budget; a program takes
vector_lanes rows (those past the end masked), so a call of fewer rows
keeps the same layout instead of spreading the row over the lanes. A
call the plan declines, and an eager call, run the rounds as aten ops;
a declined one is logged with its reason. The backward scatters the
values' gradient to the indices, aten's topk backward. rewrite_topk is
removed: no aten.topk on the npu reaches the post-grad graph.

tests/ops/sort/test_topk.py pins the routes and the values against a
stable CPU sort: rows a whole number of programs and not, a row length
that is not a power of two, smallest, bf16, ties to the first index, a
dim that is not the last (rounds), the gradient, eager and inference_mode,
and one launch counted per call. It joins the allowlist.

Timed with PyTorchSim-Triton-Backend's validation/vector harness on its main
7fb7195 (TOGSim 601fa78, configs/tpuv6e.yml), the bundle built by
scripts/ci/bundle.py with the topk suite (PyTorchSim #395) and the measured
tables of PyTorchSim-Triton-Backend #208: the Qwen3-30B-A3B router topk,
f32 [T, 128], k 8, T 1..8192, TOGSim over tpu-perf-archive topk_block
pallas_t_lanes. Geomean 2.160 -> 0.945, within 10% 0 -> 9 of 10. T 1 is
0.73: its v6e row includes a 0.99 us layout copy XLA adds around the
(1, 128) block. T >= 256 is 0.92-0.98, on the fast side.
YWHyuk pushed a commit that referenced this pull request Oct 23, 2026
…s and indices once each

rewrite_topk replaced aten.topk with K rounds of amax, first index and
mask, then cat. Inductor fused the rounds into one kernel but made the cat
of 2K reductions into 2K column views of the outputs: a kernel with 16
output pointers for k = 8, and 16 DMAs a program on TOGSim. With the TOG
of the T 8192 router kernel cut to 2 contiguous stores and nothing else
changed, TOGSim went 94331 -> 81815 cycles; 16 contiguous stores stayed at
93388, so the cost is the count of DMAs. Every other kernel of the
compiler's validation bundle has one output.

frontend/topk.py registers aten::topk's npu kernel at AutogradPrivateUse1
and PrivateUse1 (the route attention takes, torch.library only) and calls
torchsim::topk, a triton_op. Its kernel takes a row on each lane, runs the
same rounds and gathers the K values and indices of its rows in registers,
then stores each once. topk_plan is the one gate: the last dim of a
floating input whose row fits the scratchpad budget; a program takes
vector_lanes rows (those past the end masked), so a call of fewer rows
keeps the same layout instead of spreading the row over the lanes. A
call the plan declines, and an eager call, run the rounds as aten ops;
a declined one is logged with its reason. The backward scatters the
values' gradient to the indices, aten's topk backward. rewrite_topk is
removed: no aten.topk on the npu reaches the post-grad graph.

tests/ops/sort/test_topk.py pins the routes and the values against a
stable CPU sort: rows a whole number of programs and not, a row length
that is not a power of two, smallest, bf16, ties to the first index, a
dim that is not the last (rounds), the gradient, eager and inference_mode,
and one launch counted per call. It joins the allowlist.

Timed with PyTorchSim-Triton-Backend's validation/vector harness on its main
7fb7195 (TOGSim 601fa78, configs/tpuv6e.yml), the bundle built by
scripts/ci/bundle.py with the topk suite (PyTorchSim #395) and the measured
tables of PyTorchSim-Triton-Backend #208: the Qwen3-30B-A3B router topk,
f32 [T, 128], k 8, T 1..8192, TOGSim over tpu-perf-archive topk_block
pallas_t_lanes. Geomean 2.160 -> 0.945, within 10% 0 -> 9 of 10. T 1 is
0.73: its v6e row includes a 0.99 us layout copy XLA adds around the
(1, 128) block. T >= 256 is 0.92-0.98, on the fast side.
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