Skip to content

Openaichat#437

Open
zichengorange wants to merge 2 commits intoGradientHQ:mainfrom
zichengorange:openaichat
Open

Openaichat#437
zichengorange wants to merge 2 commits intoGradientHQ:mainfrom
zichengorange:openaichat

Conversation

@zichengorange
Copy link

📋 PR Title Format

feat(api): OpenAI advanced sampling params (logprobs, logit_bias, penalties)

📝 Change Type

Please select the type of change this PR introduces (choose one or more):

  • [✅ ] feat: New feature.
  • fix: Bug fix.
  • docs: Documentation only changes.
  • refactor: A code change that neither fixes a bug nor adds a feature.
  • perf: Performance improvement.
  • test: Adding missing tests or correcting existing tests.
  • chore: Maintenance tasks (e.g., updating dependencies).

💡 Description

  • logprobs / top_logprobs: 在采样后返回选中 token 的 logprob 及 top-k logprobs,并通过 HTTP API 以 OpenAI 兼容格式返回(含流式)。
  • logit_bias: 支持对指定 token_id 加减 bias;bias=-100 时屏蔽该 token;超出 vocab 的 token_id 会忽略并打 Warning。
  • presence_penalty / frequency_penalty: 在 softmax 前按历史 token 应用惩罚,用向量化实现。
  • 容错: logprobs 计算异常时降级为不返回 logprobs,主线生成不受影响;API 层对异常 logprobs 做防御性处理。
  • 同步修改 SamplingParams、forward.proto、executor、sampler、http_server,并增加 E2E 测试与本地验证文档。

✅ Checklist

Please ensure the following points are addressed before merging:

  • [✅ ] I have performed a self-review of my own code.
  • [✅ ] I have added/updated tests that prove my fix or feature works (if applicable).
  • I have updated the documentation (if necessary).
  • My code follows the project's style guidelines.

cheng added 2 commits March 10, 2026 01:39
…penalties) onto upstream main

Made-with: Cursor
@zichengorange zichengorange requested a review from a team March 9, 2026 18:14
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