Better HN
topnewbestaskshowjobs
Log inSign up

hauntsaninja

424 karma · joined May 9, 2020 (6y ago) · 39 submissions

Submissions

comment 1w ago · link · parent

An intuitive way of thinking about perplexity is that it is the number of options a model is considering for the next token.

Note the best case is not actually zero. If your model had zero log(perplexity) on "A random number from 1 to 10 is ___" it's not doing something useful. See the "Unknown floor" part of the original post.

In practice it is possible to get estimates for the floor assuming your current methodology, for example see Section 6.3 from Scaling Laws for Neural Language Models (2020)

comment 8mo ago · link · parent

I don't yet know a better way to do this than using a threshold!

I think if you assume perf is normally distributed, you can still get some of the math to work out. But I will need to think more about this... if I ever choose this adventure, I'll post an update on https://github.com/hauntsaninja/git_bayesect/issues/25

(I really enjoy how many generalisations there are of this problem :-) )

comment 8mo ago · link · parent

Note that "pick the commit with best expected information gain" in git_bayesect isn't optimal even in the no overhead regime. I provide a counterexample in the writeup, which implies ajb's heuristic is also not optimal. I don't see a tractable way to compute the optimal policy.

One idea: if you always spend time testing equal to your constant overhead, I think you're guaranteed to be not more than 2x off optimal.

(and agreed with ajb on "just use ccache" in practice!)

comment 8mo ago · link · parent

Yep, you can run bayesect to an arbitrary confidence level.

This script in the repo https://github.com/hauntsaninja/git_bayesect/blob/main/scrip... will show you that a) the confidence level is calibrated, b) how quickly you get to that confidence level (on average, p50 and p95)

For the failure rates you describe, calibration.py shows that you should see much higher accuracy at 300 tests

comment 8mo ago · link · parent

That sounds right. `git_bayesect` currently uses `--first-parent`, so I think belden's use case should work, but I haven't tested it much on complicated git histories.

comment 8mo ago · link · parent

Yes! It will show you the posterior probability as a single commit starts to become more likely. In addition, running `git bayesect status` will show you all posterior probabilities

comment 8mo ago · link · parent

Yay, I had fun with it too!

IIUC the way you'd do that right now is just repeatedly recording the individual observations on a single commit, which effectively gives it a probability + the number of trials to do the Beta update. I don't yet have a CLI entrypoint to record a batch observation of (probability, num_trials), but it would be easy to add one

But ofc part of the magic is that git_bayesect's commit selection tells you how to be maximally sample efficient, so you'd only want to do a batch record if your test has high constant overhead

comment 8mo ago · link · parent

git bisect works great for tracking down regressions, but relies on the bug presenting deterministically. But what if the bug is non-deterministic? Or worse, your behaviour was always non-deterministic, but something has changed, e.g. your tests went from somewhat flaky to very flaky.

In addition to the repo linked in the title, I also wrote up a little bit of the math behind it here: https://hauntsaninja.github.io/git_bayesect.html

9.

Show HN: Git bayesect – Bayesian Git bisection for non-deterministic bugs(github.com ↗)

337 points · by hauntsaninja · 8mo ago · 43 comments

comment 9mo ago · link · parent

Reasoning effort is denominated in tokens, not time, so no difference beyond slowness at heavy load

(I work at OpenAI)

comment 11mo ago · link · parent

Yes, uv skipping this step is a one time significant hit to start up time. E.g. if you're building a Dockerfile I'd recommend setting `--compile-bytecode` / `UV_COMPILE_BYTECODE`

comment 11mo ago · link · parent

Unknown has the exact same type system semantics as Any.

Unknown is a pyright specific term for inferred Any that is used as the basis for enabling additional diagnostics prohibiting gradual typing.

Notably, this is quite different from TypeScript’s unknown, which is type safe.

comment 11mo ago · link · parent

I’ve added ecosystem regression checks to every Python type checker and typeshed via https://github.com/hauntsaninja/mypy_primer. This helped a tonne with preventing unintended or overly burdensome regressions in mypy, so glad to hear upgrades are less of an Event for you

comment 11mo ago · link · parent

The conformance test suite is currently mostly focused on “what does an explicit type annotation mean”

A shared spec for this is important because if you write a Python library, you don’t want to have to write a different set of types for each Python type checker

Here are some things the spec has nothing to say about:

Inference

You don’t want to annotate every expression in your program. Type checkers have a lot of leeway here and this makes a huge difference to what it feels like to use a type checker.

For instance, mypy will complain about the following, but pyright will not (because it infers the types of unannotated collections as having Any):

  x = []
  x.append(1)
  x[0] + "oops"
The spec has nothing to say about this.

Diagnostics

The spec has very little to say about what a type checker should do with all the information it has. Should it complain about unreachable code? Should it complain if you did `if foo` instead of `if foo()` because it’s always true? The line between type checker and linter is murky. Decisions here have nothing to do with “what does this annotation mean”, so are mostly out of scope from the spec.

Configuration

This makes a huge difference when adapting huge codebases to different levels of type checking. Also the defaults really matter, which can be tricky when Python type checkers serve so many different audiences.

Other things the spec doesn’t say anything about: error messages quality, editor integration, speed, long tail of UX issues, implementation of new type system features, plugins, type system extensions or special casing

And then of course there are things we would like to spec but haven’t yet!

comment 11mo ago · link · parent

Mentioned this in another comment, but the spec conformance suite is not representative of the things users care about (nor is it meant to be).

The spec mostly concerns itself with the semantics of annotations, not diagnostics or inference. I don't really recommend using it as the basis for choosing a type checker.

(I was on the Python Typing Council and helped put together the spec, the conformance test suite, etc)

comment 11mo ago · link · parent

Note: while spec conformance is important, I don't recommend using it as the basis for choosing a type checker. It is not representative of the things that most users actually care about (and is not meant to be).

(I was on the Python Typing Council and helped put together the spec, the conformance test suite, etc)

comment 1y ago · link · parent

pyright will accept this. mypy should accept this when using --allow-redefinition-new as well

comment 1y ago · link · parent

text-davinci-001 is just not GPT-3 in any real sense

(I work at OpenAI, I helped build this page and helped train text-davinci-001)

comment 1y ago · link · parent

Note that `uvx mypy` may give you inaccurate timings on macOS. The antivirus in macOS goes a little crazy the first time it executes a mypyc compiled program.

comment 1y ago · link · parent

We had so many of these issues that we ended up LD_PRELOAD-ing patch getenv / setenv / putenv

comment 1y ago · link · parent

Yeah, that's not exactly the problematic situation... but the good news is I improved the Python's error message for this in 3.13. See https://docs.python.org/3/whatsnew/3.13.html#improved-error-...

comment 2y ago · link · parent

You don't need to use pytz, you can use the following on all Python 3: tz_UTC = datetime.timezone.utc

comment 2y ago · link · parent

Lean heavier on a mypy config file. Make heavy use of per-module configuration, in particular, setting per-module ignore_errors = true for modules you’re not yet ready to type check.

See https://mypy.readthedocs.io/en/stable/existing_code.html for some more advice.

24.

Crashing CPython with Recursion(hauntsaninja.github.io ↗)

3 points · by hauntsaninja · 3y ago · discuss

comment 4y ago · link · parent

In Python 3.11, you can use the "-P" flag or the "PYTHONSAFEPATH" environment variable to avoid adding cwd to sys.path

https://docs.python.org/3.11/whatsnew/3.11.html#summary-rele...

comment 4y ago · link · parent

You can use numpy just fine. Unlike Cython, mypyc doesn’t give you a way of accessing numpy’s C API (because you’re basically just writing Python code).

comment 4y ago · link · parent

mypy compiles itself with mypyc, for about a 3.5-4x speed up. black very recently started shipping mypyc compiled binaries, for about a 2x speed up (iirc).

comment 4y ago · link · parent

mypyc has escape hatches, e.g. casting to Any is a common trick.

comment 4y ago · link · parent

I wrote a similar tool a while back. My solution for this was to statically analyse the input to discover unused names. The cool part of doing transformations statically is that you're able to see the exact Python code you'd run without running it, e.g. `pyp --explain x[:5]`. https://github.com/hauntsaninja/pyp

comment 4y ago · link · parent

I wrote a similar tool a while back that lets you create your own "magic" variables. I use `f` all the time! https://github.com/hauntsaninja/pyp#pyp-lets-you-configure-y...
12