Skip to content

Commit 697ab06

Browse files
committed
feat(v7-g05): FIM toggle in TopBar threads to stage_train.fim_enabled
UI gap: backend supports opts.fim_enabled and surfaces extras.fim_active + fim_ratio (stages.py:1371,1694-95) since V6, but no TopBar control exposed it. Honest-closure 'FIM trajectory through UI' was reporting no UI affordance — this wires it end-to-end. - TopBar: new train-fim-enabled checkbox inside run-pipeline menu. - App.tsx: forwards opts.fim_enabled into stage_options.train. - e2e 80: two scenarios — toggle on asserts fim_active=true plus fim_ratio in (0,1] via the StageExtras DOM render; toggle off asserts fim_active=false. Real pipeline.run, not mocked.
1 parent 5d92d99 commit 697ab06

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// V7-G05: FIM (Fill-In-Middle) toggle in TopBar threads through
2+
// stage_options.train.fim_enabled and surfaces extras.train.fim_active
3+
// + fim_ratio. The visible-row assertion uses the StageExtras render
4+
// in RunResultModal so this is a true "UI shows backend math" check,
5+
// not just RPC payload echo.
6+
7+
import { test, expect } from "@playwright/test";
8+
import { gotoApp, selectPreset, closeModal } from "../fixtures";
9+
10+
test("V7-G05: FIM toggle surfaces fim_active=true + fim_ratio in train extras",
11+
async ({ page }) => {
12+
test.setTimeout(60_000);
13+
await gotoApp(page);
14+
await selectPreset(page, "llama3_8b");
15+
16+
await page.getByTestId("run-pipeline-toggle").click();
17+
await page.getByTestId("train-num-steps").fill("2");
18+
await page.getByTestId("train-fim-enabled").check();
19+
await page.getByTestId("run-pipeline-train").click();
20+
21+
const modal = page.getByTestId("run-result-modal");
22+
await modal.waitFor({ timeout: 60_000 });
23+
await page.getByTestId("run-result-expand-train").click();
24+
25+
const fimActive = await page
26+
.getByTestId("run-result-extras-train-fim_active").textContent();
27+
expect(fimActive).toBe("true");
28+
29+
const fimRatioText = await page
30+
.getByTestId("run-result-extras-train-fim_ratio").textContent();
31+
expect(fimRatioText).not.toBe("null");
32+
const fimRatio = parseFloat(fimRatioText ?? "0");
33+
expect(fimRatio).toBeGreaterThan(0);
34+
expect(fimRatio).toBeLessThanOrEqual(1);
35+
36+
await closeModal(page);
37+
});
38+
39+
test("V7-G05: FIM off by default — fim_active=false",
40+
async ({ page }) => {
41+
test.setTimeout(60_000);
42+
await gotoApp(page);
43+
await selectPreset(page, "llama3_8b");
44+
45+
await page.getByTestId("run-pipeline-toggle").click();
46+
await page.getByTestId("train-num-steps").fill("2");
47+
// Do not check train-fim-enabled.
48+
await page.getByTestId("run-pipeline-train").click();
49+
50+
const modal = page.getByTestId("run-result-modal");
51+
await modal.waitFor({ timeout: 60_000 });
52+
await page.getByTestId("run-result-expand-train").click();
53+
54+
const fimActive = await page
55+
.getByTestId("run-result-extras-train-fim_active").textContent();
56+
expect(fimActive).toBe("false");
57+
58+
await closeModal(page);
59+
});

vbgui/src/App.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ export function App(): JSX.Element {
377377
checkpoint_load_path?: string;
378378
inference_probe_text?: string;
379379
master_dtype?: "fp32" | "bf16" | "fp16" | "auto";
380+
fim_enabled?: boolean;
380381
},
381382
) => {
382383
// V7-I03: synchronous lock check at the very top — before any
@@ -433,6 +434,11 @@ export function App(): JSX.Element {
433434
if (opts?.master_dtype && opts.master_dtype !== "auto") {
434435
trainOpts.master_dtype = opts.master_dtype;
435436
}
437+
// V7-G05: forward FIM toggle. stage_train opts.fim_enabled gates
438+
// the middle-third masking + fim_ratio extras.
439+
if (opts?.fim_enabled) {
440+
trainOpts.fim_enabled = true;
441+
}
436442
// H20: when the spec carries sharding axes, derive fake_ranks
437443
// from the product of their degrees so a Train run simulates a
438444
// mean-reduced multi-rank backward (extras.fake_ranks +

vbgui/src/components/TopBar.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface TopBarProps {
1919
checkpoint_load_path?: string;
2020
inference_probe_text?: string;
2121
master_dtype?: "fp32" | "bf16" | "fp16" | "auto";
22+
fim_enabled?: boolean;
2223
}) => void;
2324
/** H02: toggle callbacks. */
2425
onMixedPrecisionChange?: (enabled: boolean) => void;
@@ -58,6 +59,10 @@ export function TopBar(p: TopBarProps): JSX.Element {
5859
// fp32/bf16/fp16 options override that for H23.
5960
const [masterDtype, setMasterDtype] =
6061
useState<"fp32" | "bf16" | "fp16" | "auto">("auto");
62+
// V7-G05: FIM (Fill-In-Middle) data path toggle. When on, stage_train
63+
// surfaces extras.train.fim_active + fim_ratio so the UI honest-closure
64+
// shows the FIM math actually fired.
65+
const [fimEnabled, setFimEnabled] = useState<boolean>(false);
6166
return (
6267
<header data-testid="top-bar"
6368
style={{ height: 56, display: "flex", alignItems: "center",
@@ -247,6 +252,14 @@ export function TopBar(p: TopBarProps): JSX.Element {
247252
<option value="fp16">fp16</option>
248253
</select>
249254
</label>
255+
<label style={{ padding: "6px 12px", display: "flex",
256+
alignItems: "center", gap: 6, fontSize: 11,
257+
color: "#374151" }}>
258+
<input data-testid="train-fim-enabled" type="checkbox"
259+
checked={fimEnabled}
260+
onChange={(e) => setFimEnabled(e.target.checked)} />
261+
FIM (Fill-In-Middle) data path
262+
</label>
250263
<label style={{ padding: "6px 12px", display: "flex",
251264
flexDirection: "column", gap: 3, fontSize: 11,
252265
color: "#374151" }}>
@@ -270,7 +283,8 @@ export function TopBar(p: TopBarProps): JSX.Element {
270283
ckptLoadPath || undefined,
271284
inference_probe_text:
272285
probeText || undefined,
273-
master_dtype: masterDtype }); }}
286+
master_dtype: masterDtype,
287+
fim_enabled: fimEnabled }); }}
274288
// H22: disable while a Train is already running so
275289
// double-clicks don't spawn a parallel pipeline.
276290
disabled={!!p.trainDisabled || !!p.trainInFlight}

0 commit comments

Comments
 (0)