[{"data":1,"prerenderedAt":441},["ShallowReactive",2],{"navigation":3,"\u002Falgorithms\u002Ftransport\u002Freference":174,"\u002Falgorithms\u002Ftransport\u002Freference-surround":436},[4,8,101,165,170],{"title":5,"path":6,"stem":7},"Getting started","\u002Fgetting-started","1.getting-started",{"title":9,"path":10,"stem":11,"children":12},"Algorithms","\u002Falgorithms","2.algorithms",[13,15,58],{"title":9,"path":10,"stem":14},"2.algorithms\u002Findex",{"title":16,"path":17,"stem":18,"children":19},"Assignment","\u002Falgorithms\u002Fassignment","2.algorithms\u002F1.assignment\u002Findex",[20,21,25,29,32,36,40],{"title":16,"path":17,"stem":18},{"title":22,"path":23,"stem":24},"Quickstart","\u002Falgorithms\u002Fassignment\u002Fquickstart","2.algorithms\u002F1.assignment\u002F1.quickstart",{"title":26,"path":27,"stem":28},"Tracking","\u002Falgorithms\u002Fassignment\u002Ftracking","2.algorithms\u002F1.assignment\u002F2.tracking",{"title":9,"path":30,"stem":31},"\u002Falgorithms\u002Fassignment\u002Falgorithms","2.algorithms\u002F1.assignment\u002F3.algorithms",{"title":33,"path":34,"stem":35},"Reference","\u002Falgorithms\u002Fassignment\u002Freference","2.algorithms\u002F1.assignment\u002F4.reference",{"title":37,"path":38,"stem":39},"Choosing","\u002Falgorithms\u002Fassignment\u002Fchoosing","2.algorithms\u002F1.assignment\u002F5.choosing",{"title":41,"path":42,"stem":43,"children":44},"Tutorials","\u002Falgorithms\u002Fassignment\u002Ftutorials","2.algorithms\u002F1.assignment\u002F6.tutorials\u002Findex",[45,46,50,54],{"title":41,"path":42,"stem":43},{"title":47,"path":48,"stem":49},"Fundamentals","\u002Falgorithms\u002Fassignment\u002Ftutorials\u002Ffundamentals","2.algorithms\u002F1.assignment\u002F6.tutorials\u002F1.fundamentals",{"title":51,"path":52,"stem":53},"Backends","\u002Falgorithms\u002Fassignment\u002Ftutorials\u002Fbackends","2.algorithms\u002F1.assignment\u002F6.tutorials\u002F2.backends",{"title":55,"path":56,"stem":57},"Object tracking","\u002Falgorithms\u002Fassignment\u002Ftutorials\u002Ftracking","2.algorithms\u002F1.assignment\u002F6.tutorials\u002F3.tracking",{"title":59,"path":60,"stem":61,"children":62},"Transport","\u002Falgorithms\u002Ftransport","2.algorithms\u002F2.transport\u002Findex",[63,64,67,71,74,77,80,84],{"title":59,"path":60,"stem":61},{"title":22,"path":65,"stem":66},"\u002Falgorithms\u002Ftransport\u002Fquickstart","2.algorithms\u002F2.transport\u002F1.quickstart",{"title":68,"path":69,"stem":70},"Point-cloud tutorial","\u002Falgorithms\u002Ftransport\u002Fpoint-clouds","2.algorithms\u002F2.transport\u002F2.point-clouds",{"title":9,"path":72,"stem":73},"\u002Falgorithms\u002Ftransport\u002Falgorithms","2.algorithms\u002F2.transport\u002F3.algorithms",{"title":33,"path":75,"stem":76},"\u002Falgorithms\u002Ftransport\u002Freference","2.algorithms\u002F2.transport\u002F4.reference",{"title":37,"path":78,"stem":79},"\u002Falgorithms\u002Ftransport\u002Fchoosing","2.algorithms\u002F2.transport\u002F5.choosing",{"title":81,"path":82,"stem":83},"Building","\u002Falgorithms\u002Ftransport\u002Fbuilding","2.algorithms\u002F2.transport\u002F6.building",{"title":41,"path":85,"stem":86,"children":87},"\u002Falgorithms\u002Ftransport\u002Ftutorials","2.algorithms\u002F2.transport\u002F7.tutorials\u002Findex",[88,89,93,97],{"title":41,"path":85,"stem":86},{"title":90,"path":91,"stem":92},"Optimal transport","\u002Falgorithms\u002Ftransport\u002Ftutorials\u002Foptimal-transport","2.algorithms\u002F2.transport\u002F7.tutorials\u002F1.optimal-transport",{"title":94,"path":95,"stem":96},"Sinkhorn","\u002Falgorithms\u002Ftransport\u002Ftutorials\u002Fsinkhorn","2.algorithms\u002F2.transport\u002F7.tutorials\u002F2.sinkhorn",{"title":98,"path":99,"stem":100},"Point clouds","\u002Falgorithms\u002Ftransport\u002Ftutorials\u002Fpoint-clouds","2.algorithms\u002F2.transport\u002F7.tutorials\u002F3.point-clouds",{"title":102,"path":103,"stem":104,"children":105},"Resources","\u002Fresources","3.resources",[106,108,147,151,155],{"title":102,"path":103,"stem":107},"3.resources\u002Findex",{"title":41,"path":109,"stem":110,"children":111},"\u002Fresources\u002Ftutorials","3.resources\u002F1.tutorials\u002Findex",[112,113,131],{"title":41,"path":109,"stem":110},{"title":16,"path":114,"stem":115,"children":116,"page":130},"\u002Fresources\u002Ftutorials\u002Fassignment","3.resources\u002F1.tutorials\u002Fassignment",[117,122,126],{"title":118,"path":119,"stem":120,"icon":121},"Tutorial 1 — The Assignment Problem","\u002Fresources\u002Ftutorials\u002Fassignment\u002F01_the_assignment_problem","3.resources\u002F1.tutorials\u002Fassignment\u002F01_the_assignment_problem","i-lucide-notebook",{"title":123,"path":124,"stem":125,"icon":121},"Tutorial 2 — Backends and Batching","\u002Fresources\u002Ftutorials\u002Fassignment\u002F02_backends_and_batching","3.resources\u002F1.tutorials\u002Fassignment\u002F02_backends_and_batching",{"title":127,"path":128,"stem":129,"icon":121},"Tutorial 3 — Object Tracking with the Assignment Problem","\u002Fresources\u002Ftutorials\u002Fassignment\u002F03_object_tracking","3.resources\u002F1.tutorials\u002Fassignment\u002F03_object_tracking",false,{"title":59,"path":132,"stem":133,"children":134,"page":130},"\u002Fresources\u002Ftutorials\u002Ftransport","3.resources\u002F1.tutorials\u002Ftransport",[135,139,143],{"title":136,"path":137,"stem":138,"icon":121},"Tutorial 1 — What Is Optimal Transport?","\u002Fresources\u002Ftutorials\u002Ftransport\u002F01_optimal_transport","3.resources\u002F1.tutorials\u002Ftransport\u002F01_optimal_transport",{"title":140,"path":141,"stem":142,"icon":121},"Tutorial 2 — The Sinkhorn Algorithm","\u002Fresources\u002Ftutorials\u002Ftransport\u002F02_sinkhorn_algorithm","3.resources\u002F1.tutorials\u002Ftransport\u002F02_sinkhorn_algorithm",{"title":144,"path":145,"stem":146,"icon":121},"Tutorial 3 — Point-Cloud OT and Shape Learning","\u002Fresources\u002Ftutorials\u002Ftransport\u002F03_point_clouds","3.resources\u002F1.tutorials\u002Ftransport\u002F03_point_clouds",{"title":148,"path":149,"stem":150},"Assignment applications","\u002Fresources\u002Fassignment-applications","3.resources\u002F2.assignment-applications",{"title":152,"path":153,"stem":154},"Transport applications","\u002Fresources\u002Ftransport-applications","3.resources\u002F3.transport-applications",{"title":156,"path":157,"stem":158,"children":159},"Benchmarks","\u002Fresources\u002Fbenchmarks","3.resources\u002F4.benchmarks\u002Findex",[160,161],{"title":156,"path":157,"stem":158},{"title":162,"path":163,"stem":164},"Contributing benchmarks","\u002Fresources\u002Fbenchmarks\u002Fcontributing","3.resources\u002F4.benchmarks\u002Fcontributing",{"title":166,"path":167,"stem":168,"icon":169},"API Reference","\u002Fapi","4.api","i-lucide-package",{"title":171,"path":172,"stem":173},"References","\u002Freferences","5.references",{"id":175,"title":176,"api":177,"body":178,"description":430,"extension":431,"links":177,"meta":432,"navigation":433,"path":75,"seo":434,"stem":76,"__hash__":435},"docs\u002F2.algorithms\u002F2.transport\u002F4.reference.md","Transport reference",null,{"type":179,"value":180,"toc":418},"minimark",[181,191,194,199,207,248,263,267,274,343,367,373,390,394,401,405],[182,183,184,185,190],"p",{},"Signatures, parameter types, and per-op descriptions are auto-generated from the source and browseable in the ",[186,187,189],"a",{"href":188},"\u002Fapi\u002Ftransport","API reference →",".",[182,192,193],{},"This page covers cross-cutting rules that apply to both transport surfaces.",[195,196,198],"h2",{"id":197},"two-surfaces","Two surfaces",[182,200,201,202,206],{},"The ",[203,204,205],"code",{},"torchmatch.transport"," namespace exposes two sub-packages that\nsolve closely related problems with different input conventions and\ndifferent runtime requirements:",[208,209,210,232],"ul",{},[211,212,213,219,220,223,224,227,228,231],"li",{},[214,215,216],"strong",{},[203,217,218],{},"torchmatch.transport.matrix"," takes a precomputed cost matrix\n(shape ",[203,221,222],{},"(N, M)"," or ",[203,225,226],{},"(B, N, M)",") and returns a transport plan in log\nspace or a scalar divergence. Backed by Python custom ops that run\niterative log-sum-exp loops on CPU and CUDA; ",[203,229,230],{},"EXACT_EMD"," uses a\nnetwork-simplex algorithm (CPU only).",[211,233,234,239,240,243,244,247],{},[214,235,236],{},[203,237,238],{},"torchmatch.transport.samples"," takes two raw point clouds\n(shapes ",[203,241,242],{},"(N, D)"," and ",[203,245,246],{},"(M, D)",") and returns a scalar OT loss or\ndebiased divergence. Pairwise squared distances are computed on the\nfly inside Triton kernels — no N×M matrix is materialised. CUDA only.",[182,249,250,251,254,255,258,259,262],{},"Both surfaces register their ops under ",[203,252,253],{},"torch.ops.transport.*","; the\nPython-side dispatchers (",[203,256,257],{},"transport.matrix.solve",",\n",[203,260,261],{},"transport.samples.loss",") are the recommended entry points.",[195,264,266],{"id":265},"input-semantics","Input semantics",[268,269,271],"h3",{"id":270},"transportmatrix",[203,272,273],{},"transport.matrix",[208,275,276,289,302,311,332],{},[211,277,278,281,282,285,286,190],{},[203,279,280],{},"NaN"," cells are ",[214,283,284],{},"rejected"," with a ",[203,287,288],{},"RuntimeError",[211,290,291,281,294,285,296,298,299,301],{},[203,292,293],{},"-inf",[214,295,284],{},[203,297,288],{},". A cost of ",[203,300,293],{},"\nwould break the solver's numerical assumptions; use a large negative\nfinite value if you need to strongly favour a particular pair.",[211,303,304,281,307,310],{},[203,305,306],{},"+inf",[214,308,309],{},"forbidden edges",". The dispatcher passes them\nthrough to the LSE solver, where they cancel automatically; the\nnetwork simplex handles them by withholding the edge from the graph.",[211,312,313,316,317,320,321,324,325,328,329,331],{},[203,314,315],{},"mask"," (optional ",[203,318,319],{},"bool"," tensor of the same shape as ",[203,322,323],{},"cost","): ",[203,326,327],{},"False","\ncells are rewritten to ",[203,330,306],{}," before the solver runs.",[211,333,334,243,336,316,339,342],{},[203,335,186],{},[203,337,338],{},"b",[203,340,341],{},"float"," tensors): source and target marginals.\nBoth default to uniform; either can be supplied on its own. Both must\nbe non-negative.",[182,344,345,347,348,351,352,355,356,358,359,362,363,366],{},[203,346,257],{}," raises ",[203,349,350],{},"ValueError"," for an out-of-range\n",[203,353,354],{},"ndim",", a non-float dtype, a non-CPU \u002F non-CUDA device, a NaN or\n",[203,357,293],{}," cell, a non-positive ",[203,360,361],{},"reg",", or an unknown ",[203,364,365],{},"backend"," string.",[268,368,370],{"id":369},"transportsamples",[203,371,372],{},"transport.samples",[182,374,375,376,379,380,347,383,385,386,389],{},"The samples surface is ",[214,377,378],{},"CUDA-only","; ",[203,381,382],{},"loss(...)",[203,384,288],{},"\nwhen called with CPU tensors. Triton kernels live under\n",[203,387,388],{},"sources\u002Ftorchmatch\u002Ftransport\u002Fsamples\u002Fkernels\u002F"," and load lazily on\nfirst call.",[195,391,393],{"id":392},"tracing-graph-capture","Tracing & graph capture",[182,395,396,397,400],{},"Both surfaces are compatible with ",[203,398,399],{},"torch.compile"," and support autograd.\nThey can be used inside compiled model code or as differentiable loss\nfunctions.",[195,402,404],{"id":403},"see-also","See also",[208,406,407,413],{},[211,408,409,412],{},[186,410,411],{"href":34},"Operations",": the assignment ops, for\ncomparison.",[211,414,415,417],{},[186,416,81],{"href":82},": wheel vs JIT paths and environment\noverrides.",{"title":419,"searchDepth":420,"depth":420,"links":421},"",3,[422,424,428,429],{"id":197,"depth":423,"text":198},2,{"id":265,"depth":423,"text":266,"children":425},[426,427],{"id":270,"depth":420,"text":273},{"id":369,"depth":420,"text":372},{"id":392,"depth":423,"text":393},{"id":403,"depth":423,"text":404},"Input rules, surface overview, and graph-capture notes for torchmatch.transport ops.","md",{},{"title":33},{"title":176,"description":430},"Tq9SvUAs-C-gqpNBTMAObqHNA6jYZTMKbiTzMM5scUU",[437,439],{"title":9,"path":72,"stem":73,"description":438,"children":-1},"The optimal transport problem, Sinkhorn, debiasing, unbalanced OT, and the network simplex — plus how the matrix-face Python LSE loops and the samples-face Triton streaming kernel implement them.",{"title":37,"path":78,"stem":79,"description":440,"children":-1},"A decision guide for transport.matrix and transport.samples backends, organised by cost type, differentiability requirements, and problem scale.",1785218159644]