Skip to content

add aitk webgpu#401

Draft
xieofxie wants to merge 21 commits into
mainfrom
hualxie/webgpu
Draft

add aitk webgpu#401
xieofxie wants to merge 21 commits into
mainfrom
hualxie/webgpu

Conversation

@xieofxie
Copy link
Copy Markdown
Contributor

@xieofxie xieofxie commented May 7, 2026

need patch utf-8 ?

        import builtins
        import os
        import olive
        import olive.workflows

        # PYTHONUTF8=1 is not honoured by the Python-WebGPU launcher because
        # the env var must be read by the actual CPython binary at startup, and
        # the WebGPU runtime delegates to a uv-managed CPython that never sees it.
        # Patch builtins.open for the duration of the Olive call so any text file
        # opened without an explicit encoding (e.g. chat_template.jinja in
        # transformers) uses UTF-8 instead of the Windows default (cp1252).
        _original_open = builtins.open

        def _utf8_open(file, mode="r", *args, **kwargs):
            if "b" not in mode and "encoding" not in kwargs:
                kwargs["encoding"] = "utf-8"
            return _original_open(file, mode, *args, **kwargs)

        builtins.open = _utf8_open
        try:
            output = olive.workflows.run(oliveJson)
        finally:
            builtins.open = _original_open
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(path)

will fail for ds

need patch model ?

will fail for ds, llama, qwen

model = og.Model(model_folder)
      6 tokenizer = og.Tokenizer(model)
      7 tokenizer_stream = tokenizer.create_stream()
      8 

RuntimeError: Node (/model/layers.2/attn/o_proj/MatMulNBits) Op (MatMulNBits) [ShapeInferenceError] Incompatible dimensions for matrix multiplication

from onnx import helper
import sys
import json
from pathlib import Path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant