Skip to content

CISPOLoss drops out-of-range token gradients instead of detaching IS weights #4664

Open

Description

@davrens101

Bug

CISPOLoss differentiates through the clamped importance ratio, which zeroes the policy gradient whenever a token's ratio is outside the clip interval. This contradicts CISPO's defining purpose of preserving those token updates.

The primary MiniMax-M1 paper, section 3.1, equation 4, specifies the surrogate as -stopgrad(clipped_ratio) * advantage * log_pi_current: https://arxiv.org/html/2506.13585v1#S3.E4 . Current torchrl/objectives/llm/grpo.py::_compute_policy_objective instead returns -clipped_ratio * advantage.

Actual CPU reproduction

A real trainable two-class linear token policy, wrapped as a TensorDictModuleBase with a TensorDictModule and native LLMMaskedCategorical, emits probabilities [0.2, 0.8]. Score token 0 with advantage 1, one valid token and clip_epsilon=0.2. Public CISPOLoss(policy, entropy_bonus=False)(data) and backward produce:

Current/behavior ratio Actual logit gradient Equation 4 gradient
0.5 [0, 0] [-0.64, +0.64]
1.0 [-0.8, +0.8] [-0.8, +0.8]
2.0 [0, 0] [-0.96, +0.96]

This uses real distribution scoring and autograd, not a mocked loss or fixed log-probability echo. Python 3.12, PyTorch 2.15.0+cpu, TensorDict 0.15.4. The unavailable optional C++ extension is not used by this path.

Focused fix plan

Pass the already-computed current token log-probabilities into the private objective hook. CISPO detaches clipped importance weights and multiplies them by current log-probabilities and advantages. Keep ordinary GRPO/DAPO clipping, masks, KL terms and aggregation unchanged. Add native trainable-policy regressions comparing both loss and parameter gradients with equation 4, covering clipped/unclipped ratios, advantage signs and padding.

Related open GSPO work #4652/#4653 adds a different objective; its patch does not repair CISPO. Merged #4164 only strengthened forward-value tests, which do not detect this gradient error. No duplicate fix or specific ownership claim was found in the searched issues/PRs.

I supervised and checked the AI-assisted work as it progressed. AI assistance was used for investigation and reproduction. No maintainer review or approval is claimed. No CLA has been signed by an agent; any required acceptance remains an account-holder action.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions