anthropics / anthropics/original_performance_takehome

Two potential bugs in build_mem_image in problem.py

オープン
#10 コメント 2 件 リアクション 13 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
4.2k
フォーク
950
PR マージ指標
30日以内にマージされた PR はありません

説明

Found while working through the take-home challenge. Two issues in build_mem_image:

1. Line 498: Likely typo in pointer calculation

Current:
inp_values_p = inp_indices_p + len(inp.values) # should be len(inp.indices)

Should be:
inp_values_p = inp_indices_p + len(inp.indices)

Currently works by accident since len(inp.indices) == len(inp.values) == batch_size, but the intent appears to be indices + len(indices) = values_start.

2. Line 512: Slice assignment truncates allocated extra room

Current:
mem[inp_values_p:] = inp.values # truncates list

The function allocates extra room on lines 492-494:
extra_room = len(t.values) + len(inp.indices) * 2 + VLEN * 2 + 32
mem = [0] * (header + len(t.values) + len(inp.indices) + len(inp.values) + extra_room)

But mem[inp_values_p:] = inp.values replaces everything from inp_values_p to end, discarding the extra room. Python slice assignment shrinks the list when the replacement is shorter than the slice.

Should be:
mem[inp_values_p:inp_values_p + len(inp.values)] = inp.values

Additionally, mem[7] = extra_room on line 508 gets immediately overwritten by mem[header:inp_indices_p] = t.values on line 510 (since header = 7), so the extra_room pointer is never actually accessible from the header.

Not blocking for the challenge (computed extra_room_p at runtime as inp_values_p + batch_size), but figured worth flagging.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。