Skip to content

perf(assign): fuse unchanged dense CUDA assignment - #29

Open
JESUSROYETH wants to merge 1 commit into
Borda:mainfrom
JESUSROYETH:codex/fuse-dense-cuda-assignment-20261021
Open

JESUSROYETH wants to merge 1 commit into
Borda:mainfrom
JESUSROYETH:codex/fuse-dense-cuda-assignment-20261021

Conversation

@JESUSROYETH

Copy link
Copy Markdown
Collaborator

This reduces complete nano OBB training time by 10.94% on an L4 at batch 16/1024/BF16, with the merged replay and input options enabled.

The new fused_assignment option schedules dense IoU, class gather/masking, rotated containment and conflict resolution in four CUDA passes. It defaults to false, native PyTorch still computes powers, trigonometry, ranking and target normalization. Unsupported inputs keep the native path.

I ran five alternating 50-epoch pairs, seconds as median (range):

Main 8276de7 Patch
Complete fit 306.911 (300.181-311.299) 273.342 (273.152-279.940)
Whole process 312.132 (305.372-316.486) 278.525 (278.367-285.148)

All 350 loss values per run, model/optimiser/EMA/scheduler states and validation metrics match byte for byte. Focused CPU/CUDA checks and pre-commit pass. This measurement is for this recipe only. That said, full make gate, aggregate coverage, goldens and long-run accuracy remain unverified. Workload and startup limits are in WP-200b.

  • Clean-room acknowledged: the basis is this repository, our CUDA profiles and registered runtime APIs.

WP: 200b
Provenance: R40, R44
Assumptions: none
Gate: tests/assign/test_cuda_assignment.py; tests/ptl/test_loss_capture.py; tests/ptl/test_cli.py; tests/ptl/test_compile.py::TestDetectObjectiveTracesAsOneGraph

WP: 200b
Provenance: R40, R44
Assumptions: none
Gate: focused assignment, loss replay, CLI and compiler tests; pre-commit
Signed-off-by: Jesús Royeth <JESUSROYETH@users.noreply.github.com>
@JESUSROYETH
JESUSROYETH requested a review from Borda as a code owner October 22, 2026 10:06
@Borda
Borda requested a balanced review from Copilot October 22, 2026 20:45
@Borda Borda added the enhancement New feature or request label Oct 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The fit-test assertion rejects valid native-fallback environments because it treats Triton availability as full backend eligibility.

1 open issue
What changed in this PR

Adds opt-in CUDA fusion to the existing target-assignment pipeline, aiming to reduce training time without changing assignment results. The reported 10.94% complete-fit improvement applies to the measured nano OBB workload.

Changes:

  • Adds four CUDA passes with native fallbacks for unsupported execution.
  • Threads fused_assignment through training, both loss branches and graph-recording checks.
  • Adds parity, fallback, replay and CLI tests, plus installation and benchmark documentation.

Validation remains provisional: full make gate, aggregate coverage, accelerator goldens and long-run accuracy are unverified. No runtime checks were performed in this review.

File Description
tests/​ptl/​test_loss_capture.py Exercises fused assignment during loss replay and training.
tests/​ptl/​test_compile.py Checks compiler tracing with fusion requested.
tests/​ptl/​test_cli.py Verifies CLI forwarding to both assigners.
tests/​assign/​test_cuda_assignment.py Adds parity, eligibility, boundary and replay coverage.
src/​lucid_yolo/​ptl/​module.py Exposes the default-off training option.
src/​lucid_yolo/​ptl/​loss_capture.py Includes fusion settings and helpers in recording checks.
src/​lucid_yolo/​losses/​dual_loss.py Forwards fusion requests to both branches.
src/​lucid_yolo/​assign/​tal.py Integrates optional CUDA passes into assignment.
src/​lucid_yolo/​assign/​stal.py Forwards the small-target assigner's option.
src/​lucid_yolo/​assign/​one_to_one.py Forwards the unique assigner's option.
src/​lucid_yolo/​assign/​_cuda.py Handles eligibility, launches, readiness and fallback.
src/​lucid_yolo/​assign/​_cuda_kernels.py Implements the four device passes.
pyproject.toml Adds optional CUDA-assignment dependencies.
docs/​work_packages/​wp-200b.md Records implementation, measurements and limitations.
docs/​work_packages/​wp-200.md Links the dependent work package.
docs/​work_packages/​wp-199.md Adds the dependency backlink.
docs/​work_packages/​wp-198.md Adds the dependency backlink.
docs/​TRAINING.md Documents installation, eligibility and usage.
docs/​ROADMAP.md Tracks WP-200b and outstanding validation.
docs/​PROVENANCE.md Records implementation sources and runtime constraints.
docs/​engineering/​phase-17-pose-objective-parity.md Includes the new work-package report.

Review effort: Balanced

Comment on lines +678 to +679
if fused_assignment and _cuda._AVAILABLE:
assert {kind for kind, _ in _cuda._STATE.verified} == {"metric", "conflicts"}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants