google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.59k stars 5.16k forks source link

mediapipe/tasks-genai for web uses a Deprecated function "requestAdapterInfo" caused failed to run with new Chrome Browser #5720

Closed kdshk closed 6 days ago

kdshk commented 1 week ago

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

None

OS Platform and Distribution

Windows 11, Chrome V130

Mobile device if the issue happens on mobile device

No response

Browser and version if the issue happens on browser

Version 132.0.6807.0 (Official Build)

Programming Language and version

javascript

MediaPipe version

0.10.18

Bazel version

No response

Solution

mediapipe/tasks-genai

Android Studio, NDK, SDK versions (if issue is related to building in Android environment)

No response

Xcode & Tulsi version (if issue is related to building for iOS)

No response

Describe the actual behavior

exception when call LlmInference.createFromOptions TypeError: a.requestAdapterInfo is not a functio

Describe the expected behaviour

should be success initialize the genAI task

Standalone code/steps you may have used to try to get what you need

javascript throw exception when call createFromOptions with error information "TypeError: a.requestAdapterInfo is not a function"
await LlmInference.createFromOptions(genaiFileset, {
                baseOptions: {
                    modelAssetPath: this.modelPath
                },
                maxTokens: 32000,
                topK: 40,
                temperature: 0.8,
                randomSeed: 101,
                loraRanks: [4, 8, 16, 64]
            });

Other info / Complete Logs

sidepanel-BtA2uG1z.js:10 Experimental Chromium WGSL subgroup support detected. Enabling this feature in the inference engine.
la @ sidepanel-BtA2uG1z.js:10Understand this warningAI
sidepanel-BtA2uG1z.js:18 TypeError: a.requestAdapterInfo is not a function
    at Sn.Z (sidepanel-BtA2uG1z.js:10:49854)
    at async He.createFromOptions (sidepanel-BtA2uG1z.js:11:6585)
    at async I8.initialize (sidepanel-BtA2uG1z.js:18:224)
    at async W8.initialize (sidepanel-BtA2uG1z.js:18:184835)
kuaashish commented 1 week ago

Hi @kdshk,

Could you please share the exact steps you are following from our documentation? This will help us understand the issue more clearly and assist you better.

Thank you!!

kdshk commented 1 week ago

Hi @kdshk,

Could you please share the exact steps you are following from our documentation? This will help us understand the issue more clearly and assist you better.

Thank you!!

Hi I followed the sample here "https://ai.google.dev/edge/mediapipe/solutions/genai/llm_inference/web_js" and used "npm install @mediapipe/tasks-genai" to import gen ai library. Referred the sample code to initialize LlmInference, then the Chrome browser(132.0.6807.0). throw the error "TypeError: a.requestAdapterInfo is not a function". After visit "https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/requestAdapterInfo" it seems requestAdapterInfo is "Deprecated" while @mediapipe/tasks-genai (0.10.18) is still using it. Simply uses the new info object in GPUAdapter manually can have this issue patched.

const genai = await FilesetResolver.forGenAiTasks( // path/to/wasm/root "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-genai@latest/wasm" ); llmInference = await LlmInference.createFromOptions(genai, { baseOptions: { modelAssetPath: '/assets/gemma-2b-it-gpu-int4.bin' }, maxTokens: 1000, topK: 40, temperature: 0.8, randomSeed: 101 });

kuaashish commented 6 days ago

Hi @schmidt-sebastian,

Could you please look into this issue?

Thank you!!

schmidt-sebastian commented 6 days ago

We merged a fix for this on Oct31 (https://github.com/google-ai-edge/mediapipe/commit/ba4b77058947def6c20efed3eb789f51775f1ee4), but unfortunately our Web release was cut on Oct 28th.

You should be able to use the latest nightly: https://www.npmjs.com/package/@mediapipe/tasks-genai/v/0.10.18-rc.20241108

google-ml-butler[bot] commented 6 days ago

Are you satisfied with the resolution of your issue? Yes No