Skip to content

Preserve singleton dimensions in soft sorting transport - #712

Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
ott-jax:mainfrom
AHMETHAKANBEZIR1:fix/soft-sort-singleton
Open

AHMETHAKANBEZIR1 wants to merge 1 commit into
ott-jax:mainfrom
AHMETHAKANBEZIR1:fix/soft-sort-singleton

Conversation

@AHMETHAKANBEZIR1

Copy link
Copy Markdown

soft_sort.sort(jnp.array([2.0])) raises an axis error because transport_for_sort squeezes its only sample to a scalar. Likewise, quantize(x, num_levels=1) fails when its single target weight becomes scalar.

Preserve the sample and weight dimensions with explicit reshapes, retaining None for unspecified weights. For a singleton input, the default whitening/sigmoid maps directly to its constant value 0.5; this avoids differentiating standard deviation at zero and keeps singleton sorting gradients finite. Custom squashing functions retain their existing path.

Validation on Windows, Python 3.12.14 / JAX 0.11.2 CPU:

  • Five new cases fail against unmodified main 36338c9 with axis/index errors; all five pass after the change, including JIT, singleton identity gradients, and single-level mean/gradient references.
  • Entire tests/tools/soft_sort_test.py: 31 passed.
  • Fast selection of the five new cases: 5 passed.
  • Configured pre-commit hooks pass; git diff --check passes.

The new analytic tests use the existing x64 fixture. A separate float32 singleton smoke check returned approximately 2 and gradient 1. Full package tests, GPU, and benchmarks were not run. The existing JAXopt deprecation warning remains.

Prepared and tested autonomously with an AI coding agent; no independent human code review has been performed. This is a locally reproduced API failure, not a claimed production incident.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant