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(ui): wire MiniMax H3 LoRAs into the linear-view graph builder
Lincoln Steind3415f1898fc
diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/generation/addMiniMaxH3LoRAs.ts b/invokeai/frontend/web/src/features/nodes/util/graph/generation/addMiniMaxH3LoRAs.tsnew file mode 100644index 0000000000..b26e26a7ed--- /dev/null+++ b/invokeai/frontend/web/src/features/nodes/util/graph/generation/addMiniMaxH3LoRAs.ts@@ -0,0 +1,65 @@+import type { RootState } from 'app/store/store';+import { getPrefixedId } from 'features/controlLayers/konva/util';+import { zModelIdentifierField } from 'features/nodes/types/common';+import type { Graph } from 'features/nodes/util/graph/generation/Graph';+import type { Invocation, S } from 'services/api/types';++/**+ * Add MiniMax H3 LoRA wiring to the graph between the model loader and the+ * denoise node.+ *+ * Each enabled H3 LoRA becomes a ``lora_selector`` feeding a ``collect``+ * node, which fans into a ``minimax_h3_lora_collection_loader`` that rewrites+ * the model loader's transformer output with the ``loras`` list populated.+ * There is no variant/expert routing (H3 has a single fl2va transformer);+ * the backend loader re-validates every LoRA's base server-side.+ */+export const addMiniMaxH3LoRAs = (+ state: RootState,+ g: Graph,+ denoise: Invocation<'minimax_h3_denoise'>,+ modelLoader: Invocation<'minimax_h3_model_loader'>+): void => {+ const enabledLoRAs = state.loras.loras.filter((l) => l.isEnabled && l.model.base === 'minimax-h3');++ if (enabledLoRAs.length === 0) {+ return;+ }++ const loraMetadata: S['LoRAMetadataField'][] = [];++ const loraCollector = g.addNode({+ id: getPrefixedId('lora_collector'),+ type: 'collect',+ });+ const loraCollectionLoader = g.addNode({+ type: 'minimax_h3_lora_collection_loader',+ id: getPrefixedId('minimax_h3_lora_collection_loader'),+ });++ g.addEdge(loraCollector, 'collection', loraCollectionLoader, 'loras');+ g.addEdge(modelLoader, 'transformer', loraCollectionLoader, 'transformer');+ g.deleteEdgesTo(denoise, ['transformer']);+ g.addEdge(loraCollectionLoader, 'transformer', denoise, 'transformer');++ for (const lora of enabledLoRAs) {+ const { weight } = lora;+ const parsedModel = zModelIdentifierField.parse(lora.model);++ const loraSelector = g.addNode({+ type: 'lora_selector',+ id: getPrefixedId('lora_selector'),+ lora: parsedModel,+ weight,+ });++ loraMetadata.push({+ model: parsedModel,+ weight,+ });++ g.addEdge(loraSelector, 'lora', loraCollector, 'item');+ }++ g.upsertMetadata({ loras: loraMetadata });+};diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.tsindex 852118de84..3e397d8291 100644--- a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts+++ b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts@@ -7,6 +7,7 @@ import { isMiniMaxH3ReferenceImageConfig } from 'features/controlLayers/store/tyimport { getGlobalReferenceImageWarnings } from 'features/controlLayers/store/validators';import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';import { zImageField } from 'features/nodes/types/common';+import { addMiniMaxH3LoRAs } from 'features/nodes/util/graph/generation/addMiniMaxH3LoRAs';import { addNSFWChecker } from 'features/nodes/util/graph/generation/addNSFWChecker';import { addTextToImage } from 'features/nodes/util/graph/generation/addTextToImage';import { addWatermarker } from 'features/nodes/util/graph/generation/addWatermarker';@@ -129,6 +130,10 @@ export const buildMiniMaxH3Graph = async (arg: GraphBuilderArg): Promise<GraphBug.addEdge(posCond, 'conditioning', denoise, 'positive_conditioning');g.addEdge(seed, 'value', denoise, 'seed');+ // H3 LoRAs (e.g. the Turbo step-distillation LoRA) rewire the transformer edge through a+ // collection loader. Works with both the folder transformer and the single-file overrides.+ addMiniMaxH3LoRAs(state, g, denoise, modelLoader);+g.upsertMetadata({model: Graph.getModelMetadataField(modelConfig),steps,