Views
No views yet
1from transformers import (
2 AutoConfig,
3 AutoProcessor,
4 AutoTokenizer,
5 DiffusionGemmaGenerationConfig,
6 DiffusionGemmaForBlockDiffusion,
7)
8
9MODEL_ID = "Intel/diffusiongemma-26B-A4B-it-int4-AutoRound"
10
11config = AutoConfig.from_pretrained(MODEL_ID)
12processor = AutoProcessor.from_pretrained(MODEL_ID)
13tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
14
15gen_config = DiffusionGemmaGenerationConfig.from_pretrained(MODEL_ID)
16
17model = DiffusionGemmaForBlockDiffusion.from_pretrained(
18 MODEL_ID,
19 device_map="auto",
20 dtype="auto",
21 trust_remote_code=False,
22)
23
24model.eval()
25
26messages = [{"role": "user", "content": "Why is the sky blue?"}]
27input_ids = tokenizer.apply_chat_template(
28 messages, tokenize=True, return_dict=True, return_tensors="pt", add_generation_prompt=True
29).to(model.device)
30
31output = model.generate(**input_ids, max_new_tokens=256)
32response = tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True)
33print(response)1vllm serve Intel/diffusiongemma-26B-A4B-it-int4-AutoRound --port 8088 --gpu-memory-utilization 0.75
2curl http://localhost:8088/v1/chat/completions -H "Content-Type: application/json" -d '{
3 "messages": [{"role": "user", "content": "Why is the sky blue?"}],
4 "max_tokens": 256,
5 "temperature": 1.0
6 }'
7{"id":"chatcmpl-a307153d4590a1f3","object":"chat.completion","created":1782479268,"model":"Intel/diffusiongemma-26B-A4B-it-int4-AutoRound","choices":[{"index":0,"message":{"role":"assistant","content":"The sky is blue because of a phenomenon called **Rayleigh scattering**.\n\nHere is the step-by-step breakdown of why this happens:\n\n### 1. Sunlight is made of all colors\nEven though sunlight looks white to us, it is actually made up of all the colors of the rainbow: red, orange, yellow, green, blue, indigo, and violet. Each color travels as a wave with a different **wavelength**.\n* **Red light** has long, lazy waves.\n* **Blue and violet light** have short, choppy waves.\n\n### 2. The atmosphere acts as an obstacle\nEarth is surrounded by an atmosphere filled with nitrogen and oxygen gases. When sunlight enters the atmosphere, it hits these gas molecules and scat in all directions.\n\n### 3. Short waves scatter more\nBecause red and yellow light have long wavelengths, they pass through the atmosphere mostly without hitting anything. However, because **blue travels travels in shorter waves**, it crashes into the gas molecules and gets \"scattered\" in every direction. \n\n### 4. Our eyes see blue\nBecause the blue light is being scattered everywhere in the upper atmosphere, when you look up, your eyes are catching all that scattered blue light coming from every","refusal":null,"annotations":null,"audio":null,"function_call":null,"reasoning":null},"logprobs":null,"finish_reason":"length","stop_reason":null,"token_ids":null,"routed_experts":null}],"service_tier":null,"system_fingerprint":"vllm-0.23.1rc1.dev418+g6e3a983cf-ba5bc09d","usage":{"prompt_tokens":19,"total_tokens":275,"completion_tokens":256,"prompt_tokens_details":null},"prompt_logprobs":null,"prompt_token_ids":null,"prompt_text":null,"kv_transfer_params":null}auto-round-best --model /models/diffusiongemma-26B-A4B-it/ --scheme "W4A16" --group_size 64 --output_dir ./diffusiongemma_int4/