Skip to content

Geometry of Truth tutorial uses pandas with remote models, but pandas is not whitelisted #536

@marthaflinderslewis

Description

@marthaflinderslewis

Running the Geometry of truth tutorial up to the following cell gives the error that pandas is not whitelisted. I can rewrite to not use pandas, but is there any plan to allow the use of pandas?

import torch

PROMPT_TEMPLATE = """The city of Tokyo is in Japan. This statement is: TRUE
The city of Hanoi is in Poland. This statement is: FALSE
{statement} This statement is:"""

LAYER = 20
punctuation_token_id = model.tokenizer('.').input_ids[1] # extract activation over "."

true_activations = []
false_activations = []
with model.session(remote=True) as session:
  for i in range(df.shape[0]):
    row = df.iloc[i]
    prompt = PROMPT_TEMPLATE.format(statement=row.statement)
    prompt_token_ids = model.tokenizer(prompt).input_ids
    punctuation_index = rindex(prompt_token_ids, punctuation_token_id) - 1

    with model.trace(prompt):
      activation = model.model.layers[LAYER].output[0][:, punctuation_index, :].save()
    if row.label == 0:
      false_activations.append(activation)
    else:
      true_activations.append(activation)

clear_output()

true_activations = torch.cat(true_activations)
false_activations = torch.cat(false_activations)

true_activations.shape, false_activations.shape

gives the following output and error:

[2025-10-05 17:18:43] [67dc0c6a-65ed-4755-962a-4675f97730c6] RECEIVED   : Your job has been received and is waiting to be queued.
INFO:nnsight_remote:[67dc0c6a-65ed-4755-962a-4675f97730c6] RECEIVED   : Your job has been received and is waiting to be queued.
[2025-10-05 17:18:43] [67dc0c6a-65ed-4755-962a-4675f97730c6] QUEUED     : Your job has been recieved by the coordinator and is waiting to be queued.
INFO:nnsight_remote:[67dc0c6a-65ed-4755-962a-4675f97730c6] QUEUED     : Your job has been recieved by the coordinator and is waiting to be queued.
[2025-10-05 17:18:43] [67dc0c6a-65ed-4755-962a-4675f97730c6] QUEUED     : Task 67dc0c6a-65ed-4755-962a-4675f97730c6 has been added to the queue. Currently at position 1
INFO:nnsight_remote:[67dc0c6a-65ed-4755-962a-4675f97730c6] QUEUED     : Task 67dc0c6a-65ed-4755-962a-4675f97730c6 has been added to the queue. Currently at position 1
[2025-10-05 17:18:43] [67dc0c6a-65ed-4755-962a-4675f97730c6] DISPATCHED : Dispatching task...
INFO:nnsight_remote:[67dc0c6a-65ed-4755-962a-4675f97730c6] DISPATCHED : Dispatching task...

---------------------------------------------------------------------------

ExitTracingException                      Traceback (most recent call last)

[/tmp/ipython-input-1817750371.py](https://localhost:8080/#) in <cell line: 0>()
     12 with model.session(remote=True) as session:
---> 13   for i in range(df.shape[0]):
     14     row = df.iloc[i]

6 frames

ExitTracingException: 


During handling of the above exception, another exception occurred:

RemoteException                           Traceback (most recent call last)

[/usr/local/lib/python3.12/dist-packages/nnsight/intervention/backends/remote.py](https://localhost:8080/#) in handle_response(self, response, tracer)
    123 
    124         if response.status == ResponseModel.JobStatus.ERROR:
--> 125             raise RemoteException(f"{response.description}\nRemote exception.")
    126 
    127         # Log response for user

RemoteException: Traceback (most recent call last):
  File "/u/svcndifuser/ndif-deployment/repos/prod/ndif/src/services/ray/src/ray/deployments/modeling/base.py", line 191, in __call__
    inputs = self.pre()
             ^^^^^^^^^^
  File "/u/svcndifuser/miniconda3/envs/service/lib/python3.12/site-packages/ray/util/tracing/tracing_helper.py", line 463, in _resume_span
    return method(self, *_args, **_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/svcndifuser/ndif-deployment/repos/prod/ndif/src/services/ray/src/ray/deployments/modeling/base.py", line 242, in pre
    request = self.request.deserialize(self.model)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/svcndifuser/ndif-deployment/repos/prod/ndif/src/services/ray/src/schema/request.py", line 64, in deserialize
    return RequestModel.deserialize(model, request, self.zlib)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/svcndifuser/miniconda3/envs/service/lib/python3.12/site-packages/nnsight/schema/request.py", line 44, in deserialize
    request:RequestModel = load(data.read(), model)
                           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/svcndifuser/miniconda3/envs/service/lib/python3.12/site-packages/nnsight/intervention/serialization.py", line 72, in load
    return CustomCloudUnpickler(io.BytesIO(data), model, frame).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/svcndifuser/ndif-deployment/repos/prod/ndif/src/services/ray/src/ray/nn/security/protected_objects.py", line 93, in load
    return pickle.Unpickler.load(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/svcndifuser/ndif-deployment/repos/prod/ndif/src/services/ray/src/ray/nn/security/protected_environment.py", line 168, in __call__
    raise ImportError(f"Module {name} is not whitelisted")
ImportError: Module pandas.core.frame is not whitelisted

Module pandas.core.frame is not whitelisted
Remote exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    remote executionwhitelistAn operation is not whitelisted in remote execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions