メインコンテンツへスキップ
見出し画像

Hy3 動いた

    まとめ

    Hy3 (295B-A21B) が動いた。それだけ。
    このマシンでの生成速度は 6 t/s 程度。
    インベーダーゲームを作ったら遊べた。日本語も悪くない。

    1 ビット量子化でも、タスクによっては、日本語で、まともに使えるのかもしれない。(使えないかもしれない。
    この環境だと生成速度が実用的ではなかった。

    モデル

    IQ1_M が今回の対象。(AngelSlim は 2ヶ月前くらいにも触ったな、

    llama.cpp

    これを試した2026年7月14日現在の master ブランチでは動かなかった。
    次の修正を行うことで動くようになった。

    $ git diff src/models/hy-v3.cpp
    diff --git a/src/models/hy-v3.cpp b/src/models/hy-v3.cpp
    index 47a0beaf2..520a24edd 100644
    --- a/src/models/hy-v3.cpp
    +++ b/src/models/hy-v3.cpp
    @@ -65,7 +65,7 @@ void llama_model_hy_v3::load_arch_tensors(llama_model_loader & ml) {
    
             // MoE routed experts (sigmoid router + expert selection bias)
             layer.ffn_gate_inp    = create_tensor(tn(LLM_TENSOR_FFN_GATE_INP,    "weight", i), {n_embd, n_expert}, TENSOR_NOT_REQUIRED);
    -        layer.ffn_exp_probs_b = create_tensor(tn(LLM_TENSOR_FFN_EXP_PROBS_B,           i), {n_expert}, TENSOR_NOT_REQUIRED);
    +        layer.ffn_exp_probs_b = create_tensor(tn(LLM_TENSOR_FFN_EXP_PROBS_B,   "bias", i), {n_expert}, TENSOR_NOT_REQUIRED);
             layer.ffn_down_exps   = create_tensor(tn(LLM_TENSOR_FFN_DOWN_EXPS,   "weight", i), {n_ff_exp, n_embd, n_expert}, TENSOR_NOT_REQUIRED);
             create_tensor_gate_up_exps(layer, i, n_embd, n_ff_exp, n_expert, TENSOR_NOT_REQUIRED);

    実行

    CUDA_VISIBLE_DEVICES=0 \
    llama-server -hf AngelSlim/Hy3-GGUF:IQ1_M \
      -c 4096 --n-cpu-moe 76  -fa on \
      --spec-type draft-mtp --spec-draft-n-max 3 --spec-draft-n-min 1 \
      -ctk q8_0 -ctv q8_0 -ctkd q8_0 -ctvd q8_0

    インベーダーゲームを index.html のみで作成して

    生成結果

    以下は、1 つの index.html だけで動くインベーダー風ゲームです。
    JavaScript・CSS もすべてこのファイルに内包しています。

    <!DOCTYPE html>
    <html lang="ja">
    <head>
    <meta charset="UTF-8">
    <title>Invader Game</title>
    <style>
      html,body{margin:0;background:#000;color:#fff;font-family:monospace;text-align:center;}
      canvas{display:block;margin:10px auto;border:2px solid #444;}
      p{margin:6px;}
    </style>
    </head>
    <body>
    <h2>INVADER</h2>
    <p>左:← 右:→ 射撃:スペース</p>
    <canvas id="c" width="400" height="300"></canvas>
    <script>
    const cv = document.getElementById('c');
    const ctx = cv.getContext('2d');
    
    // プレイヤー
    const player = { x: 180, y: 270, w: 20, h: 10, speed: 4 };
    // 弾
    let bullets = [];
    // 敵
    let enemies = [];
    for (let y = 0; y < 4; y++) {
      for (let x = 0; x < 10; x++) {
        enemies.push({ x: 30 + x * 34, y: 30 + y * 30, w: 20, h: 14, alive: true });
      }
    }
    let enemyDir = 1;
    let enemySpeed = 1;
    
    // キー
    const keys = {};
    document.addEventListener('keydown', e => {
      keys[e.key] = true;
      if (e.key === ' ') {
        bullets.push({ x: player.x + player.w/2 - 2, y: player.y, w: 4, h: 10 });
      }
    });
    document.addEventListener('keyup', e => keys[e.key] = false);
    
    function update() {
      // プレイヤー移動
      if (keys['ArrowLeft']) player.x -= player.speed;
      if (keys['ArrowRight']) player.x += player.speed;
      if (player.x < 0) player.x = 0;
      if (player.x > cv.width - player.w) player.x = cv.width - player.w;
    
      // 弾
      bullets.forEach(b => b.y -= 6);
      bullets = bullets.filter(b => b.y > 0);
    
      // 敵移動
      let hitEdge = false;
      enemies.forEach(e => {
        e.x += enemyDir * enemySpeed;
        if (e.x < 0 || e.x > cv.width - e.w) hitEdge = true;
      });
      if (hitEdge) {
        enemyDir *= -1;
        enemies.forEach(e => e.y += 10);
      }
    
      // 弾と敵
      bullets.forEach(b => {
        enemies.forEach(e => {
          if (e.alive &&
              b.x < e.x + e.w && b.x + b.w > e.x &&
              b.y < e.y + e.h && b.y + b.h > e.y) {
            e.alive = false;
            b.y = -100;
          }
        });
      });
      enemies = enemies.filter(e => e.alive);
    }
    
    function draw() {
      ctx.clearRect(0, 0, cv.width, cv.height);
    
      // プレイヤー
      ctx.fillStyle = '#0f0';
      ctx.fillRect(player.x, player.y, player.w, player.h);
    
      // 弾
      ctx.fillStyle = '#ff0';
      bullets.forEach(b => ctx.fillRect(b.x, b.y, b.w, b.h));
    
      // 敵
      ctx.fillStyle = '#f00';
      enemies.forEach(e => ctx.fillRect(e.x, e.y, e.w, e.h));
    
      if (enemies.length === 0) {
        ctx.fillStyle = '#fff';
        ctx.fillText('YOU WIN!', 160, 150);
      }
    }
    
    function loop() {
      update();
      draw();
      requestAnimationFrame(loop);
    }
    loop();
    </script>
    </body>
    </html>

    遊び方
    1. 上記を index.html として保存
    2. ブラウザで開く
    3. ← → で移動、スペース で弾を発射
    敵を全部倒せば YOU WIN! と表示されます。
    必要に応じて難易度やグラフィックを追加できます。

    必要最低限だが、遊べるものは作ってくれた。

    画像

    生成速度

    プロンプト処理

    • 10.28 tokens per second

    テキスト生成

    • 6.35 tokens per second

    検証マシン


    あなたへのおすすめ