Version 2.2 research release

Custom-DL-Optimizer

Measure the workload. Keep the best valid plan.

A constraint-aware PyTorch inference selector for weighted serving signatures, persistent decisions, built-in compiler paths, and optional production runtimes.

pip install custom-dl-optimizer
4 built-in plans 3 runtime integrations P99 evidence 4 bounded agent tools

The deployment problem

A faster graph on paper can still lose in your process.

Models disagreeA pass that helps a dense CNN can regress a depthwise network.
Setup is not freeCompilation cost matters when services are short lived or shapes change.
Fast can be wrongPrecision and graph changes need parity checks before deployment.

What the package does

One workload profile enters. Several plans compete.

The host supplies a real model and representative tensors. Each eligible plan is built in isolation, checked against eager FP32, timed, and retained only when it clears the configured threshold.

A neural network graph branches into four profiled and rewritten candidates. Three candidates fail validation or selection, while one path reaches GPU execution.
01 Profile 02 Rewrite or compile 03 Validate parity 04 Select with fallback

Live selection trace

The raw winner is not always the deployable winner.

In this illustrative trace, an external backend is fastest but fails parity. The valid compiler plan wins; native remains available as the exit path.

Preparing candidates
CandidateMedian latencyDecision
Eager FP32 100.0 ms
Native AMP 43.0 ms
FX + Inductor 39.8 ms
External provider 35.4 ms
FX + Inductor selected: 2.51x vs eager, parity passed

Version 2 API

A callable result with the evidence attached.

The selected module and its report travel together. Save the evidence beside your deployment artifact, then inspect exactly why the plan won.

optimize.py
from custom_dl_optimizer import (
    OptimizationConfig,
    Optimizer,
)

optimizer = Optimizer(
    device="cuda",
    config=OptimizationConfig(
        enable_compile=True,
        min_speedup=1.02,
    ),
)

result = optimizer.optimize(model, sample)
output = result(sample)

print(result.selected_plan)
result.save_report("optimization.json")

Bring your strongest baseline

Compare built-ins, vendor compilers, and research backends under one policy.

Every plan is evaluated across weighted signatures. Custom-DL handles isolation, cold start, parity, P50-P99 measurement, resource constraints, amortization, cache validation, and fallback.

Built in
  • Eager FP32
  • Native AMP/layout
  • FX rewrites
  • FX + Inductor
Provider API
  • Torch-TensorRT
  • ONNX Runtime
  • TorchAO quantization
  • Private provider
One comparable report Per-case parity, P50-P99, constraints, cold start, cache state, break-even
Read the provider contract

Agent-safe by construction

Let an agent optimize approved workloads, not arbitrary code.

The host registers live modules and tensors in process. The agent sees only names and four bounded operations; no weights, paths, shell commands, downloads, or Python expressions cross the tool boundary.

Open the agent guide
inspect_runtimeread only
list_workloadsregistered only
optimizemeasured
get_reportJSON

Honest evidence

A regression is a result, not an inconvenience.

The historical T4 study shows why selection needs a native fallback. Most gains came from established precision, layout, and compiler techniques; the fixed custom path lost on MobileNet-V2.

ModelEager FP32InductorExperimentalvs eagervs Inductor
ResNet-50366.997 ms99.254 ms89.307 ms4.11x1.11x
MobileNet-V2112.703 ms54.312 ms64.372 ms1.75x0.84x
VGG-16639.399 ms273.326 ms273.402 ms2.34x1.00x
EfficientNet-B0146.788 ms70.784 ms66.409 ms2.21x1.07x
DenseNet-121360.750 ms194.997 ms193.169 ms1.87x1.01x

Historical hardware snapshot, not a v2 benchmark and not a state-of-the-art claim. Rerun the notebook before citing results.

Custom-DL-Optimizer v2

Do not guess which backend wins. Measure it.

Explore the repository