libsdca 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libsdca-0.4.0/AGENTS.md +88 -0
- libsdca-0.4.0/CHANGELOG.md +247 -0
- libsdca-0.4.0/CITATION.cff +73 -0
- libsdca-0.4.0/DEPENDENCIES.md +82 -0
- libsdca-0.4.0/MANIFEST.in +7 -0
- libsdca-0.4.0/PKG-INFO +311 -0
- libsdca-0.4.0/README.md +359 -0
- libsdca-0.4.0/VERSION +1 -0
- libsdca-0.4.0/docs/API.md +725 -0
- libsdca-0.4.0/docs/C.md +206 -0
- libsdca-0.4.0/docs/CPP.md +231 -0
- libsdca-0.4.0/docs/JAX.md +227 -0
- libsdca-0.4.0/docs/PYTHON.md +236 -0
- libsdca-0.4.0/docs/README.md +18 -0
- libsdca-0.4.0/docs/RUST.md +187 -0
- libsdca-0.4.0/docs/TORCH.md +338 -0
- libsdca-0.4.0/include/sdca/c_api.h +445 -0
- libsdca-0.4.0/include/sdca/core/driver.h +202 -0
- libsdca-0.4.0/include/sdca/core/each_isa.h +56 -0
- libsdca-0.4.0/include/sdca/core/execution.h +33 -0
- libsdca-0.4.0/include/sdca/core/isa.h +116 -0
- libsdca-0.4.0/include/sdca/core/lambert.h +374 -0
- libsdca-0.4.0/include/sdca/core/lanes.h +749 -0
- libsdca-0.4.0/include/sdca/core/limits.h +184 -0
- libsdca-0.4.0/include/sdca/core/math.h +455 -0
- libsdca-0.4.0/include/sdca/core/project.h +10 -0
- libsdca-0.4.0/include/sdca/core/project_base.h +487 -0
- libsdca-0.4.0/include/sdca/core/project_entropy.h +603 -0
- libsdca-0.4.0/include/sdca/core/project_knapsack.h +388 -0
- libsdca-0.4.0/include/sdca/core/project_numeric.h +91 -0
- libsdca-0.4.0/include/sdca/core/project_softmax.h +928 -0
- libsdca-0.4.0/include/sdca/core/project_topk.h +313 -0
- libsdca-0.4.0/include/sdca/core/project_topk_entropy.h +814 -0
- libsdca-0.4.0/include/sdca/core/project_two_simplex.h +307 -0
- libsdca-0.4.0/include/sdca/core/reduce.h +403 -0
- libsdca-0.4.0/include/sdca/core/select.h +120 -0
- libsdca-0.4.0/include/sdca/core/storage.h +313 -0
- libsdca-0.4.0/include/sdca/core/types.h +29 -0
- libsdca-0.4.0/include/sdca/kernel.h +413 -0
- libsdca-0.4.0/include/sdca/loss/ce.h +1066 -0
- libsdca-0.4.0/include/sdca/loss/distill.h +1243 -0
- libsdca-0.4.0/include/sdca/loss/multilabel.h +343 -0
- libsdca-0.4.0/include/sdca/loss/proximal.h +113 -0
- libsdca-0.4.0/include/sdca/loss/row.h +194 -0
- libsdca-0.4.0/include/sdca/loss/teacher_gradient.h +206 -0
- libsdca-0.4.0/include/sdca/loss/topk.h +840 -0
- libsdca-0.4.0/include/sdca/loss.h +156 -0
- libsdca-0.4.0/include/sdca/math/blas.h +85 -0
- libsdca-0.4.0/include/sdca/math/blas_builtin.h +31 -0
- libsdca-0.4.0/include/sdca/math/cblas.h +45 -0
- libsdca-0.4.0/include/sdca/prox.h +259 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/context.h +30 -33
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/data/dataset.h +3 -2
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/data/input.h +9 -8
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/data/output.h +11 -21
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/data/scratch.h +26 -25
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/data.h +37 -48
- libsdca-0.4.0/include/sdca/solver/duals.h +139 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/eval/core.h +3 -2
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/eval/dual.h +3 -2
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/eval/evaluate.h +135 -165
- libsdca-0.4.0/include/sdca/solver/eval/linalg.h +84 -0
- libsdca-0.4.0/include/sdca/solver/eval/primal.h +168 -0
- libsdca-0.4.0/include/sdca/solver/eval/products.h +301 -0
- libsdca-0.4.0/include/sdca/solver/eval/scores.h +95 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/eval/types.h +11 -9
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/eval.h +30 -10
- libsdca-0.4.0/include/sdca/solver/objective/entropy.h +494 -0
- libsdca-0.4.0/include/sdca/solver/objective/entropy_block.h +486 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/objective/feasible_dual.h +6 -5
- libsdca-0.4.0/include/sdca/solver/objective/hinge.h +260 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/objective/objective_base.h +242 -84
- libsdca-0.4.0/include/sdca/solver/objective.h +189 -0
- libsdca-0.4.0/include/sdca/solver/reporting.h +101 -0
- libsdca-0.4.0/include/sdca/solver/screening.h +120 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/solverdef.h +22 -10
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver/update.h +22 -46
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/solver.h +100 -14
- libsdca-0.4.0/include/sdca/utility/buffer.h +47 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/utility/fpenv.h +18 -0
- libsdca-0.4.0/include/sdca/utility/logging.h +111 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/utility/parallel.h +83 -21
- libsdca-0.4.0/include/sdca/utility/row_reduction.h +84 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/pyproject.toml +35 -23
- libsdca-0.4.0/python/libsdca/__init__.py +89 -0
- libsdca-0.4.0/python/libsdca/_composed/__init__.py +47 -0
- libsdca-0.4.0/python/libsdca/_composed/_api.py +152 -0
- libsdca-0.4.0/python/libsdca/_composed/_entropy.py +603 -0
- libsdca-0.4.0/python/libsdca/_composed/_jax_bfloat.py +63 -0
- libsdca-0.4.0/python/libsdca/_composed/_losses.py +803 -0
- libsdca-0.4.0/python/libsdca/_composed/_project.py +191 -0
- libsdca-0.4.0/python/libsdca/_composed/_targets.py +61 -0
- libsdca-0.4.0/python/libsdca/_composed/_xp.py +174 -0
- libsdca-0.4.0/python/libsdca/_composed/xp_jax.py +322 -0
- libsdca-0.4.0/python/libsdca/_composed/xp_torch.py +438 -0
- libsdca-0.4.0/python/libsdca/_extensions.py +250 -0
- libsdca-0.4.0/python/libsdca/_frontend.py +742 -0
- libsdca-0.4.0/python/libsdca/_frontend_cpu.h +170 -0
- libsdca-0.4.0/python/libsdca/_jax_alias.py +72 -0
- libsdca-0.4.0/python/libsdca/_jax_cpu.cpp +312 -0
- libsdca-0.4.0/python/libsdca/_jax_cuda.cpp +336 -0
- libsdca-0.4.0/python/libsdca/_jax_native.py +229 -0
- libsdca-0.4.0/python/libsdca/_jax_ops.py +634 -0
- libsdca-0.4.0/python/libsdca/_jax_results.py +63 -0
- libsdca-0.4.0/python/libsdca/_limits.py +151 -0
- libsdca-0.4.0/python/libsdca/_native.py +1315 -0
- libsdca-0.4.0/python/libsdca/_torch_compat.py +8 -0
- libsdca-0.4.0/python/libsdca/_torch_cpu.cpp +728 -0
- libsdca-0.4.0/python/libsdca/_torch_cuda_plan.h +260 -0
- libsdca-0.4.0/python/libsdca/_torch_linear.py +801 -0
- libsdca-0.4.0/python/libsdca/_torch_native.py +149 -0
- libsdca-0.4.0/python/libsdca/_torch_ops.py +660 -0
- libsdca-0.4.0/python/libsdca/_torch_teacher.py +45 -0
- libsdca-0.4.0/python/libsdca/jax.py +587 -0
- libsdca-0.4.0/python/libsdca/optax.py +167 -0
- libsdca-0.4.0/python/libsdca/sklearn.py +250 -0
- libsdca-0.4.0/python/libsdca/torch.py +1045 -0
- libsdca-0.4.0/python/libsdca/triton/__init__.py +6 -0
- libsdca-0.4.0/python/libsdca/triton/_jax_transport.py +45 -0
- libsdca-0.4.0/python/libsdca/triton/ce.py +2342 -0
- libsdca-0.4.0/python/libsdca/triton/common.py +443 -0
- libsdca-0.4.0/python/libsdca/triton/distill.py +3619 -0
- libsdca-0.4.0/python/libsdca/triton/jax_ffi.py +155 -0
- libsdca-0.4.0/python/libsdca/triton/launch_jax.py +424 -0
- libsdca-0.4.0/python/libsdca/triton/launch_torch.py +359 -0
- libsdca-0.4.0/python/libsdca/triton/linear.py +31 -0
- libsdca-0.4.0/python/libsdca/triton/math.py +329 -0
- libsdca-0.4.0/python/libsdca/triton/multilabel.py +783 -0
- libsdca-0.4.0/python/libsdca/triton/prox.py +1560 -0
- libsdca-0.4.0/python/libsdca/triton/reduce.py +243 -0
- libsdca-0.4.0/python/libsdca/triton/rows.py +215 -0
- libsdca-0.4.0/python/libsdca/triton/topk.py +2459 -0
- libsdca-0.4.0/python/libsdca.egg-info/PKG-INFO +311 -0
- libsdca-0.4.0/python/libsdca.egg-info/SOURCES.txt +269 -0
- libsdca-0.4.0/python/libsdca.egg-info/requires.txt +54 -0
- libsdca-0.4.0/sdca_build.py +169 -0
- libsdca-0.4.0/setup.py +153 -0
- libsdca-0.4.0/src/blas_probe.cpp +13 -0
- libsdca-0.4.0/src/c_api.cpp +945 -0
- libsdca-0.4.0/src/native_build.txt +30 -0
- libsdca-0.4.0/tests/python/boundaries.py +2104 -0
- libsdca-0.4.0/tests/python/conformance/__init__.py +9 -0
- libsdca-0.4.0/tests/python/conformance/backends.py +220 -0
- libsdca-0.4.0/tests/python/conformance/cells.py +501 -0
- libsdca-0.4.0/tests/python/conformance/contract.py +282 -0
- libsdca-0.4.0/tests/python/conformance/hinges.py +146 -0
- libsdca-0.4.0/tests/python/conformance/inputs.py +338 -0
- libsdca-0.4.0/tests/python/conformance/known.py +74 -0
- libsdca-0.4.0/tests/python/conformance/known_failures/Darwin-arm64.json +1196 -0
- libsdca-0.4.0/tests/python/conformance/known_failures/Linux-x86_64.json +1615 -0
- libsdca-0.4.0/tests/python/conformance/manifest.py +101 -0
- libsdca-0.4.0/tests/python/conformance/references.py +666 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/conftest.py +105 -3
- libsdca-0.4.0/tests/python/hinge_order_cases.py +79 -0
- libsdca-0.4.0/tests/python/interfaces.py +504 -0
- libsdca-0.4.0/tests/python/masked_cases.py +700 -0
- libsdca-0.4.0/tests/python/named_losses.py +216 -0
- libsdca-0.4.0/tests/python/native_route_cases.py +155 -0
- libsdca-0.4.0/tests/python/numpy_api.py +170 -0
- libsdca-0.4.0/tests/python/pending.py +25 -0
- libsdca-0.4.0/tests/python/probability_references.py +88 -0
- libsdca-0.4.0/tests/python/properties.py +1269 -0
- libsdca-0.4.0/tests/python/release_numerics.py +542 -0
- libsdca-0.4.0/tests/python/rule_table.py +553 -0
- libsdca-0.4.0/tests/python/storage_limits.py +16 -0
- libsdca-0.4.0/tests/python/test_boundaries.py +181 -0
- libsdca-0.4.0/tests/python/test_ce_limits.py +171 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_centered_certificate.py +9 -7
- libsdca-0.4.0/tests/python/test_certificate.py +202 -0
- libsdca-0.4.0/tests/python/test_chunked_rows_cuda.py +232 -0
- libsdca-0.4.0/tests/python/test_composed_compile.py +162 -0
- libsdca-0.4.0/tests/python/test_composed_solves.py +131 -0
- libsdca-0.4.0/tests/python/test_conformance_jax.py +20 -0
- libsdca-0.4.0/tests/python/test_conformance_native.py +17 -0
- libsdca-0.4.0/tests/python/test_conformance_torch.py +18 -0
- libsdca-0.4.0/tests/python/test_conformance_tracking.py +66 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_convergence.py +25 -20
- libsdca-0.4.0/tests/python/test_cross_interface.py +919 -0
- libsdca-0.4.0/tests/python/test_cuda.py +993 -0
- libsdca-0.4.0/tests/python/test_cuda_memory.py +48 -0
- libsdca-0.4.0/tests/python/test_distillation_adaptive.py +84 -0
- libsdca-0.4.0/tests/python/test_distillation_narrow_compile.py +69 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_distillation_offsets.py +13 -11
- libsdca-0.4.0/tests/python/test_distillation_references.py +248 -0
- libsdca-0.4.0/tests/python/test_distillation_review_cuda.py +315 -0
- libsdca-0.4.0/tests/python/test_distillation_stream_accuracy.py +167 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_distillation_two_pass.py +7 -4
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_distributed_higher.py +20 -7
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_entropy_references.py +5 -2
- libsdca-0.4.0/tests/python/test_examples.py +41 -0
- libsdca-0.4.0/tests/python/test_extension_build_lock.py +67 -0
- libsdca-0.4.0/tests/python/test_float64_extreme_reductions.py +83 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_fpenv.py +18 -6
- libsdca-0.4.0/tests/python/test_frontend_rules.py +104 -0
- libsdca-0.4.0/tests/python/test_hinge_order_native.py +54 -0
- libsdca-0.4.0/tests/python/test_hinge_order_torch.py +359 -0
- libsdca-0.4.0/tests/python/test_hinge_parity_torch.py +50 -0
- libsdca-0.4.0/tests/python/test_hinge_spread.py +148 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_integration.py +14 -17
- libsdca-0.4.0/tests/python/test_interface.py +275 -0
- libsdca-0.4.0/tests/python/test_jax_cuda_ffi.py +640 -0
- libsdca-0.4.0/tests/python/test_jax_cuda_scalars.py +278 -0
- libsdca-0.4.0/tests/python/test_jax_distillation_reduction.py +62 -0
- libsdca-0.4.0/tests/python/test_jax_extension.py +31 -0
- libsdca-0.4.0/tests/python/test_jax_gradient_buffers.py +156 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_jax_half_precision.py +65 -29
- libsdca-0.4.0/tests/python/test_jax_k_domain.py +77 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_jax_loss_dtypes.py +8 -5
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_jax_mask_gap_rounding.py +20 -0
- libsdca-0.4.0/tests/python/test_jax_multilabel_hinge_reduction.py +35 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_jax_topk_mass.py +12 -2
- libsdca-0.4.0/tests/python/test_jax_training_setups.py +61 -0
- libsdca-0.4.0/tests/python/test_jax_triton_capability.py +102 -0
- libsdca-0.4.0/tests/python/test_k1_routing.py +135 -0
- libsdca-0.4.0/tests/python/test_k_domain.py +85 -0
- libsdca-0.4.0/tests/python/test_limits.py +177 -0
- libsdca-0.4.0/tests/python/test_loss_rows.py +135 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_losses.py +21 -9
- libsdca-0.4.0/tests/python/test_masked_classes_numpy.py +64 -0
- libsdca-0.4.0/tests/python/test_module_options.py +80 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_multilabel_negative_max.py +3 -17
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_multilabel_split.py +37 -24
- libsdca-0.4.0/tests/python/test_native_route_jax.py +138 -0
- libsdca-0.4.0/tests/python/test_native_route_torch.py +312 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_objectives.py +18 -14
- libsdca-0.4.0/tests/python/test_one_check.py +105 -0
- libsdca-0.4.0/tests/python/test_optax.py +304 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_ordinary_inputs.py +35 -20
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_precision_ranges.py +60 -22
- libsdca-0.4.0/tests/python/test_probabilities_jax.py +114 -0
- libsdca-0.4.0/tests/python/test_probabilities_numpy.py +90 -0
- libsdca-0.4.0/tests/python/test_probabilities_torch.py +273 -0
- libsdca-0.4.0/tests/python/test_properties_checks.py +103 -0
- libsdca-0.4.0/tests/python/test_properties_jax.py +197 -0
- libsdca-0.4.0/tests/python/test_properties_torch.py +144 -0
- libsdca-0.4.0/tests/python/test_proximal_distillation_stream.py +105 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_proximal_subnormal.py +53 -31
- libsdca-0.4.0/tests/python/test_reuse_logits_jax.py +91 -0
- libsdca-0.4.0/tests/python/test_reuse_logits_torch.py +372 -0
- libsdca-0.4.0/tests/python/test_rule_table.py +888 -0
- libsdca-0.4.0/tests/python/test_shared_arguments.py +160 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_shrinking.py +46 -53
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_sklearn.py +154 -95
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_softmax_limits.py +44 -85
- libsdca-0.4.0/tests/python/test_source_distribution.py +23 -0
- libsdca-0.4.0/tests/python/test_stability.py +765 -0
- libsdca-0.4.0/tests/python/test_strided_rows_cuda.py +118 -0
- libsdca-0.4.0/tests/python/test_target_gradients.py +294 -0
- libsdca-0.4.0/tests/python/test_threads.py +51 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_topk_large_k.py +19 -23
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_topk_references.py +64 -83
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_topk_subnormal_mass.py +40 -53
- libsdca-0.4.0/tests/python/test_torch_k_domain.py +124 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/test_torch_references.py +83 -41
- libsdca-0.4.0/tests/python/test_torch_row_reduction.py +117 -0
- libsdca-0.4.0/tests/python/test_torch_teacher_covariance.py +180 -0
- libsdca-0.4.0/tests/python/test_torch_training_setups.py +350 -0
- libsdca-0.4.0/tests/python/test_triton_interpreted.py +224 -0
- libsdca-0.4.0/tests/python/test_triton_launch.py +363 -0
- libsdca-0.4.0/tests/python/test_work_counts.py +71 -0
- libsdca-0.4.0/tests/python/topk_rows.py +16 -0
- libsdca-0.3.0/AGENTS.md +0 -56
- libsdca-0.3.0/CHANGELOG.md +0 -77
- libsdca-0.3.0/DEPENDENCIES.md +0 -91
- libsdca-0.3.0/MANIFEST.in +0 -9
- libsdca-0.3.0/PKG-INFO +0 -205
- libsdca-0.3.0/README.md +0 -224
- libsdca-0.3.0/include/sdca/c_api.h +0 -361
- libsdca-0.3.0/include/sdca/loss.h +0 -637
- libsdca-0.3.0/include/sdca/math/blas.h +0 -298
- libsdca-0.3.0/include/sdca/math/blas_builtin.h +0 -255
- libsdca-0.3.0/include/sdca/math/cblas.h +0 -58
- libsdca-0.3.0/include/sdca/math/compensated.h +0 -126
- libsdca-0.3.0/include/sdca/math/distillation.h +0 -491
- libsdca-0.3.0/include/sdca/math/entropy.h +0 -1855
- libsdca-0.3.0/include/sdca/math/exp_rows.h +0 -382
- libsdca-0.3.0/include/sdca/math/functor.h +0 -58
- libsdca-0.3.0/include/sdca/math/lambert.h +0 -229
- libsdca-0.3.0/include/sdca/math/log_exp.h +0 -281
- libsdca-0.3.0/include/sdca/math/prox_rows.h +0 -396
- libsdca-0.3.0/include/sdca/prox/entropy.h +0 -290
- libsdca-0.3.0/include/sdca/prox/entropy_norm.h +0 -58
- libsdca-0.3.0/include/sdca/prox/knapsack_eq.h +0 -235
- libsdca-0.3.0/include/sdca/prox/knapsack_le.h +0 -108
- libsdca-0.3.0/include/sdca/prox/knapsack_le_biased.h +0 -223
- libsdca-0.3.0/include/sdca/prox/proxdef.h +0 -459
- libsdca-0.3.0/include/sdca/prox/topk_cone.h +0 -261
- libsdca-0.3.0/include/sdca/prox/topk_cone_biased.h +0 -71
- libsdca-0.3.0/include/sdca/prox/topk_entropy.h +0 -178
- libsdca-0.3.0/include/sdca/prox/topk_entropy_biased.h +0 -109
- libsdca-0.3.0/include/sdca/prox/topk_simplex.h +0 -95
- libsdca-0.3.0/include/sdca/prox/topk_simplex_biased.h +0 -100
- libsdca-0.3.0/include/sdca/prox/two_entropy.h +0 -111
- libsdca-0.3.0/include/sdca/prox/two_simplex.h +0 -394
- libsdca-0.3.0/include/sdca/prox/two_simplex_sort.h +0 -83
- libsdca-0.3.0/include/sdca/prox.h +0 -22
- libsdca-0.3.0/include/sdca/solver/eval/accumulate.h +0 -73
- libsdca-0.3.0/include/sdca/solver/eval/primal.h +0 -114
- libsdca-0.3.0/include/sdca/solver/eval/scores.h +0 -86
- libsdca-0.3.0/include/sdca/solver/objective/l2_distillation.h +0 -218
- libsdca-0.3.0/include/sdca/solver/objective/l2_entropy.h +0 -71
- libsdca-0.3.0/include/sdca/solver/objective/l2_entropy_topk.h +0 -188
- libsdca-0.3.0/include/sdca/solver/objective/l2_hinge_topk.h +0 -194
- libsdca-0.3.0/include/sdca/solver/objective/l2_multilabel_entropy.h +0 -69
- libsdca-0.3.0/include/sdca/solver/objective/l2_multilabel_hinge.h +0 -213
- libsdca-0.3.0/include/sdca/solver/objective/l2_topk_hinge.h +0 -203
- libsdca-0.3.0/include/sdca/solver/objective.h +0 -103
- libsdca-0.3.0/include/sdca/solver/reporting.h +0 -89
- libsdca-0.3.0/include/sdca/solver/screening.h +0 -163
- libsdca-0.3.0/include/sdca/utility/logging.cpp +0 -15
- libsdca-0.3.0/include/sdca/utility/logging.h +0 -86
- libsdca-0.3.0/include/sdca/utility/scratch.h +0 -76
- libsdca-0.3.0/python/JAX.md +0 -80
- libsdca-0.3.0/python/README.md +0 -142
- libsdca-0.3.0/python/TORCH.md +0 -195
- libsdca-0.3.0/python/libsdca/__init__.py +0 -142
- libsdca-0.3.0/python/libsdca/_core.py +0 -1884
- libsdca-0.3.0/python/libsdca/_cpu.py +0 -1110
- libsdca-0.3.0/python/libsdca/_cpu_entropy.py +0 -146
- libsdca-0.3.0/python/libsdca/_cross_entropy.py +0 -650
- libsdca-0.3.0/python/libsdca/_cuda_launch.py +0 -235
- libsdca-0.3.0/python/libsdca/_entropy.py +0 -268
- libsdca-0.3.0/python/libsdca/_extensions.py +0 -315
- libsdca-0.3.0/python/libsdca/_first_order.py +0 -50
- libsdca-0.3.0/python/libsdca/_hinge.py +0 -98
- libsdca-0.3.0/python/libsdca/_jax_ffi.cpp +0 -253
- libsdca-0.3.0/python/libsdca/_jax_ffi.py +0 -221
- libsdca-0.3.0/python/libsdca/_jax_losses.py +0 -1235
- libsdca-0.3.0/python/libsdca/_linear_cross_entropy.py +0 -1014
- libsdca-0.3.0/python/libsdca/_linear_full_range.py +0 -81
- libsdca-0.3.0/python/libsdca/_multilabel.py +0 -188
- libsdca-0.3.0/python/libsdca/_ops.py +0 -565
- libsdca-0.3.0/python/libsdca/_tensor_losses.py +0 -520
- libsdca-0.3.0/python/libsdca/_tensor_prox.py +0 -446
- libsdca-0.3.0/python/libsdca/_topk.py +0 -104
- libsdca-0.3.0/python/libsdca/_torch_ce.h +0 -832
- libsdca-0.3.0/python/libsdca/_torch_cuda.h +0 -771
- libsdca-0.3.0/python/libsdca/_torch_distill.h +0 -1627
- libsdca-0.3.0/python/libsdca/_torch_distributed.py +0 -76
- libsdca-0.3.0/python/libsdca/_torch_entropy.cpp +0 -427
- libsdca-0.3.0/python/libsdca/_torch_lanes.h +0 -1123
- libsdca-0.3.0/python/libsdca/_torch_prox.h +0 -1157
- libsdca-0.3.0/python/libsdca/_torch_topk_hinge.h +0 -1822
- libsdca-0.3.0/python/libsdca/_triton_distillation.py +0 -1715
- libsdca-0.3.0/python/libsdca/_triton_entropy.py +0 -601
- libsdca-0.3.0/python/libsdca/_triton_hinge.py +0 -363
- libsdca-0.3.0/python/libsdca/_triton_linear.py +0 -30
- libsdca-0.3.0/python/libsdca/_triton_multilabel.py +0 -1101
- libsdca-0.3.0/python/libsdca/_triton_prox.py +0 -866
- libsdca-0.3.0/python/libsdca/_triton_reduce.py +0 -187
- libsdca-0.3.0/python/libsdca/_triton_topk.py +0 -1070
- libsdca-0.3.0/python/libsdca/_triton_weighted_entropy.py +0 -388
- libsdca-0.3.0/python/libsdca/jax.py +0 -1335
- libsdca-0.3.0/python/libsdca/sklearn.py +0 -205
- libsdca-0.3.0/python/libsdca/torch.py +0 -1978
- libsdca-0.3.0/python/libsdca.egg-info/PKG-INFO +0 -205
- libsdca-0.3.0/python/libsdca.egg-info/SOURCES.txt +0 -222
- libsdca-0.3.0/python/libsdca.egg-info/requires.txt +0 -36
- libsdca-0.3.0/sdca_build.py +0 -63
- libsdca-0.3.0/setup.py +0 -73
- libsdca-0.3.0/src/c_api.cpp +0 -1241
- libsdca-0.3.0/src/tensor_losses.h +0 -1339
- libsdca-0.3.0/tests/python/common_inputs.py +0 -760
- libsdca-0.3.0/tests/python/loss_references.py +0 -200
- libsdca-0.3.0/tests/python/test_abi_compatibility.py +0 -106
- libsdca-0.3.0/tests/python/test_accuracy_claims.py +0 -43
- libsdca-0.3.0/tests/python/test_api_contracts.py +0 -468
- libsdca-0.3.0/tests/python/test_backend_routing.py +0 -189
- libsdca-0.3.0/tests/python/test_build_config.py +0 -261
- libsdca-0.3.0/tests/python/test_certificate.py +0 -361
- libsdca-0.3.0/tests/python/test_cpu_extension.py +0 -488
- libsdca-0.3.0/tests/python/test_cpu_memory.py +0 -86
- libsdca-0.3.0/tests/python/test_cpu_process_state.py +0 -48
- libsdca-0.3.0/tests/python/test_cross_entropy.py +0 -460
- libsdca-0.3.0/tests/python/test_cuda.py +0 -284
- libsdca-0.3.0/tests/python/test_cuda_float64_entropy.py +0 -510
- libsdca-0.3.0/tests/python/test_cuda_launch.py +0 -775
- libsdca-0.3.0/tests/python/test_distillation.py +0 -480
- libsdca-0.3.0/tests/python/test_distillation_bounded_expm1.py +0 -120
- libsdca-0.3.0/tests/python/test_distillation_references.py +0 -237
- libsdca-0.3.0/tests/python/test_distillation_stream_accuracy.py +0 -58
- libsdca-0.3.0/tests/python/test_distillation_value.py +0 -49
- libsdca-0.3.0/tests/python/test_distributed.py +0 -312
- libsdca-0.3.0/tests/python/test_entropy_higher_precision.py +0 -79
- libsdca-0.3.0/tests/python/test_float32_zero_gaps.py +0 -112
- libsdca-0.3.0/tests/python/test_float64_zero_gaps.py +0 -79
- libsdca-0.3.0/tests/python/test_fused_entropy.py +0 -347
- libsdca-0.3.0/tests/python/test_half_gradient_rounding.py +0 -319
- libsdca-0.3.0/tests/python/test_half_precision.py +0 -333
- libsdca-0.3.0/tests/python/test_half_zero_gaps.py +0 -96
- libsdca-0.3.0/tests/python/test_indexed_losses.py +0 -223
- libsdca-0.3.0/tests/python/test_inplace_gradient.py +0 -310
- libsdca-0.3.0/tests/python/test_interface.py +0 -282
- libsdca-0.3.0/tests/python/test_jax.py +0 -1005
- libsdca-0.3.0/tests/python/test_jax_backend.py +0 -1032
- libsdca-0.3.0/tests/python/test_jax_distillation_references.py +0 -134
- libsdca-0.3.0/tests/python/test_jax_ffi.py +0 -269
- libsdca-0.3.0/tests/python/test_jax_k_domain.py +0 -73
- libsdca-0.3.0/tests/python/test_k_domain.py +0 -78
- libsdca-0.3.0/tests/python/test_kernel_limits.py +0 -156
- libsdca-0.3.0/tests/python/test_linear_cross_entropy.py +0 -526
- libsdca-0.3.0/tests/python/test_linear_cuda_accumulation.py +0 -210
- libsdca-0.3.0/tests/python/test_linear_full_range.py +0 -127
- libsdca-0.3.0/tests/python/test_loss_dtypes.py +0 -108
- libsdca-0.3.0/tests/python/test_module_options.py +0 -31
- libsdca-0.3.0/tests/python/test_multilabel_gap_rounding.py +0 -75
- libsdca-0.3.0/tests/python/test_multilabel_kernels.py +0 -581
- libsdca-0.3.0/tests/python/test_multilabel_online.py +0 -85
- libsdca-0.3.0/tests/python/test_multilabel_well_fit.py +0 -78
- libsdca-0.3.0/tests/python/test_native_tensor_losses.py +0 -776
- libsdca-0.3.0/tests/python/test_projection_termination.py +0 -267
- libsdca-0.3.0/tests/python/test_proximal_extremes.py +0 -187
- libsdca-0.3.0/tests/python/test_stress.py +0 -289
- libsdca-0.3.0/tests/python/test_stress_torch.py +0 -106
- libsdca-0.3.0/tests/python/test_tensor_losses.py +0 -345
- libsdca-0.3.0/tests/python/test_tensor_prox.py +0 -438
- libsdca-0.3.0/tests/python/test_threads.py +0 -239
- libsdca-0.3.0/tests/python/test_topk_kernels.py +0 -808
- libsdca-0.3.0/tests/python/test_torch.py +0 -646
- libsdca-0.3.0/tests/python/test_torch_common_inputs.py +0 -297
- libsdca-0.3.0/tests/python/test_torch_compile.py +0 -233
- libsdca-0.3.0/tests/python/test_torch_cpu_paths.py +0 -396
- libsdca-0.3.0/tests/python/test_torch_func.py +0 -109
- libsdca-0.3.0/tests/python/test_torch_k_domain.py +0 -122
- libsdca-0.3.0/tests/python/test_triton_devices.py +0 -164
- libsdca-0.3.0/tests/python/test_weighted_cuda.py +0 -586
- libsdca-0.3.0/tests/python/test_wide_float32_prox.py +0 -163
- libsdca-0.3.0/tests/python/test_wide_float64_sums.py +0 -109
- libsdca-0.3.0/tests/python/topk_rows.py +0 -32
- {libsdca-0.3.0 → libsdca-0.4.0}/LICENSE +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/utility/stopwatch.h +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/include/sdca/utility/types.h +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/python/libsdca/py.typed +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/python/libsdca.egg-info/dependency_links.txt +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/python/libsdca.egg-info/top_level.txt +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/setup.cfg +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/child_process.py +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/interpreter.py +0 -0
- {libsdca-0.3.0 → libsdca-0.4.0}/tests/python/mpmath_types.py +0 -0
libsdca-0.4.0/AGENTS.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Using `libsdca` (Guide for AI Coding Assistants)
|
|
2
|
+
|
|
3
|
+
A short reference for AI coding assistants that integrate `libsdca` into user code. Usage
|
|
4
|
+
examples are in the [README](README.md#quick-start) and the linked guides; loss names,
|
|
5
|
+
options, defaults and errors are shared across languages and defined in
|
|
6
|
+
[docs/API.md](docs/API.md).
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install libsdca # NumPy solver and losses (numpy>=1.23)
|
|
12
|
+
pip install 'libsdca[torch]' # PyTorch losses (torch>=2.1)
|
|
13
|
+
pip install 'libsdca[jax]' # JAX CPU losses (jax>=0.4.35)
|
|
14
|
+
pip install 'libsdca[jax-cuda]' # JAX CUDA losses (Linux, NVIDIA driver 580+; Python 3.11+, C++17 compiler or jax-triton 0.5)
|
|
15
|
+
pip install 'libsdca[sklearn]' # SDCAClassifier (scikit-learn>=1.6)
|
|
16
|
+
cargo add libsdca # Rust crate (Rust>=1.74 and a C++11 compiler)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- **Wheels:** Linux `x86_64` (`manylinux_2_28`) and macOS `arm64` (11+). Other platforms
|
|
20
|
+
build the sdist with a C++11 compiler and link a system CBLAS when one is found.
|
|
21
|
+
- **First-use builds:** PyTorch and JAX compile their CPU kernels on first use (a C++17
|
|
22
|
+
compiler and Python headers: `build-essential python3-dev` on Debian/Ubuntu,
|
|
23
|
+
`xcode-select --install` on macOS). Without them, CPU calls run the same kernels in the
|
|
24
|
+
prebuilt native library and PyTorch CUDA calls launch them through Python (far more
|
|
25
|
+
overhead per call), each with a one-time warning ([TORCH.md](docs/TORCH.md#build-tools)).
|
|
26
|
+
- **Check the selected path:** `libsdca.torch.explain_backend(cross_entropy, logits, target)`
|
|
27
|
+
returns `(backend, reason)` for the call `cross_entropy(logits, target)`;
|
|
28
|
+
`libsdca.jax.explain_backend` does the same for JAX.
|
|
29
|
+
|
|
30
|
+
### Building from source
|
|
31
|
+
|
|
32
|
+
| Interface | Build | Guide |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| Python | `pip install .` from a checkout; BLAS through `SDCA_BLAS_BACKEND=AUTO\|BUILTIN\|EXTERNAL` or `SDCA_BLAS="-lopenblas"` | [DEPENDENCIES.md](DEPENDENCIES.md#python) |
|
|
35
|
+
| C++ (header-only) | `cmake -S . -B build && cmake --build build --target install`, then `find_package(libsdca CONFIG)` and `libsdca::libsdca` | [CPP.md](docs/CPP.md) |
|
|
36
|
+
| C | the same with `-DSDCA_BUILD_C_API=ON`; link `libsdca::sdca_c` | [C.md](docs/C.md) |
|
|
37
|
+
| Rust | `cargo build`; `build.rs` compiles the C ABI with `CXX` and the same BLAS rule | [RUST.md](docs/RUST.md#building) |
|
|
38
|
+
|
|
39
|
+
Without CMake, compile C++ with `-DBLAS_BUILTIN -pthread -fno-fast-math -ffp-contract=off`
|
|
40
|
+
(or `-DBLAS_DEFAULT_LOCAL_HEADER` and a CBLAS such as `-lopenblas`); BLAS selection is
|
|
41
|
+
described in [API.md](docs/API.md#blas).
|
|
42
|
+
|
|
43
|
+
## Which API to use
|
|
44
|
+
|
|
45
|
+
| User goal | API | Guide |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Replace `torch.nn.CrossEntropyLoss` (labels or probabilities, weights, label smoothing) | `libsdca.torch.CrossEntropyLoss`, `cross_entropy` | [TORCH.md](docs/TORCH.md#replace-pytorch-cross-entropy) |
|
|
48
|
+
| Large-vocabulary head + cross-entropy without `(N, V)` logits | `LinearCrossEntropyLoss`, `linear_cross_entropy` | [TORCH.md](docs/TORCH.md#linear-layer-and-cross-entropy-without-the-logits) |
|
|
49
|
+
| Top-*k*, hinge and multilabel PyTorch losses | `TopKCrossEntropyLoss`, `TopKHingeLoss`, `MulticlassHingeLoss`, `MultilabelHingeLoss`, `MultilabelCrossEntropyLoss` | [TORCH.md](docs/TORCH.md) |
|
|
50
|
+
| Logit distillation in PyTorch | `DistillationLoss`, `distillation_loss` | [TORCH.md](docs/TORCH.md#teacher-logits-and-distillation) |
|
|
51
|
+
| Losses in JAX (`jit`, `grad`, `vmap`) | `libsdca.jax` | [JAX.md](docs/JAX.md) |
|
|
52
|
+
| Replace optax's softmax cross-entropies or multiclass hinge (per-example, optax signatures) | `libsdca.optax` | [JAX.md](docs/JAX.md#optax-losses) |
|
|
53
|
+
| Linear or kernel SVM / softmax classifier (scikit-learn) | `libsdca.sklearn.SDCAClassifier` | [PYTHON.md](docs/PYTHON.md#classifier) |
|
|
54
|
+
| Same, with duality-gap history and warm starts | `libsdca.fit(X, y, loss)` with loss objects such as `libsdca.TopKHinge(k=2)` | [PYTHON.md](docs/PYTHON.md#training) |
|
|
55
|
+
| Losses and gradients on NumPy arrays | `libsdca.loss_and_grad` | [PYTHON.md](docs/PYTHON.md#losses-and-gradients) |
|
|
56
|
+
| Rust, C++, C | crate `libsdca`, headers `sdca/*.h`, library `libsdca_c` | [Rust](docs/RUST.md), [C++](docs/CPP.md), [C](docs/C.md) |
|
|
57
|
+
|
|
58
|
+
## Pitfalls
|
|
59
|
+
|
|
60
|
+
- **Class axis:** every PyTorch loss takes classes on `dim=1` (`dim=0` for 1-D logits),
|
|
61
|
+
like `F.cross_entropy`; JAX losses take them on `axis=-1`.
|
|
62
|
+
- **Loss parameters** belong to their loss: `TopKHingeLoss(k=2)`,
|
|
63
|
+
`libsdca.TopKHinge(k=2)`; passing a parameter another loss uses is an error, and top-*k*
|
|
64
|
+
losses have no default `k`. PyTorch/JAX hyperparameters are keyword-only; NumPy loss
|
|
65
|
+
objects also accept positional arguments.
|
|
66
|
+
- **Backends:** `"auto"` (default) and `"kernel"` run libsdca's kernels and raise
|
|
67
|
+
`NotImplementedError` naming `backend="composed"` where no kernel computes a call (another
|
|
68
|
+
device, a CUDA shape beyond the kernels); `"composed"` uses framework operations.
|
|
69
|
+
- **Distillation** takes raw logits for both inputs and applies no $T^2$ factor
|
|
70
|
+
([TORCH.md](docs/TORCH.md#teacher-logits-and-distillation)).
|
|
71
|
+
- **Memory:** a CPU sum or mean computes its gradient in the forward pass (peak: logits plus
|
|
72
|
+
gradient). Other PyTorch backward passes (CUDA, `reduction="none"`, scaled upstreams)
|
|
73
|
+
write the gradient over the logits when nothing else references them, and warn once when
|
|
74
|
+
something does (`reuse_logits=False` turns it off; [TORCH.md](docs/TORCH.md#memory)).
|
|
75
|
+
- **Derivatives:** the kernels are first order; pass `backend="composed"` for higher
|
|
76
|
+
derivatives or forward mode ([TORCH.md](docs/TORCH.md#compilation-and-transformations)).
|
|
77
|
+
- **Solver objective:** $\frac12\Vert W \Vert_2^2 + C\sum_i \ell_i$ with no intercept;
|
|
78
|
+
standardize features; for $d \gg n$ pass a Gram matrix
|
|
79
|
+
([PYTHON.md](docs/PYTHON.md#training), [API.md](docs/API.md#options)).
|
|
80
|
+
- **Convergence:** only `status == "solved"` guarantees the duality gap
|
|
81
|
+
([API.md](docs/API.md#results)).
|
|
82
|
+
- **Precision:** `precision=None` follows the storage dtype (16-bit inputs use `float32`
|
|
83
|
+
work); pass `precision="float64"` for double work ([API.md](docs/API.md#precision),
|
|
84
|
+
[known limits](docs/API.md#known-limits)).
|
|
85
|
+
|
|
86
|
+
## Developing `libsdca`
|
|
87
|
+
|
|
88
|
+
Building, testing and the repository layout are in [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.0 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
Changes since 0.3.0. Every interface has a new API with one set of loss names, options and
|
|
6
|
+
defaults ([API.md](docs/API.md)). The [technical report](https://mlapin.github.io/libsdca/report/)
|
|
7
|
+
gives the benchmarks and numerical comparisons.
|
|
8
|
+
|
|
9
|
+
### Upgrading from 0.3.0
|
|
10
|
+
|
|
11
|
+
- **Names and parameters:** rename the losses and pass their parameters as below (top-*k*
|
|
12
|
+
losses need `k`; PyTorch and JAX take hyperparameters by keyword).
|
|
13
|
+
- **`float32` data works in `float32`:** NumPy losses and gradients of `float32` inputs
|
|
14
|
+
differ from 0.3.0's by up to about half a `float32` ulp, and fits of `float32` data can
|
|
15
|
+
stop at a larger gap. `precision="float64"` reproduces 0.3.0's double work
|
|
16
|
+
([API.md](docs/API.md#precision)).
|
|
17
|
+
- **Invalid values no longer raise:** `NaN` or `+inf` logits and invalid rows of masked
|
|
18
|
+
classes give `NaN` rows (NumPy warns once per call; `check_rows=True` raises), and a logit
|
|
19
|
+
of `-inf` removes its class. Labels out of range raise PyTorch's
|
|
20
|
+
`Target 7 is out of bounds.` in NumPy, Rust, C, C++ and synchronous CPU calls; CUDA and
|
|
21
|
+
traced composed calls produce `NaN` rows.
|
|
22
|
+
- **Distillation teachers get gradients:** a teacher that requires gradients (PyTorch) or is
|
|
23
|
+
differentiated (JAX) now receives PyTorch's gradient; detach it to keep 0.3.0's behaviour.
|
|
24
|
+
- **Linux wheels need `scipy-openblas32`:** they link its OpenBLAS, and `pip` installs it
|
|
25
|
+
with them ([API.md](docs/API.md#blas)).
|
|
26
|
+
- **Zeros and empty batches:** gradient entries that were `-0.0` are `+0.0`, and NumPy batches
|
|
27
|
+
of zero rows return empty arrays (0.3.0 raised `ValueError`).
|
|
28
|
+
- **Error texts:** every interface uses one text per error, PyTorch's where PyTorch has one.
|
|
29
|
+
- **Memory:** PyTorch backward writes the gradient over logits that nothing else references;
|
|
30
|
+
code that keeps a reference to the logits gets a warning and a new gradient
|
|
31
|
+
([TORCH.md](docs/TORCH.md#memory)).
|
|
32
|
+
|
|
33
|
+
### Breaking changes
|
|
34
|
+
|
|
35
|
+
- **One loss vocabulary:** every interface names the losses `cross_entropy`,
|
|
36
|
+
`topk_cross_entropy`, `multiclass_hinge`, `topk_hinge` (`variant="beta"`, the default, or
|
|
37
|
+
`"alpha"`), `multilabel_hinge`, `multilabel_cross_entropy`, `proximal_cross_entropy`,
|
|
38
|
+
`distillation` and `proximal_distillation`. Each takes only its own parameters (`k`,
|
|
39
|
+
`variant`, `gamma`, `temperature`): a parameter of another loss is a `TypeError`. String
|
|
40
|
+
aliases (`softmax`, `fp32`, ...) and the Python and Rust names `topk_hinge_alpha` and
|
|
41
|
+
`topk_hinge_beta` are gone; the C kinds, C++ kinds and C++ objectives keep them.
|
|
42
|
+
- **Top-*k* losses need `k`:** `topk_cross_entropy` and `topk_hinge` have no default `k`
|
|
43
|
+
(0.3.0 used `k = 1`); omitting it is a `TypeError` in Python, and `k = 0` is an invalid
|
|
44
|
+
argument in C and C++ (Rust's `"topk_hinge".parse()` still gives `k = 1`).
|
|
45
|
+
- **`gamma` is the step of the proximal losses:** `proximal_cross_entropy` and
|
|
46
|
+
`proximal_distillation` take their Moreau step as `gamma` (default `1`; required in C++'s `sdca::loss_parameters`)
|
|
47
|
+
instead of `alpha`.
|
|
48
|
+
- **NumPy:** losses are objects: `fit(X, y, libsdca.TopKHinge(k=2))`,
|
|
49
|
+
`loss_and_grad(logits, target, loss)` and `coordinate_update(logits, target, loss)`.
|
|
50
|
+
`libsdca.Kernel(K)` marks a Gram matrix and `libsdca.Probabilities(P)` probability targets.
|
|
51
|
+
`Solver`, `distillation_loss_and_grad` and `proximal_distillation_loss_and_grad` are gone,
|
|
52
|
+
and `import libsdca` no longer exports the PyTorch losses.
|
|
53
|
+
- **scikit-learn:** `SDCAClassifier(loss, *, C, k, variant, gamma, tol, max_iter, eval_epoch,
|
|
54
|
+
shrinking, kernel, precision, n_jobs, random_state, warm_start)`: `objective` is now
|
|
55
|
+
`loss`, `max_epoch` is `max_iter`, and `recompute_primal` and `projection_precision` are
|
|
56
|
+
gone.
|
|
57
|
+
- **PyTorch and JAX:** one function (and in PyTorch one module) per loss, with keyword-only
|
|
58
|
+
hyperparameters. `SDCALoss`, `sdca_loss`, `TopKHingeAlphaLoss` and `TopKHingeBetaLoss` are
|
|
59
|
+
gone: use `TopKHingeLoss(k=2, variant="alpha")`.
|
|
60
|
+
- **Classes on `dim=1` in every PyTorch loss** (`dim=0` for 1-D logits), as in
|
|
61
|
+
`F.cross_entropy`; the losses other than `cross_entropy` defaulted to `dim=-1`. JAX keeps
|
|
62
|
+
`axis=-1`.
|
|
63
|
+
- **Backends `"auto"`, `"kernel"` and `"composed"`:** `"auto"` (the default) and `"kernel"`
|
|
64
|
+
run libsdca's kernels and raise `NotImplementedError` naming `backend="composed"` where no
|
|
65
|
+
kernel computes a call, instead of falling back to tensor operations. `"composed"` runs
|
|
66
|
+
framework operations on any device. The `"native"`, `"torch"` and `"jax"` backends are
|
|
67
|
+
gone; `explain_backend` reports the path of a call in both frameworks.
|
|
68
|
+
- **Kernel derivatives are first order:** differentiating a kernel gradient again, or forward
|
|
69
|
+
mode, raises; `backend="composed"` supports them
|
|
70
|
+
([TORCH.md](docs/TORCH.md#compilation-and-transformations)).
|
|
71
|
+
- **Invalid numerical inputs give `NaN`:** in PyTorch and JAX, `NaN` or `+inf` logits,
|
|
72
|
+
invalid class weights and invalid rows of masked classes give `NaN` rows, with no host
|
|
73
|
+
synchronization. NumPy's `loss_and_grad` writes `NaN` rows and issues one
|
|
74
|
+
`InvalidRowsWarning` per call (`check_rows=True` raises).
|
|
75
|
+
- **`float32` work by default:** NumPy, scikit-learn, Rust and the C++ loss helpers work in
|
|
76
|
+
`float32` for `float32` inputs; `precision="float64"` selects double work.
|
|
77
|
+
- **One array layout:** NumPy, Rust, C and C++ share row-major features `(n, d)`, weights
|
|
78
|
+
`(m, d)` and duals `(n, m)` ([API.md](docs/API.md#array-layouts)). NumPy `Model.weights`
|
|
79
|
+
and `center` were Fortran-ordered `(d, m)`.
|
|
80
|
+
- **Training options:** `eval_epoch = 0` evaluates only at the end, and `seed` sets the
|
|
81
|
+
order of the examples. The statuses are `solved`, `no_progress`, `max_epoch` and `failed`
|
|
82
|
+
(`none` and `solving` are gone).
|
|
83
|
+
- **C ABI 7** (0.3.0: 5): `sdca_loss_evaluate`, `sdca_loss_rows`, `sdca_dual_update`,
|
|
84
|
+
`sdca_model_fit`, `sdca_model_scores`, `sdca_history_rows`, `sdca_max_extent` and
|
|
85
|
+
`sdca_blas_backend` replace the 0.3.0 entry points, with the structs `sdca_loss`
|
|
86
|
+
(`SDCA_LOSS_INIT(kind)`), `sdca_execution`, `sdca_targets`, `sdca_fit_options` and
|
|
87
|
+
`sdca_input`. `sdca_loss_evaluate` returns `SDCA_INVALID_ROWS` (`1`) when it writes `NaN`
|
|
88
|
+
rows ([C.md](docs/C.md)).
|
|
89
|
+
- **Rust:** `Loss` variants carry their parameters (`Loss::topk_hinge(2)`); a `Solver`
|
|
90
|
+
builder trains and takes coordinate steps, and `Settings` hold the precision, threads and
|
|
91
|
+
`check_rows`. `Loss::loss_and_grad` also returns a `#[must_use]` `LossReport`
|
|
92
|
+
([RUST.md](docs/RUST.md)).
|
|
93
|
+
- **C++:** the objective factories use the shared names and take `gamma`; the loss kinds are
|
|
94
|
+
`sdca::kernel::Kind`, and `sdca::loss_kind`, `sdca::loss_name` and `sdca/loss_kind.h` are
|
|
95
|
+
gone. Labels are 0-based, `make_input_feature(n, d, X)` and
|
|
96
|
+
`make_input_kernel(n, n_train, K)` take the number of examples first, and the headers need
|
|
97
|
+
no `logging.cpp` ([CPP.md](docs/CPP.md)).
|
|
98
|
+
|
|
99
|
+
### New features
|
|
100
|
+
|
|
101
|
+
- **Class weights, label smoothing and `ignore_index` everywhere:** NumPy, Rust and the C ABI
|
|
102
|
+
take PyTorch's `cross_entropy` options, for the same losses as PyTorch and JAX
|
|
103
|
+
([API.md](docs/API.md#loss-evaluation-options)).
|
|
104
|
+
- **CPU losses without build tools:** where the PyTorch or JAX CPU extension cannot be built,
|
|
105
|
+
CPU calls run the same kernels in the prebuilt native library after one `RuntimeWarning`
|
|
106
|
+
([TORCH.md](docs/TORCH.md#build-tools), [JAX.md](docs/JAX.md#build-tools)).
|
|
107
|
+
- **Probability targets for `cross_entropy`** in every interface, with class weights and label
|
|
108
|
+
smoothing as in PyTorch, and PyTorch's gradient for targets that require one.
|
|
109
|
+
- **PyTorch cross-entropy parity:** `CrossEntropyLoss` and `cross_entropy` take label
|
|
110
|
+
smoothing, probability targets and labels of any integer dtype; `LinearCrossEntropyLoss`
|
|
111
|
+
takes `class_weight`, label smoothing and probability targets; the other single-label
|
|
112
|
+
losses take `weight` and `ignore_index`. Every PyTorch loss works under `torch.func`.
|
|
113
|
+
- **Masked classes:** a score of `-inf` masks its class in every loss, interface and backend
|
|
114
|
+
([API.md](docs/API.md#masked-classes)).
|
|
115
|
+
- **Mean subgradient at kinks:** at ties of the nonsmooth hinges the gradient splits evenly
|
|
116
|
+
among the tied classes, as optax and `torch.amax` do; rows without ties are unchanged
|
|
117
|
+
([API.md](docs/API.md#loss-definitions)).
|
|
118
|
+
- **`reuse_logits`** (PyTorch, default `True`): an eager backward writes the gradient over
|
|
119
|
+
logits that nothing else references, and warns once when something does
|
|
120
|
+
([TORCH.md](docs/TORCH.md#memory)).
|
|
121
|
+
- **`libsdca.optax`:** optax's `softmax_cross_entropy_with_integer_labels`,
|
|
122
|
+
`softmax_cross_entropy`, `safe_softmax_cross_entropy` and `multiclass_hinge_loss` with
|
|
123
|
+
their signatures, on the libsdca kernels ([JAX.md](docs/JAX.md#optax-losses)).
|
|
124
|
+
- **JAX on CUDA:** `libsdca.jax` runs the same fused Triton kernels as PyTorch for every loss.
|
|
125
|
+
- **Composed losses:** `backend="composed"` compiles as one graph under `torch.compile` and
|
|
126
|
+
avoids softmax collapse as the kernels do.
|
|
127
|
+
- **Batch scores:** `sdca_model_scores` (C), `sdca::batch_scores` (C++) and Rust's
|
|
128
|
+
`Model::decision_function` score a batch with one BLAS `gemm`.
|
|
129
|
+
- **NumPy:** `fit` takes `num_threads` and `seed`.
|
|
130
|
+
|
|
131
|
+
### Behaviour changes
|
|
132
|
+
|
|
133
|
+
- **Labels out of range are errors, as in PyTorch** in NumPy, Rust, C and C++
|
|
134
|
+
(`Target 7 is out of bounds.`).
|
|
135
|
+
- **Probability targets of a loss evaluation are taken as given,** as by PyTorch's
|
|
136
|
+
`cross_entropy` (training still requires rows on the simplex).
|
|
137
|
+
- **One BLAS rule for every build:** `pip install`, the Rust crate and CMake link the first
|
|
138
|
+
system CBLAS that links (Accelerate, OpenBLAS, CBLAS, BLAS), else the built-in products with
|
|
139
|
+
a warning; `SDCA_BLAS` and `SDCA_BLAS_BACKEND` override it ([API.md](docs/API.md#blas)).
|
|
140
|
+
- **One set of CPU kernels:** PyTorch, JAX, NumPy, Rust, C and C++ share the same header-only
|
|
141
|
+
kernels; results differ from 0.3.0 in the last bits.
|
|
142
|
+
- **Subnormals are kept:** the CPU kernels clear flush-to-zero around their calls, and their
|
|
143
|
+
exponentials reach the subnormal range.
|
|
144
|
+
- **Reductions stay finite:** a `mean` of finite rows whose totals leave the range stays
|
|
145
|
+
finite in PyTorch and JAX.
|
|
146
|
+
- **Distillation** forms its gradient from the log-ratio of student and teacher logits
|
|
147
|
+
(Barron et al., 2026): equal logits give an exact zero gradient.
|
|
148
|
+
- **First-use builds** are cached in `SDCA_CACHE_DIR`; a failed build is skipped for 24 hours.
|
|
149
|
+
JAX-only installs no longer need PyTorch.
|
|
150
|
+
- **NumPy and device tensors:** the NumPy API copies CUDA tensors to the host and warns once,
|
|
151
|
+
pointing to `libsdca.torch`.
|
|
152
|
+
|
|
153
|
+
### Performance
|
|
154
|
+
|
|
155
|
+
- **Run-time instruction sets:** the CPU kernels compile scalar, AVX2 and AVX-512 code in
|
|
156
|
+
one translation unit and choose at run time (NEON on arm64); `SDCA_CPU_CAPABILITY` lowers
|
|
157
|
+
the choice ([API.md](docs/API.md#environment-variables)).
|
|
158
|
+
- **Threads:** loss evaluations split their rows by an estimate of their work
|
|
159
|
+
([API.md](docs/API.md#threads)).
|
|
160
|
+
- **One CPU kernel pass per training step:** a CPU sum or mean whose logits need a gradient
|
|
161
|
+
computes values and gradient in one pass.
|
|
162
|
+
- **CUDA:** fused cross-entropy, distillation and linear cross-entropy kernels with
|
|
163
|
+
specialized narrow and medium row paths, and no copies of leaf or referenced logits.
|
|
164
|
+
|
|
165
|
+
### Removals
|
|
166
|
+
|
|
167
|
+
- **`sdca/prox.h`:** `prox_two_simplex_sort`, `thresholds_two_simplex_sort` and undocumented
|
|
168
|
+
internals are removed; `sdca::prox(t, first, last)` is documented
|
|
169
|
+
([CPP.md](docs/CPP.md#projections-and-proximal-operators)).
|
|
170
|
+
- **BLAS options (C++):** `BLAS_MKL`, `BLAS_ACCELERATE`, `BLAS_DEFAULT`, `USE_ILP64`,
|
|
171
|
+
`USE_SEQUENTIAL` and `cmake/FindMKL.cmake` are gone (link MKL with `SDCA_BLAS=-lmkl_rt`).
|
|
172
|
+
- **MATLAB and Octave:** the MEX gateways, `docs/MATLAB.md` and `SDCA_BUILD_MATLAB` are gone.
|
|
173
|
+
- **`projection_precision`:** gone from every interface.
|
|
174
|
+
- **`SDCA_CUDA_LAUNCHER`:** gone; Triton launches the CUDA kernels.
|
|
175
|
+
|
|
176
|
+
## 0.3.0 (2026-11-09)
|
|
177
|
+
|
|
178
|
+
### Highlights
|
|
179
|
+
|
|
180
|
+
- **Unified interfaces:** Python package (`fit`, `loss_and_grad`, `coordinate_update`),
|
|
181
|
+
scikit-learn estimator (`SDCAClassifier`), PyTorch modules and functions, JAX loss
|
|
182
|
+
functions, Rust crate, C ABI (`include/sdca/c_api.h`) and C++11 headers sharing one set
|
|
183
|
+
of objective, option and status names ([API.md](docs/API.md)).
|
|
184
|
+
- **Numerical stability:** Losses and gradients preserve tiny probability tails down to the
|
|
185
|
+
subnormal limit (avoiding softmax collapse), and distillation gradients are exact zero at
|
|
186
|
+
equal logits ([known limits](docs/API.md#known-limits)).
|
|
187
|
+
- **Fused CUDA and CPU kernels:** On an A100 (`8192 × 32000` and `8192 × 128256`),
|
|
188
|
+
cross-entropy takes `0.93–0.98×` `torch.compile` time (`0.33–0.41×` eager), top-5
|
|
189
|
+
cross-entropy `0.23–0.26×`, and distillation `0.62–0.81×`.
|
|
190
|
+
- **Duality-gap guarantee:** `status == "solved"` requires the duality gap of the returned
|
|
191
|
+
weights and the feasible projection of the returned duals, evaluated in `double` with a
|
|
192
|
+
first-order rounding estimate, to meet
|
|
193
|
+
`tol` ([API.md](docs/API.md#results)).
|
|
194
|
+
|
|
195
|
+
### Interfaces and losses
|
|
196
|
+
|
|
197
|
+
- **PyTorch (`libsdca`, `libsdca.torch`):** `CrossEntropyLoss` (drop-in for
|
|
198
|
+
`torch.nn.CrossEntropyLoss`, except integer class labels only and no label smoothing), `TopKCrossEntropyLoss`, `MulticlassHingeLoss`,
|
|
199
|
+
`TopKHingeLoss` ($\alpha$ and $\beta$), `MultilabelCrossEntropyLoss`,
|
|
200
|
+
`MultilabelHingeLoss`, `ProximalCrossEntropyLoss`, `DistillationLoss`,
|
|
201
|
+
`ProximalDistillationLoss`, `SDCALoss`, and `LinearCrossEntropyLoss` (chunked linear head
|
|
202
|
+
+ cross-entropy without materializing `(N, V)` logits) across `float16`, `bfloat16`,
|
|
203
|
+
`float32` and `float64` on CPU and CUDA, with `torch.compile(fullgraph=True)` and
|
|
204
|
+
`DTensor` support ([TORCH.md](docs/TORCH.md)).
|
|
205
|
+
- **JAX (`libsdca.jax`):** Classification and distillation losses for `jit`, `grad` and
|
|
206
|
+
`vmap`, with zero-copy XLA FFI custom calls on CPU ([JAX.md](docs/JAX.md)).
|
|
207
|
+
- **Python & scikit-learn:** `fit`, `loss_and_grad`, `distillation_loss_and_grad`,
|
|
208
|
+
`proximal_distillation_loss_and_grad`, `coordinate_update`, and `SDCAClassifier`
|
|
209
|
+
([docs/PYTHON.md](docs/PYTHON.md)).
|
|
210
|
+
- **Rust, C and C++:** Rust crate `libsdca` ([docs/RUST.md](docs/RUST.md)), versioned C
|
|
211
|
+
ABI `libsdca::sdca_c` ([docs/C.md](docs/C.md)) and CMake target `libsdca::libsdca`
|
|
212
|
+
([docs/CPP.md](docs/CPP.md)).
|
|
213
|
+
|
|
214
|
+
### Performance and solver improvements
|
|
215
|
+
|
|
216
|
+
- **CUDA kernels:** Fused Triton kernels for all losses with C++ `cuLaunchKernel` autograd
|
|
217
|
+
dispatch, multi-row CTA tiling for short rows, streaming tiles up to $2^{25}$ classes, and
|
|
218
|
+
in-place backward gradient writes into unreferenced logits tensors.
|
|
219
|
+
- **CPU kernels:** JIT-compiled ATen/OpenMP C++ extension with C++ autograd nodes and SIMD
|
|
220
|
+
`float32` exponentials + `float64` row statistics for narrow cross-entropy and top-*k*
|
|
221
|
+
cross-entropy ($k \le 64$).
|
|
222
|
+
- **Shrinking and screening (`shrinking="auto"`):** Combines LIBLINEAR-style active-set
|
|
223
|
+
shrinking with gap-safe screening for hinge fits, adapting the evaluation schedule to
|
|
224
|
+
shrunk epoch work (`0.14–0.59×` `LinearSVC` runtime; [API.md](docs/API.md#shrinking)).
|
|
225
|
+
- **$O(n \log n)$ projections and Taylor root warm-starts:** Top-*k* cone, simplex, knapsack
|
|
226
|
+
and top-*k* entropy projections run in $O(n \log n)$, and proximal / entropy root solves
|
|
227
|
+
converge in `1.0–1.3` row evaluations on average.
|
|
228
|
+
|
|
229
|
+
### Numerics and precision
|
|
230
|
+
|
|
231
|
+
- **Single rounding:** 16-bit gradients are scaled by the upstream cotangent and reduction
|
|
232
|
+
factor in working precision before a single rounding to the output dtype, and hinge / top-*k*
|
|
233
|
+
target gradients are formed from the unrounded competitor sum.
|
|
234
|
+
- **Optional double iterate for `float32` fits (`precision="float64"`):** Keeps internal
|
|
235
|
+
solver weights and duals in `double` (`8(d + n)m` bytes) and rounds once at each
|
|
236
|
+
evaluation so `float32` fits reach `float64` gap tolerances down to `float32` output
|
|
237
|
+
rounding (`3.5e-7` on `digits`; pass `precision="float32"` for pure `float32` speed and
|
|
238
|
+
memory).
|
|
239
|
+
- **Compensated reductions & hardened projections:** Compensated sums in multilabel
|
|
240
|
+
cross-entropy and distillation, warm-start residual preservation at large score offsets,
|
|
241
|
+
and checked `float64` / extended-precision `multilabel_hinge` projections.
|
|
242
|
+
|
|
243
|
+
### Packaging and build
|
|
244
|
+
|
|
245
|
+
- Portable `py3-none` wheels for Linux `x86_64` (`manylinux_2_28`) and macOS 11+ (`arm64`)
|
|
246
|
+
with built-in BLAS; configurable BLAS (`SDCA_BLAS_BACKEND=AUTO|EXTERNAL|BUILTIN`);
|
|
247
|
+
CMake 3.12+ package config; and GitHub Actions CI on Linux and macOS.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: >-
|
|
3
|
+
If libsdca is useful in your research, please cite the TPAMI paper; the earlier papers
|
|
4
|
+
introduce the top-k losses, and the technical report describes the library.
|
|
5
|
+
type: software
|
|
6
|
+
title: "libsdca: Accurate and Fast Classification Losses for SDCA and Neural Networks"
|
|
7
|
+
abstract: >-
|
|
8
|
+
Fused loss layers and SDCA solvers, accurate to the limit of the floating-point format
|
|
9
|
+
and fast on GPU and CPU.
|
|
10
|
+
authors:
|
|
11
|
+
- family-names: Lapin
|
|
12
|
+
given-names: Maksim
|
|
13
|
+
version: 0.4.0
|
|
14
|
+
date-released: 2026-11-27
|
|
15
|
+
license: MIT
|
|
16
|
+
url: https://mlapin.github.io/libsdca/
|
|
17
|
+
repository-code: https://github.com/mlapin/libsdca
|
|
18
|
+
keywords:
|
|
19
|
+
- sdca
|
|
20
|
+
- top-k
|
|
21
|
+
- cross-entropy
|
|
22
|
+
- svm
|
|
23
|
+
- loss functions
|
|
24
|
+
- numerical accuracy
|
|
25
|
+
- pytorch
|
|
26
|
+
- jax
|
|
27
|
+
preferred-citation:
|
|
28
|
+
type: article
|
|
29
|
+
title: Analysis and Optimization of Loss Functions for Multiclass, Top-k, and Multilabel Classification
|
|
30
|
+
authors:
|
|
31
|
+
- family-names: Lapin
|
|
32
|
+
given-names: Maksim
|
|
33
|
+
- family-names: Hein
|
|
34
|
+
given-names: Matthias
|
|
35
|
+
- family-names: Schiele
|
|
36
|
+
given-names: Bernt
|
|
37
|
+
journal: IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI)
|
|
38
|
+
volume: 40
|
|
39
|
+
issue: 7
|
|
40
|
+
start: 1533
|
|
41
|
+
end: 1554
|
|
42
|
+
year: 2018
|
|
43
|
+
references:
|
|
44
|
+
- type: conference-paper
|
|
45
|
+
title: Top-k Multiclass SVM
|
|
46
|
+
authors:
|
|
47
|
+
- family-names: Lapin
|
|
48
|
+
given-names: Maksim
|
|
49
|
+
- family-names: Hein
|
|
50
|
+
given-names: Matthias
|
|
51
|
+
- family-names: Schiele
|
|
52
|
+
given-names: Bernt
|
|
53
|
+
collection-title: Advances in Neural Information Processing Systems (NeurIPS)
|
|
54
|
+
year: 2015
|
|
55
|
+
- type: conference-paper
|
|
56
|
+
title: "Loss Functions for Top-k Error: Analysis and Insights"
|
|
57
|
+
authors:
|
|
58
|
+
- family-names: Lapin
|
|
59
|
+
given-names: Maksim
|
|
60
|
+
- family-names: Hein
|
|
61
|
+
given-names: Matthias
|
|
62
|
+
- family-names: Schiele
|
|
63
|
+
given-names: Bernt
|
|
64
|
+
collection-title: IEEE Conference on Computer Vision and Pattern Recognition (CVPR)
|
|
65
|
+
year: 2016
|
|
66
|
+
- type: report
|
|
67
|
+
title: "libsdca: Accurate and Fast Classification Losses for SDCA and Neural Networks"
|
|
68
|
+
authors:
|
|
69
|
+
- family-names: Lapin
|
|
70
|
+
given-names: Maksim
|
|
71
|
+
year: 2026
|
|
72
|
+
month: 11
|
|
73
|
+
url: https://mlapin.github.io/libsdca/report/
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Dependencies and builds
|
|
2
|
+
|
|
3
|
+
`libsdca` needs only a C++11 compiler (the first-use PyTorch and JAX CPU kernels, C++17). An external
|
|
4
|
+
CBLAS is recommended: every build links a system one when it finds one, and otherwise uses
|
|
5
|
+
the built-in products and warns ([API.md](docs/API.md#blas)). CMake 3.12+ is needed only for
|
|
6
|
+
the CMake packages `libsdca::libsdca` and `libsdca::sdca_c`.
|
|
7
|
+
|
|
8
|
+
## Tested configurations
|
|
9
|
+
|
|
10
|
+
| Component | Environments |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| C++ and C ABI | Ubuntu 22.04 / 24.04 `x86_64` with GCC 11 and 13 and Clang 18 (built-in and external BLAS, ASan/UBSan, TSan); macOS `arm64` with Apple Clang (built-in BLAS and Accelerate) |
|
|
13
|
+
| Python | Python 3.10–3.14, NumPy 1.26–2.5, SciPy 1.15–1.18, scikit-learn 1.7–1.9, PyTorch 2.1–2.15, JAX 0.4.35–0.12 |
|
|
14
|
+
| CUDA | NVIDIA A100 with PyTorch 2.14–2.15, Triton 3.8–3.9 and JAX 0.12 (hosted CI has no GPU) |
|
|
15
|
+
| Packaging | `py3-none` wheels via `cibuildwheel` on `manylinux_2_28` `x86_64` (OpenBLAS of `scipy-openblas32`) and macOS 11+ `arm64` (Accelerate), sdist, `.crate` |
|
|
16
|
+
| Rust | Rust 1.74 (MSRV) and stable on Linux `x86_64` (built-in BLAS, reference BLAS, OpenBLAS, BLIS) |
|
|
17
|
+
|
|
18
|
+
## Python
|
|
19
|
+
|
|
20
|
+
| Extra | Packages | Purpose |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| *(default)* | `numpy>=1.23`; `scipy-openblas32` (Linux wheels) | NumPy solver and losses; the BLAS of the Linux wheels |
|
|
23
|
+
| `sklearn` | `scikit-learn>=1.6` | `SDCAClassifier` |
|
|
24
|
+
| `torch` | `torch>=2.1`, `setuptools>=77,<81`, `ziglang>=0.13,<0.18` (Linux) | PyTorch losses |
|
|
25
|
+
| `jax` | `jax>=0.4.35` | JAX losses (`libsdca.jax`) |
|
|
26
|
+
| `jax-cuda` | `jax[cuda13]>=0.7.2`; `triton>=3.7`, `jax-triton>=0.5` (Linux, Python 3.12+) | JAX losses on CUDA |
|
|
27
|
+
| `test`, `test-torch`, `test-jax` | `pytest`, `pytest-xdist`, `scipy`, `mpmath`; `hypothesis>=6.136` (`test-torch`, `test-jax`), ... | Test suites (`--group core\|torch\|jax\|all`); property tests (`test_properties_*.py`) |
|
|
28
|
+
|
|
29
|
+
- **Versions:** PyTorch 2.1 wheels need `numpy<2`. The fused CUDA kernels need `triton>=3.3`,
|
|
30
|
+
which PyTorch 2.7 and later install; without it CUDA calls raise `NotImplementedError`
|
|
31
|
+
naming `backend="composed"`. `libsdca.torch.explain_backend` reports the active path.
|
|
32
|
+
- **First-use builds:** The PyTorch and JAX CPU kernels compile on first use against the
|
|
33
|
+
installed framework (a C++17 compiler and Python headers; JAX against
|
|
34
|
+
`jax.ffi.include_dir()`). Without build tools, CPU calls with `backend="auto"` raise
|
|
35
|
+
`NotImplementedError` naming `backend="composed"`.
|
|
36
|
+
- **Licences:** `libsdca` is MIT. The Linux wheels require, and load at run time, the
|
|
37
|
+
`scipy-openblas32` package (BSD-2-Clause), which ships OpenBLAS and LAPACK (BSD-3-Clause)
|
|
38
|
+
and the GCC runtime libraries `libgfortran` and `libquadmath` (GPL-3.0 with the GCC Runtime
|
|
39
|
+
Library Exception); its wheel carries their texts. The `libsdca` wheels include none of them.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
python -m pip install . # a system CBLAS, else built-in (warns)
|
|
43
|
+
SDCA_BLAS_BACKEND=BUILTIN python -m pip install . # no external BLAS
|
|
44
|
+
SDCA_BLAS_BACKEND=EXTERNAL python -m pip install . # require an external CBLAS
|
|
45
|
+
SDCA_BLAS_BACKEND=PACKAGE python -m pip install --no-build-isolation . # scipy-openblas32 (installed)
|
|
46
|
+
SDCA_BLAS="-L/opt/blas/lib -lopenblas" python -m pip install . # explicit linker flags
|
|
47
|
+
SDCA_BUILD_NATIVE=OFF python -m pip install '.[torch]' # tensor losses only, no compiler
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## C++ and CMake
|
|
51
|
+
|
|
52
|
+
| CMake option | Default | Description |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `SDCA_BLAS_BACKEND` | `AUTO` | `AUTO` (external CBLAS if found, else built-in with a warning), `BUILTIN`, or `EXTERNAL` ([API.md](docs/API.md#blas)) |
|
|
55
|
+
| `SDCA_BLAS` | `$ENV{SDCA_BLAS}` | Linker flags of an external CBLAS, in place of the candidates of `src/native_build.txt` |
|
|
56
|
+
| `SDCA_BUILD_C_API` | `OFF` | Build and install the C ABI library `libsdca::sdca_c` |
|
|
57
|
+
| `BUILD_TESTING` | `OFF` | Build the bundled GoogleTest suites |
|
|
58
|
+
| `SDCA_WARNINGS_AS_ERRORS` | `OFF` | Add `-Werror` |
|
|
59
|
+
| `USE_CHRONO` | `ON` | `<chrono>` wall clock (`OFF`: POSIX `gettimeofday`) |
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cmake -S . -B build -DSDCA_BLAS_BACKEND=BUILTIN -DCMAKE_INSTALL_PREFIX="$PWD/build/install"
|
|
63
|
+
cmake --build build --target install
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```cmake
|
|
67
|
+
find_package(libsdca CONFIG REQUIRED)
|
|
68
|
+
target_link_libraries(my_program PRIVATE libsdca::libsdca)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Without CMake, define `BLAS_DEFAULT_LOCAL_HEADER` and link a CBLAS (such as `-lopenblas` or
|
|
72
|
+
`-framework Accelerate`), or define `BLAS_BUILTIN` for the built-in products; with neither, the
|
|
73
|
+
headers take the built-in products and the solver logs a warning once. The headers need no
|
|
74
|
+
separate source file. Every build reads its BLAS candidates and compile flags from
|
|
75
|
+
`src/native_build.txt` ([API.md](docs/API.md#blas)); Intel MKL links through `SDCA_BLAS`
|
|
76
|
+
(for example `-lmkl_rt`, its 32-bit integer interface).
|
|
77
|
+
|
|
78
|
+
## Rust
|
|
79
|
+
|
|
80
|
+
The crate has no Rust dependencies and needs Rust 1.74+. `build.rs` compiles `src/c_api.cpp`
|
|
81
|
+
with `CXX` (default `c++`) and the BLAS of the shared rule: a system CBLAS if one links, else
|
|
82
|
+
the built-in products with a Cargo warning ([docs/RUST.md](docs/RUST.md#building)).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
recursive-include include *.h
|
|
2
|
+
include src/c_api.cpp src/native_build.txt src/blas_probe.cpp
|
|
3
|
+
include sdca_build.py VERSION
|
|
4
|
+
recursive-include docs *.md
|
|
5
|
+
include python/libsdca/_torch_cpu.cpp python/libsdca/_jax_cpu.cpp python/libsdca/_jax_cuda.cpp python/libsdca/_frontend_cpu.h python/libsdca/_torch_cuda_plan.h
|
|
6
|
+
include CHANGELOG.md DEPENDENCIES.md AGENTS.md CITATION.cff
|
|
7
|
+
recursive-include tests/python *.py *.json
|