Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): offer the FP8 Storage default only where it does something
Alexander Eichhorn4ecb198ccea8
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 4cebb0012e..fa30bf0ec0 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1196,7 +1196,7 @@"installBundle": "Install bundle","installFailed": "Install failed","installFp8Storage": "FP8 storage",- "installFp8StorageTooltip": "Store the weights in FP8 to roughly halve VRAM use. Checkpoints that already store FP8 weights get this automatically; GGUF, NF4 and SDNQ models are not affected.",+ "installFp8StorageTooltip": "Store the weights in FP8 to roughly halve VRAM use. Applied only where the model's loader supports it — a checkpoint that already stores FP8 weights gets it automatically, and models it cannot help (GGUF, NF4 and SDNQ among them) are left alone.","installInPlace": "Install in place","installJobSummary_one": "{{count}} job · no active installs","installJobSummary_other": "{{count}} jobs · no active installs",diff --git a/invokeai/frontend/webv2/src/features/models/data/api.ts b/invokeai/frontend/webv2/src/features/models/data/api.tsindex 59bf5eeafe..54525b7889 100644--- a/invokeai/frontend/webv2/src/features/models/data/api.ts+++ b/invokeai/frontend/webv2/src/features/models/data/api.ts@@ -36,6 +36,24 @@ export const listMissingModels = async (signal?: AbortSignal): Promise<ModelConfexport const getModelsDir = (signal?: AbortSignal): Promise<string> =>requestJson<string>(`${MODELS_BASE}/models_dir`, { signal });+/** One `(base, type, format)` loader key and whether FP8 Storage reaches it. */+export interface Fp8StorageSupportRow {+ base: string;+ type: string;+ format: string;+ supported: boolean;+}++/**+ * Which kinds of model FP8 Storage actually does something for. Static per backend build.+ *+ * Keyed by the loader key rather than the model type, because the answer differs along all three+ * parts: FLUX main implements the cast, FLUX ControlNet does not, and a GGUF main model must never be+ * re-encoded. A key the backend does not serve is not supported.+ */+export const getFp8StorageSupport = (signal?: AbortSignal): Promise<Fp8StorageSupportRow[]> =>+ requestJson<Fp8StorageSupportRow[]>(`${MODELS_BASE}/fp8_storage_support`, { signal });+export const updateModel = (key: string, changes: ModelRecordChanges, signal?: AbortSignal): Promise<ModelConfig> =>requestJson<ModelConfig>(`${MODELS_BASE}/i/${encodeURIComponent(key)}`, {body: JSON.stringify(changes),diff --git a/invokeai/frontend/webv2/src/features/models/data/fp8StorageSupportStore.test.ts b/invokeai/frontend/webv2/src/features/models/data/fp8StorageSupportStore.test.tsnew file mode 100644index 0000000000..dcaeb34763--- /dev/null+++ b/invokeai/frontend/webv2/src/features/models/data/fp8StorageSupportStore.test.ts@@ -0,0 +1,123 @@+import type { ModelConfig } from '@features/models/core/types';++import { beforeEach, describe, expect, it, vi } from 'vitest';++const api = vi.hoisted(() => ({ getFp8StorageSupport: vi.fn() }));++vi.mock('./api', () => api);++const row = (base: string, type: string, format: string, supported: boolean) => ({ base, format, supported, type });++const model = (base: string, type: string, format: string) =>+ ({ base, format, type }) as Pick<ModelConfig, 'base' | 'format' | 'type'>;++/** The two rows that make the case for the key: same base, same type, opposite answers by format. */+const WAN_ROWS = [+ row('wan', 'main', 'checkpoint', true),+ row('wan', 'main', 'gguf_quantized', false),+ row('flux', 'controlnet', 'checkpoint', false),+];++describe('fp8 storage support store', () => {+ beforeEach(() => {+ vi.resetModules();+ api.getFp8StorageSupport.mockReset();+ });++ it('answers per (base, type, format) once the table is loaded', async () => {+ api.getFp8StorageSupport.mockResolvedValue(WAN_ROWS);+ const store = await import('./fp8StorageSupportStore');++ await store.ensureFp8StorageSupportLoaded();+ const snapshot = store.getFp8StorageSupportSnapshot();++ expect(snapshot.status).toBe('loaded');+ expect(store.isFp8StorageSupported(snapshot, model('wan', 'main', 'checkpoint'))).toBe(true);+ // The format alone flips it: the same architecture's packed weights must never be re-encoded.+ expect(store.isFp8StorageSupported(snapshot, model('wan', 'main', 'gguf_quantized'))).toBe(false);+ // And the type alone flips it for FLUX, which is why neither half of the key can be dropped.+ expect(store.isFp8StorageSupported(snapshot, model('flux', 'controlnet', 'checkpoint'))).toBe(false);+ });++ it('resolves a wildcard row the way the backend resolves a wildcard loader', async () => {+ api.getFp8StorageSupport.mockResolvedValue([row('any', 't2i_adapter', 'diffusers', true)]);+ const store = await import('./fp8StorageSupportStore');++ await store.ensureFp8StorageSupportLoaded();+ const snapshot = store.getFp8StorageSupportSnapshot();++ // Every T2I adapter is served by one `any`-base registration, and no record carries `any` as its+ // own base. Exact key first, then the wildcard — the order `get_implementation` uses.+ expect(store.isFp8StorageSupported(snapshot, model('sd-1', 't2i_adapter', 'diffusers'))).toBe(true);+ expect(store.isFp8StorageSupported(snapshot, model('sdxl', 't2i_adapter', 'diffusers'))).toBe(true);+ // The wildcard does not leak across the rest of the key.+ expect(store.isFp8StorageSupported(snapshot, model('sd-1', 'main', 'diffusers'))).toBe(false);+ });++ it('prefers an exact row over the wildcard', async () => {+ api.getFp8StorageSupport.mockResolvedValue([+ row('any', 't2i_adapter', 'diffusers', true),+ row('flux', 't2i_adapter', 'diffusers', false),+ ]);+ const store = await import('./fp8StorageSupportStore');++ await store.ensureFp8StorageSupportLoaded();+ const snapshot = store.getFp8StorageSupportSnapshot();++ // A loader registered for one architecture overrides the generic one, so its answer has to win —+ // including when it is the more restrictive of the two.+ expect(store.isFp8StorageSupported(snapshot, model('flux', 't2i_adapter', 'diffusers'))).toBe(false);+ expect(store.isFp8StorageSupported(snapshot, model('sd-1', 't2i_adapter', 'diffusers'))).toBe(true);+ });++ it('answers no for a model the table does not mention', async () => {+ api.getFp8StorageSupport.mockResolvedValue(WAN_ROWS);+ const store = await import('./fp8StorageSupportStore');++ await store.ensureFp8StorageSupportLoaded();++ // A VAE gets no row, and neither does a loader key the backend does not serve. Both mean the+ // control would do nothing, which is the same conclusion the server reaches for them.+ expect(store.isFp8StorageSupported(store.getFp8StorageSupportSnapshot(), model('sdxl', 'vae', 'diffusers'))).toBe(+ false+ );+ });++ it('answers no before the table has arrived', async () => {+ api.getFp8StorageSupport.mockResolvedValue(WAN_ROWS);+ const store = await import('./fp8StorageSupportStore');++ // A control that appears a moment late is better than one that turns out to be inert, so unknown+ // reads as unsupported rather than optimistically as supported.+ expect(store.isFp8StorageSupported(store.getFp8StorageSupportSnapshot(), model('wan', 'main', 'checkpoint'))).toBe(+ false+ );+ });++ it('shares one request and retries after a failure', async () => {+ api.getFp8StorageSupport.mockRejectedValueOnce(new Error('offline')).mockResolvedValueOnce(WAN_ROWS);+ const store = await import('./fp8StorageSupportStore');++ const first = store.ensureFp8StorageSupportLoaded();+ expect(store.ensureFp8StorageSupportLoaded()).toBe(first);+ // Swallowed rather than rethrown: the consumer hides the row and has no message to show. The+ // status is what lets the next mount try again instead of waiting forever.+ await expect(first).resolves.toBeUndefined();+ expect(store.getFp8StorageSupportSnapshot().status).toBe('error');++ await store.ensureFp8StorageSupportLoaded();+ expect(store.getFp8StorageSupportSnapshot().status).toBe('loaded');+ expect(api.getFp8StorageSupport).toHaveBeenCalledTimes(2);+ });++ it('does not refetch a table it already holds', async () => {+ api.getFp8StorageSupport.mockResolvedValue(WAN_ROWS);+ const store = await import('./fp8StorageSupportStore');++ await store.ensureFp8StorageSupportLoaded();+ await store.ensureFp8StorageSupportLoaded();++ // Static per backend build: a second mount of the detail view must not hit the network again.+ expect(api.getFp8StorageSupport).toHaveBeenCalledTimes(1);+ });+});diff --git a/invokeai/frontend/webv2/src/features/models/data/fp8StorageSupportStore.ts b/invokeai/frontend/webv2/src/features/models/data/fp8StorageSupportStore.tsnew file mode 100644index 0000000000..2599f48d89--- /dev/null+++ b/invokeai/frontend/webv2/src/features/models/data/fp8StorageSupportStore.ts@@ -0,0 +1,101 @@+import type { ModelConfig } from '@features/models/core/types';++import {+ captureAccountScope,+ isAccountScopeCurrent,+ registerAccountOwnedResource,+} from '@platform/state/accountLifecycle';+import { createExternalStore } from '@platform/state/externalStore';+import { createTrailingSingleFlight } from '@platform/state/singleFlight';++import { getFp8StorageSupport, type Fp8StorageSupportRow } from './api';++/**+ * Which models may be offered the FP8 Storage default, answered by the backend.+ *+ * The client used to answer it from the model type alone — `main`, `controlnet` or `t2i_adapter` — and+ * so offered the control for 19 of the 52 loader keys that ignore it: a GGUF main model whose packed+ * weights must never be re-encoded, a FLUX ControlNet whose loader never casts. Type is not enough,+ * and neither is base: FLUX main casts and FLUX ControlNet does not. The server composes the whole+ * answer per `(base, type, format)` and ships the finished boolean.+ *+ * Static per backend build, so it is fetched once on first use rather than kept fresh.+ */++export interface Fp8StorageSupportSnapshot {+ /** Null until fetched. Keyed `base\u0000type\u0000format`. */+ byKey: ReadonlyMap<string, boolean> | null;+ status: 'idle' | 'loading' | 'loaded' | 'error';+}++const EMPTY_SNAPSHOT: Fp8StorageSupportSnapshot = { byKey: null, status: 'idle' };+const store = createExternalStore<Fp8StorageSupportSnapshot>(EMPTY_SNAPSHOT);+const refreshFlight = createTrailingSingleFlight();++const rowKey = (base: string, type: string, format: string): string => `${base}\u0000${type}\u0000${format}`;++registerAccountOwnedResource({+ clear: () => {+ refreshFlight.reset();+ store.setSnapshot(EMPTY_SNAPSHOT);+ },+ name: 'fp8-storage-support',+});++const refresh = (): Promise<void> =>+ refreshFlight.run(() => {+ const owner = captureAccountScope();++ store.patchSnapshot({ status: store.getSnapshot().byKey ? 'loaded' : 'loading' });++ return getFp8StorageSupport(owner.signal)+ .then((rows: Fp8StorageSupportRow[]) => {+ if (isAccountScopeCurrent(owner)) {+ store.setSnapshot({+ byKey: new Map(rows.map((row) => [rowKey(row.base, row.type, row.format), row.supported])),+ status: 'loaded',+ });+ }+ })+ .catch(() => {+ if (isAccountScopeCurrent(owner)) {+ // No error copy: the only consumer hides a control it cannot vouch for, which needs no+ // message. Recorded as `error` so a later mount retries rather than waiting forever.+ store.patchSnapshot({ status: store.getSnapshot().byKey ? 'loaded' : 'error' });+ }+ });+ });++/** Fetch on first use; concurrent callers share the request. */+export const ensureFp8StorageSupportLoaded = (): Promise<void> => {+ const { status } = store.getSnapshot();++ if (status === 'idle' || status === 'error') {+ return refresh();+ }++ return refreshFlight.inflight() ?? Promise.resolve();+};++/**+ * Whether FP8 Storage does anything for this model. `false` until the table has arrived.+ *+ * Unknown reads as unsupported in both directions — before the table loads, and for a key the table+ * does not contain. Offering a control that turns out to be inert is the defect this replaces; a+ * control that appears a moment late is not.+ *+ * A row with base `any` is a wildcard loader registration, resolved after the exact key and in the same+ * order the backend registry resolves a loader. T2I adapters are served entirely that way, so without+ * the fallback they would all lose the control.+ */+export const isFp8StorageSupported = (+ snapshot: Fp8StorageSupportSnapshot,+ model: Pick<ModelConfig, 'base' | 'format' | 'type'>+): boolean =>+ snapshot.byKey?.get(rowKey(model.base, model.type, model.format)) ??+ snapshot.byKey?.get(rowKey('any', model.type, model.format)) ??+ false;++export const getFp8StorageSupportSnapshot = (): Fp8StorageSupportSnapshot => store.getSnapshot();++export const useFp8StorageSupportSelector = store.useSelector;diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.browser.test.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.browser.test.tsxnew file mode 100644index 0000000000..9863290a09--- /dev/null+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.browser.test.tsx@@ -0,0 +1,223 @@+import type * as ModelsApi from '@features/models/data/api';++import { ChakraProvider } from '@chakra-ui/react';+import { getFp8StorageSupportSnapshot } from '@features/models/data/fp8StorageSupportStore';+import { accountLifecycle } from '@platform/state/accountLifecycle';+import { system } from '@theme/system';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import type { DefaultSettingsModel } from './defaultSettingsFields';++import { DefaultSettingsSection } from './DefaultSettingsSection';++/**+ * The FP8 Storage row is shown only where the backend says the setting reaches the model.+ *+ * It used to be shown for every `main`, `controlnet` and `t2i_adapter` record, which offered it for 19+ * loader keys that ignore it -- a GGUF main model whose packed weights must never be re-encoded, a FLUX+ * ControlNet whose loader never casts. The answer now comes from the server, per `(base, type, format)`.+ */++const api = vi.hoisted(() => ({+ getFp8StorageSupport: vi.fn(),+ // The models store fetches on activation; stubbed so this test touches no network at all.+ getModelsDir: vi.fn(() => Promise.resolve('')),+ listMissingModels: vi.fn(() => Promise.resolve([])),+ listModels: vi.fn(() => Promise.resolve([])),+ updateModel: vi.fn(),+}));++// Spread over the real module rather than replacing it: the section pulls in the models store, which+// imports the rest of this transport module, and a bare replacement drops those exports.+vi.mock('@features/models/data/api', async (importOriginal) => ({+ ...(await importOriginal<typeof ModelsApi>()),+ ...api,+}));+// Interpolating rather than echoing the key: each row's switch is named+// `models.customizeDefaultField` with the field in it, so without this every switch on the panel has+// the same accessible name and none of them can be addressed by it.+vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string, values?: Record<string, string>) => (values ? `${key}:${Object.values(values).join(',')}` : key),+ }),+}));++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const FP8_LABEL = 'models.defaultFields.fp8Storage';+const PREPROCESSOR_LABEL = 'models.defaultFields.preprocessor';++const settingsModel = (overrides: Partial<DefaultSettingsModel>): DefaultSettingsModel =>+ ({+ base: 'flux',+ default_settings: null,+ format: 'checkpoint',+ key: 'model-key',+ type: 'main',+ ...overrides,+ }) as DefaultSettingsModel;++const row = (base: string, type: string, format: string, supported: boolean) => ({ base, format, supported, type });++const deferred = <T,>() => {+ let resolve!: (value: T) => void;+ const promise = new Promise<T>((resolvePromise) => {+ resolve = resolvePromise;+ });++ return { promise, resolve };+};++const labels = (host: HTMLElement): string[] =>+ [...host.querySelectorAll('p, span, div')].map((node) => node.textContent ?? '');++const showsFp8Row = (host: HTMLElement): boolean => labels(host).includes(FP8_LABEL);++describe('DefaultSettingsSection FP8 Storage row', () => {+ let host: HTMLDivElement;+ let root: Root;++ const render = async (model: DefaultSettingsModel) => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await act(() => {+ root.render(+ <ChakraProvider value={system}>+ <DefaultSettingsSection model={model} onError={vi.fn()} onSaved={vi.fn()} />+ </ChakraProvider>+ );+ });+ };++ beforeEach(() => {+ vi.resetModules();+ api.getFp8StorageSupport.mockReset();+ api.updateModel.mockReset();+ accountLifecycle.activate('fp8-row-test', ':user:fp8-row-test');+ // The store is a static import, so `resetModules` does not touch it -- only the account lifecycle+ // clears it. Asserted rather than assumed: if that stopped working, the later cells would inherit+ // the first one's table and pass for the wrong reason.+ expect(getFp8StorageSupportSnapshot()).toMatchObject({ byKey: null, status: 'idle' });+ });++ afterEach(async () => {+ await act(() => root.unmount());+ host.remove();+ accountLifecycle.invalidate();+ });++ it('shows the row for a model whose loader implements the cast', async () => {+ api.getFp8StorageSupport.mockResolvedValue([row('flux', 'main', 'checkpoint', true)]);++ await render(settingsModel({}));+ await act(async () => {+ await Promise.resolve();+ });++ expect(showsFp8Row(host)).toBe(true);+ });++ it('leaves it out for a FLUX ControlNet, whose loader never casts, and keeps the rest of the section', async () => {+ api.getFp8StorageSupport.mockResolvedValue([+ row('flux', 'main', 'checkpoint', true),+ row('flux', 'controlnet', 'checkpoint', false),+ ]);++ await render(settingsModel({ type: 'controlnet' }));+ await act(async () => {+ await Promise.resolve();+ });++ // Same base as the supported row above: this is the case a per-architecture answer cannot express.+ expect(showsFp8Row(host)).toBe(false);+ expect(labels(host)).toContain(PREPROCESSOR_LABEL);+ });++ it('leaves it out for a quantized main model', async () => {+ api.getFp8StorageSupport.mockResolvedValue([+ row('flux', 'main', 'checkpoint', true),+ row('flux', 'main', 'gguf_quantized', false),+ ]);++ await render(settingsModel({ format: 'gguf_quantized' }));+ await act(async () => {+ await Promise.resolve();+ });++ expect(showsFp8Row(host)).toBe(false);+ });++ it('waits for the table rather than showing a row it cannot vouch for', async () => {+ const request = deferred<ReturnType<typeof row>[]>();+ api.getFp8StorageSupport.mockReturnValue(request.promise);++ await render(settingsModel({}));++ // In flight: hidden, because a control that turns out to be inert is the defect being removed and+ // a control that appears a moment late is not.+ expect(showsFp8Row(host)).toBe(false);++ await act(async () => {+ request.resolve([row('flux', 'main', 'checkpoint', true)]);+ await request.promise;+ });++ // And it appears when the answer arrives, which is what the subscription is for.+ expect(showsFp8Row(host)).toBe(true);+ });++ it('saves the setting the row turns on', async () => {+ // The other cells only prove the row is rendered. Without this one the `Switch` could be deleted+ // from it and every assertion here would still pass, which is the same shape of defect as a+ // control that renders and does nothing.+ api.getFp8StorageSupport.mockResolvedValue([row('flux', 'main', 'checkpoint', true)]);+ api.updateModel.mockResolvedValue({ ...settingsModel({}), default_settings: { fp8_storage: true } });++ await render(settingsModel({}));+ await act(async () => {+ await Promise.resolve();+ });++ const fp8Switch = [...host.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')].find((input) =>+ input.closest('div')?.textContent?.includes(FP8_LABEL)+ );+ expect(fp8Switch, 'the FP8 Storage row renders no switch').toBeDefined();++ await act(async () => {+ fp8Switch!.click();+ await Promise.resolve();+ });+ const save = [...host.querySelectorAll('button')].find((button) => button.textContent === 'models.saveDefaults');+ await act(async () => {+ save!.click();+ await Promise.resolve();+ });++ expect(api.updateModel).toHaveBeenCalledWith(+ 'model-key',+ expect.objectContaining({ default_settings: expect.objectContaining({ fp8_storage: true }) }),+ expect.anything()+ );+ });++ it('asks the backend once, not once per model the user opens', async () => {+ api.getFp8StorageSupport.mockResolvedValue([row('flux', 'main', 'checkpoint', true)]);++ await render(settingsModel({}));+ await act(async () => {+ await Promise.resolve();+ });+ await act(() => root.unmount());+ host.remove();+ await render(settingsModel({ key: 'another-model' }));+ await act(async () => {+ await Promise.resolve();+ });++ expect(api.getFp8StorageSupport).toHaveBeenCalledTimes(1);+ });+});diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.tsxindex 6cef59fd1d..e0a5cf9e75 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/DefaultSettingsSection.tsx@@ -3,8 +3,14 @@ import type { AnyModelDefaultSettings } from '@features/models/core/types';import { createListCollection, Grid, HStack, Icon, NumberInput, Stack, Switch, Text } from '@chakra-ui/react';import { updateModel } from '@features/models/data/api';+import {+ ensureFp8StorageSupportLoaded,+ isFp8StorageSupported,+ useFp8StorageSupportSelector,+} from '@features/models/data/fp8StorageSupportStore';import { replaceModelInStore } from '@features/models/data/modelsStore';import { ModelSelect } from '@features/models/ui/components/ModelSelect';+import { useMountEffect } from '@platform/react/useMountEffect';import { useScopedAction } from '@platform/react/useScopedAction';import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';import { Button, Combobox, FieldLabel, Panel, Select } from '@platform/ui';@@ -150,7 +156,15 @@ export const DefaultSettingsSection = ({onSaved: () => void;}) => {const { t } = useTranslation();- const fields = useMemo(() => getFieldsForModel(model), [model]);+ // Whether FP8 Storage reaches this model depends on its format and on its loader, so the backend+ // answers it. Fetched here because this section is the only thing that asks, and the table is static+ // per backend build. While it is unknown the row stays hidden: a control that arrives a moment late+ // is better than one that does nothing.+ useMountEffect(() => {+ void ensureFp8StorageSupportLoaded();+ });+ const fp8StorageSupported = useFp8StorageSupportSelector((snapshot) => isFp8StorageSupported(snapshot, model));+ const fields = useMemo(() => getFieldsForModel(model, fp8StorageSupported), [fp8StorageSupported, model]);const [draft, setDraft] = useState<DefaultSettingsDraft>(() => ({modelKey: model.key,settings: { ...model.default_settings },diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsxindex 2ec8173e36..2095e63ca5 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx@@ -104,9 +104,16 @@ const selectModelIdentity = (snapshot: ModelsSnapshot, modelKey: string): ModelIconst selectDefaultSettingsModel = (snapshot: ModelsSnapshot, modelKey: string): DefaultSettingsModel | null => {const model = findModel(snapshot, modelKey);- // `base` is projected too: the FP8 storage default is unavailable for Z-Image.+ // `base` and `format` are projected too: together with the type they are the loader key the backend+ // answers the FP8 Storage question on, and all three parts change the answer.return model- ? { base: model.base, default_settings: model.default_settings, key: model.key, type: model.type }+ ? {+ base: model.base,+ default_settings: model.default_settings,+ format: model.format,+ key: model.key,+ type: model.type,+ }: null;};diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.test.ts b/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.test.tsindex a936583e1e..074d71d960 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.test.ts+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.test.ts@@ -2,38 +2,13 @@ import type { ModelConfig } from '@features/models/core/types';import { describe, expect, it } from 'vitest';-import { getFieldsForModel, supportsFp8Storage, validateDefaults } from './defaultSettingsFields';+import { getFieldsForModel, validateDefaults } from './defaultSettingsFields';const model = (base: string, type: string): Pick<ModelConfig, 'base' | 'type'> =>({ base, type }) as Pick<ModelConfig, 'base' | 'type'>;-const fieldKeys = (candidate: Pick<ModelConfig, 'base' | 'type'>): string[] =>- getFieldsForModel(candidate).map((field) => String(field.key));--describe('supportsFp8Storage', () => {- it('offers the toggle for main models', () => {- // Expose Z-Image FP8 defaults so installed settings can be inspected and disabled.- for (const base of ['sdxl', 'flux', 'krea-2', 'qwen-image', 'wan', 'ideogram-4', 'z-image']) {- expect(supportsFp8Storage(model(base, 'main'))).toBe(true);- }- });-- it('hides it for LoRA and ControlLoRA, which are patched rather than run', () => {- // The casting hooks would never fire, so the toggle would be silently ignored.- expect(supportsFp8Storage(model('sdxl', 'lora'))).toBe(false);- expect(supportsFp8Storage(model('sdxl', 'control_lora'))).toBe(false);- });-- it('offers it for the control adapters the backend does cast', () => {- expect(supportsFp8Storage(model('sdxl', 'controlnet'))).toBe(true);- expect(supportsFp8Storage(model('sdxl', 't2i_adapter'))).toBe(true);- });-- it('hides it for VAEs', () => {- // fp8 storage measurably degrades decode quality, so the backend excludes VAEs outright.- expect(supportsFp8Storage(model('sdxl', 'vae'))).toBe(false);- });-});+const fieldKeys = (candidate: Pick<ModelConfig, 'base' | 'type'>, fp8StorageSupported = true): string[] =>+ getFieldsForModel(candidate, fp8StorageSupported).map((field) => String(field.key));describe('getFieldsForModel', () => {it('appends fp8_storage to the main-model fields without disturbing the existing ones', () => {@@ -62,7 +37,16 @@ describe('getFieldsForModel', () => {});it('gives a ControlLoRA the preprocessor only', () => {- expect(fieldKeys(model('sdxl', 'control_lora'))).toEqual(['preprocessor']);+ // Not decided here any more: the backend's table has no `supported` row for a control LoRA, since+ // it is patched into a base model and the casting hooks would never fire.+ expect(fieldKeys(model('sdxl', 'control_lora'), false)).toEqual(['preprocessor']);+ });++ it('leaves the row out entirely when the backend says FP8 Storage does nothing for this model', () => {+ // The whole point of the change: a FLUX ControlNet, a GGUF main model or a model whose loader never+ // casts must not be offered a control that silently does nothing.+ expect(fieldKeys(model('flux', 'controlnet'), false)).toEqual(['preprocessor']);+ expect(fieldKeys(model('flux', 'main'), false)).not.toContain('fp8_storage');});});diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.ts b/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.tsindex e6db84d7e3..8b7c2a7a60 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.ts+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/defaultSettingsFields.ts@@ -3,7 +3,7 @@ import type { TFunction } from 'i18next';import { loraDefaultSettingsSchema, mainDefaultSettingsSchema } from '@features/models/core/schemas';-export type DefaultSettingsModel = Pick<ModelConfig, 'base' | 'default_settings' | 'key' | 'type'>;+export type DefaultSettingsModel = Pick<ModelConfig, 'base' | 'default_settings' | 'format' | 'key' | 'type'>;const CONTROL_ADAPTER_TYPES = new Set(['controlnet', 't2i_adapter', 'control_lora']);@@ -200,12 +200,14 @@ const CONTROL_ADAPTER_FIELDS: FieldSpec[] = [},];-/** Exclude LoRA/ControlLoRA: patched weights lack their own forward hooks. VAEs have no defaults section. */-export const supportsFp8Storage = (model: Pick<ModelConfig, 'base' | 'type'>): boolean =>- model.type === 'main' || model.type === 'controlnet' || model.type === 't2i_adapter';--export const getFieldsForModel = (model: Pick<ModelConfig, 'base' | 'type'>): FieldSpec[] => {- const fp8Fields = supportsFp8Storage(model) ? [FP8_STORAGE_FIELD] : [];+/**+ * `fp8StorageSupported` is the backend's answer (see `data/fp8StorageSupportStore`), not a rule applied+ * here. It used to be `type === 'main' || 'controlnet' || 't2i_adapter'`, which offered the control for+ * 19 of the 52 loader keys that ignore it: the answer also depends on the model's format, and on+ * whether its loader implements the cast at all — neither of which this module can see.+ */+export const getFieldsForModel = (model: Pick<ModelConfig, 'type'>, fp8StorageSupported: boolean): FieldSpec[] => {+ const fp8Fields = fp8StorageSupported ? [FP8_STORAGE_FIELD] : [];if (model.type === 'main') {return [...MAIN_FIELDS, ...fp8Fields];