Repository navigation
feat(#23): add Play Level 3 KV cache memory level - #47
fullsend-ai-coder[bot] wants to merge 6 commits into
Conversation
Implement Play Level 3 covering KV cache memory mechanics, demand vs. capacity limits, request preemption, and FP8 KV cache memory savings. - Add calculateKvPreemption pure formula in src/lib/model.ts and unit tests in src/lib/model.test.ts - Create Level3Component in src/play/levels/level-3.tsx adhering to the 4-step teaching loop: Learn, Try, Challenge, and Recap - Implement interactive memory gauge and request slices visualization - Add Challenge goals for Llama-3-8B (32 users @ 8K on 1 GPU) and Llama-3-70B (16 users @ 4K with fewest GPUs via FP8 KV cache) - Register Level 3 in src/play/levels/index.ts and export component - Add component test coverage in src/play/levels/level-3.test.tsx Closes #23
|
🤖 Finished Review · ✅ Success · Started 11:56 PM UTC · Completed 12:13 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $2.65 |
|
<!-- fullsend:risk-assessment --> DetailsModerate risk driven by large change size (1,754 lines across 7 files implementing Play Level 3), offset by strong test coverage (43%), purely additive changes with zero deletions, single-author git history, and no protected or security-sensitive paths touched. Previous run<!-- fullsend:risk-assessment --> DetailsModerate risk driven by large change size (1,779 lines across 10 files implementing Play Level 3), offset by strong test coverage (50%), additive-only changes, low author contention, and no protected or security-sensitive paths touched. Previous run (2)<!-- fullsend:risk-assessment --> DetailsModerate risk driven by large change size (1,697 lines across 7 files implementing Play Level 3), offset by strong test coverage (57%), additive-only changes, and no protected or security-sensitive paths touched. |
ReviewFindingsHigh
Medium
Low
Next steps:
Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoiaGlnaCIsImNhdGVnb3J5IjoibG9naWMtZXJyb3IiLCJmaWxlIjoic3JjL3BsYXkvbGV2ZWxzL2luZGV4LnRzIiwiaWQiOiJmXzY1ODg0YWY0ODY1ZDkxMTciLCJsaW5lIjoyOCwiYWN0aW9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aW9uYWJsZSI6dHJ1ZSwiZGltZW5zaW9uIjoidXNlci1leHBlcmllbmNlIn1dfQ== --> ReviewFindingsHigh
Medium
Low
Labels: PR introduces Play Level 3 as a new interactive feature. Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 12:14 AM UTC · Completed 12:25 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $0.86 |
- Unlock Level 3 upon completing Level 0 in sparse registries and navigate to next level - Initialize Level 3 challenge goals to unsolved state to prevent premature auto-completion - Disambiguate KV Cache Precision compound control accessible names between Goal 1 and Goal 2 - Add role="figure" to memory architecture diagram container for WAI-ARIA 1.2 compliance - Add role="alert" and role="status" with aria-live for dynamic preemption and serving announcements - Update Level 3 component tests to verify initial uncompleted state, failing states, and completion progression Addresses #47
🔧 Fix agent — iteration 1 (bot-triggered)Addressed all 6 review findings: updated progress tracking to unlock Level 3 upon completing Level 0 in sparse registries, initialized Level 3 challenge goals to unsolved states to prevent auto-completion on mount, disambiguated KV Cache Precision compound control accessible names, added semantic role='figure' to the memory diagram container, added role='alert' and role='status' live regions for dynamic preemption alerts, and updated component and progress unit tests. Fixed (6):
Tests: passed CI inspections (1):
Conflict update: skipped; strategy Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 12:26 AM UTC · Completed 12:37 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $1.68 |
Superseded by updated review
|
/fs-fix Approved, but it conflicts with main (L4 #44 merged into src/play/levels/index.ts). Merge origin/main, keep every level already registered on main, and add this one in number order. No other changes. Lint, typecheck, test and build must pass. |
|
🤖 Finished Fix · ✅ Success · Started 12:39 AM UTC · Completed 12:54 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $1.01 |
Reconcile conflict in src/play/levels/index.ts by keeping registered levels from main and registering Level 3 in number order. Addresses #47
🔧 Fix agent — iteration 2 (human-triggered)Merged origin/main into PR branch, resolving merge conflicts in src/play/levels/index.ts, src/App.test.tsx, src/pages/play-page.test.tsx, and src/play/progress.ts. Preserved all levels already registered on main (Level 0 Tokens, Level 4 Batching) and registered Level 3 KV Cache Memory in number order. All linting, typechecking, tests, and build passed. Fixed (1):
Tests: passed Conflict update: merged; strategy Decision points
Next steps:
|
|
🤖 Review · Commit: This review was superseded by a newer commit. Check the current pull request HEAD's review status before merging. |
|
/fs-fix L2 (#42) just merged into src/play/levels/index.ts, so this conflicts again. Merge origin/main, keep every level already registered on main, and add this one in number order. No other changes. Lint, typecheck, test and build must pass. |
|
🤖 Finished Fix · ✅ Success · Started 1:04 AM UTC · Completed 1:17 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $0.81 |
Reconcile conflict in src/play/levels/index.ts by keeping registered levels from main and registering Level 3 in number order. Addresses #47
🔧 Fix agent — iteration 3 (human-triggered)Merged origin/main into PR branch, resolving merge conflicts in src/play/levels/index.ts and src/pages/play-page.tsx. Preserved all levels already registered on main (Level 0 Tokens, Level 2 Prefill vs. Decode, Level 4 Batching) and registered Level 3 KV Cache Memory in number order. All linting, typechecking, tests, and build passed cleanly. Fixed (1):
Tests: passed CI inspections (1):
Conflict update: merged; strategy Decision points
Next steps:
|
|
🤖 Finished Review · Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $2.11 This review was superseded by a newer commit. Check the current pull request HEAD's review status before merging. |
|
🤖 Finished Review · ✅ Success · Started 1:18 AM UTC · Completed 1:35 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $1.89 |
| if (prevLevel) { | ||
| if (prevLevel && prevLevel.number > 0) { | ||
| if (prevLevel.number === 3 && !levels.some((l) => l.number === 1)) { | ||
| return true |
There was a problem hiding this comment.
[high] logic-error
In isLevelUnlocked(), evaluating whether Level 4 (levelNum === 4) is unlocked checks prevLevel (Level 3). Because Level 1 is not yet registered in LEVELS, !levels.some((l) => l.number === 1) evaluates to true, causing isLevelUnlocked() to unconditionally return true for Level 4. This bypasses level progression gating, marking Level 4 as available on a fresh profile (completedLevelIds: []) while Level 3 remains locked. Level 4 should only unlock when its preceding level (Level 3) is completed.
Suggested fix: Remove the bypass at lines 192–194 of src/play/progress.ts so that Level 4 requires completion of prevLevel via return isLevelCompleted(state, prevLevel.id, levels). In src/pages/play-page.test.tsx, update the Level 4 test to seed completedLevelIds with "kv-cache" (Level 3).
| // In sparse registries: | ||
| // - Level 3 unlocks when Level 0 is completed. | ||
| // - Level 4 is available when Level 1 is not registered, or unlocks when Level 1 is completed. | ||
| if (levelNum !== undefined && levelNum > 1) { |
There was a problem hiding this comment.
[medium] pattern-inconsistency
isLevelUnlocked introduces hardcoded level-specific branches (if (levelNum === 3) and if (prevLevel.number === 3 && !levels.some((l) => l.number === 1))). This breaks the generic data-driven progression pattern established across src/play/progress.ts, where unlocking rules operate polymorphically over LevelDefinition[] based on initial availability (levels <= 1) and preceding level completion. These ad-hoc level checks bypass the standard preceding-level completion logic and tightly couple the progression utility to specific level indices.
Suggested fix: Remove the hardcoded branches for level 3 and level 4. Ensure the generic sparse-registry unlock logic (finding the highest registered level with number < levelNum and checking its completion status) handles sparse level configurations uniformly without branching on specific level numbers.
| </div> | ||
|
|
||
| {/* Goal 1 Outcome Feedback */} | ||
| <div |
There was a problem hiding this comment.
[medium] uxd-evaluate-code-heuristics
Goal 1 outcome feedback dynamically displays calculation verdicts and status messages (pass/fail status, served vs. preempted request counts) when the user modifies GPU hardware or KV cache precision options, but the container lacks live region semantics (role="status" or aria-live="polite"). Without a live region, dynamic updates are not announced to screen reader and assistive technology users (WCAG 4.1.3).
Suggested fix: Add live region semantics (role="status", aria-live="polite", and aria-atomic="true") to the Goal 1 outcome feedback container at line 945 so dynamic calculation outcomes and pass/fail transitions are announced to assistive technology.
| </div> | ||
|
|
||
| {/* Goal 2 Outcome Feedback */} | ||
| <div |
There was a problem hiding this comment.
[medium] uxd-evaluate-code-heuristics
Goal 2 outcome feedback dynamically displays calculation verdicts, GPU count efficiency hints, and preemption warnings when the user changes hardware, count, or precision options, but the container lacks live region semantics (role="status" or aria-live="polite"). Screen reader users are not alerted when options are toggled or when goal criteria are achieved (WCAG 4.1.3).
Suggested fix: Add live region semantics (role="status", aria-live="polite", and aria-atomic="true") to the Goal 2 outcome feedback container at line 1094 so dynamic calculation updates are announced to assistive technology.
| </div> | ||
| ) : ( | ||
| <div | ||
| role="status" |
There was a problem hiding this comment.
[low] pattern-inconsistency
The custom container displaying the dynamic serving status specifies role="status" and aria-live="polite", but omits aria-atomic="true". According to AGENTS.md conventions and repository live region patterns (such as in src/pages/calculator-page.tsx and src/play/levels/level-2.tsx), any custom container displaying dynamic calculation outcomes outside standard components must define complete live region semantics: role="status", aria-live="polite", and aria-atomic="true".
Suggested fix: Add aria-atomic="true" to the status container:
|
|
||
| fireEvent.click(screen.getByRole("tab", { name: /try/i })) | ||
|
|
||
| // Initial state: Llama-3-8B on 1x A100 (80GB) with 32 users @ 8K context fits with 0 preemption |
There was a problem hiding this comment.
[low] pattern-inconsistency
In src/play/levels/level-3.test.tsx, dynamic calculation verdicts for normal serving and preemption are queried via raw text matchers (screen.getByText(/All 32 requests served/i) and screen.getByText(/Preemption Detected: 32 of 32 requests preempted!/i)) rather than role-based accessible queries. AGENTS.md explicitly defines the test convention: 'Component tests (*.test.tsx) run under npm test must assert compound controls using role-based accessible queries (e.g., querying radiogroup by name), repeated controls by disambiguated name, and dynamic calculation verdicts using getByRole("status") or getByRole("alert")'.
Suggested fix: Query dynamic outcome containers using screen.getByRole("status") and screen.getByRole("alert") to match the project's accessible test query conventions.
Superseded by updated review
|
/fs-fix Merge origin/main and resolve conflicts first (keep every level registered on main), then address the open review findings. |
|
🤖 Finished Fix · ✅ Success · Started 1:41 AM UTC · Completed 1:53 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $1.15 |
…ache # Conflicts: # src/play/levels/index.ts # src/play/progress.ts
- Restore generic sparse-registry level unlocking without ad-hoc branches - Require Level 3 completion before unlocking Level 4 in tests - Add live region semantics to Level 3 status and outcome containers - Query dynamic calculation verdicts using role-based accessible queries Addresses #47
🔧 Fix agent — iteration 4 (human-triggered)Merged origin/main and resolved conflicts in src/play/levels/index.ts and src/play/progress.ts, preserving all registered levels (0, 2, 4, 5) and registering Level 3 in number order. Removed ad-hoc level 3/4 branches in isLevelUnlocked to restore generic data-driven progression gating, updated Level 4 test to require Level 3 completion, added complete live region semantics (role='status', aria-live='polite', aria-atomic='true') to Level 3 status and challenge feedback containers, and updated component tests to assert outcomes via role-based queries. Fixed (7):
Tests: passed CI inspections (1):
Conflict update: merged; strategy Decision points
Next steps:
|
|
🤖 Finished Review · ❌ Failure (validation failed after 1 iteration(s)) · Started 1:55 AM UTC · Completed 1:59 AM UTC Commit: Runtime: pi · Model: google-vertex/gemini-3.8-flash → gemini-3.8-flash · Effort: high · Cost: $0.49 |
|
/fs-review |
1 similar comment
|
/fs-review |
Summary
Implements Play Level 3 ("KV Cache Memory") teaching how keys and values stored in GPU memory limit concurrent requests and context length, how memory exhaustion causes request preemption and recomputation, and how FP8 KV cache halves memory per token.
Implementation Details
src/lib/model.ts): Added purecalculateKvPreemptionformula calculating KV demand, capacity tokens, max concurrency, served vs. preempted requests, and shortfall bytes. Added comprehensive unit tests insrc/lib/model.test.ts.src/play/levels/level-3.tsx): Built usingLevelLayoutand shadcn UI primitives:Calls
onComplete()when both goals are satisfied.src/play/levels/index.ts): Registered Level 3 and exportedLevel3Componentandlevel3.<Label>andaria-labelledby, no redundant aria-labels, and role-based test queries.Testing
src/lib/model.test.tsfor KV preemption calculations under fitting, preemption, and edge cases.src/play/levels/level-3.test.tsxverifying Learn, Try, Challenge (pass/fail states andonCompleteinvocation), Recap, and accessible compound control roles.npm run lint,npm run typecheck,npm test, andnpm run build— all passed cleanly.Closes #23
Post-script verification
agent/23-level-3-kv-cache)f83a27c8bd26170fc3cb818efe4f5b8683e30324..HEAD)