Skip to content

fix: preserve agentic delay bounds after context scaling - #1613

Draft
Wenyan0315 wants to merge 1 commit into
ai-dynamo:mainfrom
Wenyan0315:Wenyan0315/agentic-delay-bounds
Draft

Wenyan0315 wants to merge 1 commit into
ai-dynamo:mainfrom
Wenyan0315:Wenyan0315/agentic-delay-bounds

Conversation

@Wenyan0315

@Wenyan0315 Wenyan0315 commented Oct 25, 2026 •

Copy link
Copy Markdown

Context scaling can push generated inter-turn delays below the selected component's configured minimum. With the bundled default config plus agentic min=1000 and human min=5000, seed 42 and 1,500 sessions produced 6,174 of 22,135 later-turn delays below 1,000 ms on main 1558551 (minimum 241.745 ms). This change reduces that count to zero, with a minimum of 1,000 ms.

Addresses #1603. Kept as a draft for feedback on the compatibility choice below; analytic aggregate delay targets remain outside this focused fix.

Behavior

  • Add inter_turn_delay.context_scaling, defaulting to true to preserve existing seeded workloads. Setting it to false disables the context multiplier.
  • Enforce the selected component's minimum after scaling. The global maximum remains the final override, including when it conflicts with a minimum or is zero.
  • Preserve random draw order and cap-before-scaling behavior. Configurations without component minima retain the same generated traces when scaling is enabled.
  • Document the formula, bounds, and latent distribution parameters; regenerate the schema and include the setting in the manifest and quality summary.

The issue proposes default-off. This PR uses default-on to avoid silently changing existing benchmark workloads; maintainer feedback on that choice is welcome. quality.json still reports null aggregate delay targets: component means/medians are not valid final targets after mixture selection, truncation, and context scaling. Related #1188 changes distribution support; this PR keeps the existing distribution families.

Validation

  • macOS, Python 3.12.15; no inference server or GPU involved.
  • Initial synthesizer regression tests: 7 failed / 1 passed before the fix. Generator test directory after the fix: 242 passed, 1 deselected.
  • Three exported dataset SHA-256 fingerprints match main byte-for-byte: default config, global cap 600 ms, and cap 0; each uses 50 sessions and seed 42, with no component minima.
  • All applicable pre-commit hooks pass; generated agentic-code schema check and git diff --check pass.
  • Full unit suite: verification in progress; results will be recorded before review.

AI-assisted investigation, implementation, and validation on behalf of Wenyan0315.

Summary by CodeRabbit

  • New Features

    • Inter-turn delays can now scale down as conversation context grows. This behavior is enabled by default and can be disabled in configuration.
    • Component minimums are preserved after scaling, while the global maximum takes precedence. A global maximum of zero produces zero delay.
    • Delay scaling settings are included in generated manifests and quality summaries.
  • Documentation

    • Added guidance on delay scaling, its effects on existing seeded traces, and interpreting delay statistics.

Signed-off-by: Wenyan0315 <206175637+Wenyan0315@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the fix label Oct 25, 2026
@github-actions

Copy link
Copy Markdown

Try out this PR

Quick install:

pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@4f24baacf3fb1465a9fad99a2492a75ba6e382ed

Recommended with virtual environment (using uv):

uv venv --python 3.12 && source .venv/bin/activate
uv pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@4f24baacf3fb1465a9fad99a2492a75ba6e382ed

Last updated for commit: 4f24baa • Browse code

@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1558551 and 4f24baa.

Files selected for processing: 9
  • docs/tutorials/agentic-code-generator.md
  • src/aiperf/dataset/agentic_code_gen/configs/spec.json
  • src/aiperf/dataset/agentic_code_gen/distributions.py
  • src/aiperf/dataset/agentic_code_gen/models.py
  • src/aiperf/dataset/agentic_code_gen/reporting/metrics.py
  • src/aiperf/dataset/agentic_code_gen/session_synthesizer.py
  • tests/unit/dataset/agentic_code_gen/test_distributions.py
  • tests/unit/dataset/agentic_code_gen/test_roundtrip.py
  • tests/unit/dataset/agentic_code_gen/test_session_synthesizer.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

The change adds an enabled-by-default setting that scales sampled inter-turn delays based on the previous input size. It updates delay sampling, records the setting in quality summaries, and adds tests and tutorial documentation for scaling, bounds, and configuration roundtrips.

Changes

Inter-Turn Delay Scaling

Layer / File(s) Summary
Delay configuration and sampling
src/aiperf/dataset/agentic_code_gen/configs/spec.json, src/aiperf/dataset/agentic_code_gen/models.py, src/aiperf/dataset/agentic_code_gen/distributions.py, tests/unit/dataset/agentic_code_gen/test_distributions.py
MixtureDelayConfig adds the enabled-by-default context_scaling setting. sample_mixture_delay accepts a keyword-only delay_scale and rejects values outside (0, 1]. Tests cover scaling, component minima, a zero global maximum, and invalid scales.
Synthesis, reporting, and validation
src/aiperf/dataset/agentic_code_gen/session_synthesizer.py, src/aiperf/dataset/agentic_code_gen/reporting/metrics.py, tests/unit/dataset/agentic_code_gen/test_session_synthesizer.py, tests/unit/dataset/agentic_code_gen/test_roundtrip.py, docs/tutorials/agentic-code-generator.md
Session synthesis passes a context-dependent scale when enabled. The quality summary records the setting. Tests cover scaled and unscaled delays, bound precedence, and configuration roundtrips. The tutorial documents the scaling formula, delay bounds, and reported statistics.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: Minimal · up to 4f24b

The configured maximum still takes precedence over component minimums. No identified delay-scaling issue remains to resolve before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving agentic delay bounds after context scaling.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

I’m a rabbit with a config to share,
Delays now scale as context grows there.
Component floors still enter the play,
And global caps can have their say.
Tests trace the settings end to end,
Then off through the docs I hop, my friend.

Comment @coderabbitai help to get the list of available commands.

minimums = np.where(
is_agentic, config.agentic_delay.min or 0.0, config.human_delay.min or 0.0
)
samples = np.maximum(samples, minimums)

@mechaman mechaman Oct 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This re-applies the component min by clamping, which is inconsistent with how min is defined on the model:

min: float | None = Field(
default=None, gt=0.0, description="Hard lower bound (rejection sampled)"
)

LognormalParams.min is documented as "Hard lower bound (rejection sampled)", and sample_lognormal honors that by redrawing out-of-range values (L63–78 in this file). Here the same field is enforced with np.maximum, so after scaling, every value below the floor lands exactly on it rather than being redrawn.

This distorts the distribution. For example, with a human component of mean 450 s / median 84 s / min 30 s / max 1800 s, about 51% of human delays come out at exactly 30 s at full context (28% at scale 0.4). The new test ({900.0, 4500.0}) uses σ = 0 components, so it confirms the clamp happens but can’t show its effect on a spread-out distribution.

Could we pick one behavior and apply it consistently, from the individual lognormals through the mixture?

  • Redraw: resample, scale, re-check, falling back to the clamp after N attempts as sample_lognormal already does, or
  • Clamp: keep this, but update the min description (and the tutorial's "enforced again") to say it's rejection sampled before scaling and clamped after.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants